Skip to content

Stop bundling libraries in release #1761

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Jun 4, 2020
Merged
18 changes: 8 additions & 10 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/fmt.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/fmt.sh

Expand All @@ -17,7 +17,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/lint.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/lint.sh

Expand All @@ -26,7 +26,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/test.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/test.sh

Expand All @@ -35,7 +35,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/release.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/release.sh
- name: Upload npm package artifact
Expand All @@ -55,7 +55,7 @@ jobs:
name: npm-package
path: ./release-npm-package
- name: Run ./ci/steps/release-packages.sh
uses: ./ci/container
uses: ./ci/images/centos7
with:
args: ./ci/steps/release-packages.sh
- name: Upload release artifacts
Expand All @@ -75,7 +75,7 @@ jobs:
name: npm-package
path: ./release-npm-package
- name: Run ./ci/steps/release-packages.sh
uses: ./ci/container/arm64
uses: ./ci/images/centos7
with:
args: ./ci/steps/release-packages.sh
- name: Upload release artifacts
Expand All @@ -94,8 +94,6 @@ jobs:
with:
name: npm-package
path: ./release-npm-package
- run: brew unlink node@12
- run: brew install node
- run: ./ci/steps/release-packages.sh
env:
# Otherwise we get rate limited when fetching the ripgrep binary.
Expand All @@ -118,7 +116,7 @@ jobs:
name: release-packages
path: ./release-packages
- name: Run ./ci/steps/build-docker-image.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/build-docker-image.sh
- name: Upload release image
Expand All @@ -138,7 +136,7 @@ jobs:
name: release-packages
path: ./release-packages
- name: Run ./ci/steps/build-docker-image.sh
uses: ./ci/container/arm64
uses: ./ci/images/centos7
with:
args: ./ci/steps/build-docker-image.sh
- name: Upload release image
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/publish-npm.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/publish-npm.sh
env:
Expand All @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Run ./ci/steps/push-docker-manifest.sh
uses: ./ci/container
uses: ./ci/images/debian8
with:
args: ./ci/steps/push-docker-manifest.sh
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ release-packages/
release-gcp/
release-images/
node_modules
node-*
1 change: 1 addition & 0 deletions .ignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lib
13 changes: 7 additions & 6 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ Make sure you have `$GITHUB_TOKEN` set and [hub](https://github.com/github/hub)
10. Wait for the npm package to be published.
11. Update the homebrew package.
- Send a pull request to [homebrew-core](https://github.com/Homebrew/homebrew-core) with the URL in the [formula](https://github.com/Homebrew/homebrew-core/blob/master/Formula/code-server.rb) updated.
12. Make sure to add a release without the `v` prefix for autoupdate from `3.2.0`.

## dev

This directory contains scripts used for the development of code-server.

- [./ci/dev/container](./dev/container)
- [./ci/dev/image](./dev/image)
- See [./doc/CONTRIBUTING.md](../doc/CONTRIBUTING.md) for docs on the development container.
- [./ci/dev/fmt.sh](./dev/fmt.sh) (`yarn fmt`)
- Runs formatters.
Expand Down Expand Up @@ -104,17 +105,17 @@ You can disable minification by setting `MINIFY=`.
- Post install script for the npm package.
- Bundled by`yarn release`.

## release-container
## release-image

This directory contains the release docker container.
This directory contains the release docker container image.

- [./release-container/build.sh](./release-container/build.sh)
- [./release-image/build.sh](./release-image/build.sh)
- Builds the release container with the tag `codercom/code-server-$ARCH:$VERSION`.
- Assumes debian releases are ready in `./release-packages`.

## container
## images

This directory contains the container for CI.
This directory contains the images for CI.

## steps

Expand Down
7 changes: 7 additions & 0 deletions ci/build/build-packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,16 @@ release_archive() {
local release_name="code-server-$VERSION-$OS-$ARCH"
if [[ $OS == "linux" ]]; then
tar -czf "release-packages/$release_name.tar.gz" --transform "s/^\.\/release-standalone/$release_name/" ./release-standalone
elif [[ $OS == "darwin" && $ARCH == "x86_64" ]]; then
# Just exists to make autoupdating from 3.2.0 work again.
mv ./release-standalone "./$release_name"
zip -r "release-packages/$release_name.zip" "./$release_name"
mv "./$release_name" ./release-standalone
return
else
tar -czf "release-packages/$release_name.tar.gz" -s "/^release-standalone/$release_name/" release-standalone
fi

echo "done (release-packages/$release_name)"

release_gcp
Expand Down
21 changes: 0 additions & 21 deletions ci/build/build-standalone-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,6 @@ main() {
mkdir -p "$RELEASE_PATH/bin"
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
rsync "$node_path" "$RELEASE_PATH/lib/node"
if [[ $OS == "linux" ]]; then
bundle_dynamic_lib libstdc++
bundle_dynamic_lib libgcc_s
elif [[ $OS == "macos" ]]; then
bundle_dynamic_lib libicui18n
bundle_dynamic_lib libicuuc
bundle_dynamic_lib libicudata
fi

ln -s "./bin/code-server" "$RELEASE_PATH/code-server"
ln -s "./lib/node" "$RELEASE_PATH/node"
Expand All @@ -33,17 +25,4 @@ main() {
yarn --production --frozen-lockfile
}

bundle_dynamic_lib() {
local lib_name="$1"
local lib_path

if [[ $OS == "linux" ]]; then
lib_path="$(ldd "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $3 }')"
elif [[ $OS == "macos" ]]; then
lib_path="$(otool -L "$RELEASE_PATH/lib/node" | grep "$lib_name" | awk '{print $1 }')"
fi

cp "$lib_path" "$RELEASE_PATH/lib"
}

main "$@"
47 changes: 29 additions & 18 deletions ci/build/code-server.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,36 @@
#!/bin/sh
set -eu

# This script is intended to be bundled into the standalone releases.
# Runs code-server with the bundled node binary.

# More complicated than readlink -f or realpath to support macOS.
# See https://github.com/cdr/code-server/issues/1537
bin_dir() {
# We read the symlink, which may be relative from $0.
dst="$(readlink "$0")"
# We cd into the $0 directory.
cd "$(dirname "$0")" || exit 1
# Now we can cd into the dst directory.
cd "$(dirname "$dst")" || exit 1
# Finally we use pwd -P to print the absolute path of the directory of $dst.
pwd -P || exit 1
_realpath() {
# See https://github.com/cdr/code-server/issues/1537 on why no realpath or readlink -f.

script="$1"
cd "$(dirname "$script")"

while [ -L "$(basename "$script")" ]; do
if [ -L "./node" ] && [ -L "./code-server" ] &&
[ -f "package.json" ] &&
cat package.json | grep -q '^ "name": "code-server",$'; then
echo "***** Please use the script in bin/code-server instead!" >&2
echo "***** This script will soon be removed!" >&2
echo "***** See the release notes at https://github.com/cdr/code-server/releases/tag/v3.4.0" >&2
fi

script="$(readlink "$(basename "$script")")"
cd "$(dirname "$script")"
done

echo "$PWD/$(basename "$script")"
}

root() {
script="$(_realpath "$0")"
bin_dir="$(dirname "$script")"
dirname "$bin_dir"
}

BIN_DIR=$(bin_dir)
if [ "$(uname)" = "Linux" ]; then
export LD_LIBRARY_PATH="$BIN_DIR/../lib${LD_LIBRARY_PATH+:$LD_LIBRARY_PATH}"
elif [ "$(uname)" = "Darwin" ]; then
export DYLD_LIBRARY_PATH="$BIN_DIR/../lib${DYLD_LIBRARY_PATH+:$DYLD_LIBRARY_PATH}"
fi
exec "$BIN_DIR/../lib/node" "$BIN_DIR/.." "$@"
ROOT="$(root)"
exec "$ROOT/lib/node" "$ROOT" "$@"
3 changes: 2 additions & 1 deletion ci/build/test-standalone-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ main() {
./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python
local installed_extensions
installed_extensions="$(./release-standalone/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
if [[ $installed_extensions != "ms-python.python" ]]; then
if [[ $installed_extensions != "info Using config file ~/.config/code-server/config.yaml
ms-python.python" ]]; then
echo "Unexpected output from listing extensions:"
echo "$installed_extensions"
exit 1
Expand Down
53 changes: 0 additions & 53 deletions ci/container/arm64/Dockerfile

This file was deleted.

6 changes: 0 additions & 6 deletions ci/container/arm64/README.md

This file was deleted.

4 changes: 3 additions & 1 deletion ci/dev/fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set -euo pipefail
main() {
cd "$(dirname "$0")/../.."

shfmt -i 2 -w -s -sr $(git ls-files "*.sh")
shfmt -i 2 -w -sr $(git ls-files "*.sh")

local prettierExts
prettierExts=(
Expand All @@ -24,6 +24,8 @@ main() {
doctoc --title '# FAQ' doc/FAQ.md > /dev/null
doctoc --title '# Setup Guide' doc/guide.md > /dev/null
doctoc --title '# Install' doc/install.md > /dev/null
doctoc --title '# npm Install Requirements' doc/npm.md > /dev/null
doctoc --title '# Contributing' doc/CONTRIBUTING.md > /dev/null

if [[ ${CI-} && $(git ls-files --other --modified --exclude-standard) ]]; then
echo "Files need generation or are formatted incorrectly:"
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion ci/dev/container/exec.sh → ci/dev/image/exec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ run() {

build() {
echo "--- Building $container_name"
docker build -t $container_name ./ci/dev/container > /dev/null
docker build -t $container_name ./ci/dev/image > /dev/null
}

main "$@"
4 changes: 2 additions & 2 deletions ci/dev/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ main() {
eslint --max-warnings=0 --fix $(git ls-files "*.ts" "*.tsx" "*.js")
stylelint $(git ls-files "*.css")
tsc --noEmit
# See comment in ./ci/container/Dockerfile
# See comment in ./ci/image/debian8
if [[ ! ${CI-} ]]; then
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090 $(git ls-files "*.sh")
shellcheck -e SC2046,SC2164,SC2154,SC1091,SC1090,SC2002 $(git ls-files "*.sh")
fi
}

Expand Down
26 changes: 26 additions & 0 deletions ci/images/centos7/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM centos:7

RUN ARCH="$(uname -m | sed 's/86_64/64/; s/aarch64/arm64/')" && \
curl -fsSL "https://nodejs.org/dist/v14.4.0/node-v14.4.0-linux-$ARCH.tar.xz" | tar -C /usr/local -xJ && \
mv /usr/local/node-v14.4.0-linux-$ARCH /usr/local/node-v14.4.0
ENV PATH=/usr/local/node-v14.4.0/bin:$PATH
RUN npm install -g yarn

RUN yum groupinstall -y 'Development Tools'
RUN yum install -y python2 libsecret-devel libX11-devel libxkbfile-devel

RUN npm config set python python2

RUN yum install -y epel-release && yum install -y jq
RUN yum install -y rsync

# Copied from ../debian8/Dockerfile
# Install Go dependencies
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \
curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
ENV GO111MODULE=on
RUN go get mvdan.cc/sh/v3/cmd/shfmt
RUN go get github.com/goreleaser/nfpm/cmd/nfpm

RUN curl -fsSL https://get.docker.com | sh
2 changes: 1 addition & 1 deletion ci/container/Dockerfile → ci/images/debian8/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \
# rm -R shellcheck*

# Install Go dependencies
RUN ARCH="$(dpkg --print-architecture)" && \
RUN ARCH="$(uname -m | sed 's/x86_64/amd64/; s/aarch64/arm64/')" && \
curl -fsSL "https://dl.google.com/go/go1.14.3.linux-$ARCH.tar.gz" | tar -C /usr/local -xz
ENV PATH=/usr/local/go/bin:/root/go/bin:$PATH
ENV GO111MODULE=on
Expand Down
File renamed without changes.
Loading