Skip to content

Commit

Permalink
Simplify packaging and improve scripts
Browse files Browse the repository at this point in the history
Much better test now as well.
  • Loading branch information
nhooyr committed May 8, 2020
1 parent bc453b5 commit 6282cd7
Show file tree
Hide file tree
Showing 13 changed files with 100 additions and 102 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
**
!release-github
!release-packages
!ci
31 changes: 17 additions & 14 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,55 +32,58 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Download npm package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2
with:
name: npm-package
- name: Run ./ci/steps/static-release.sh
path: ./release
- name: Run ./ci/steps/release-static.sh
uses: ./ci/container
with:
args: ./ci/steps/static-release.sh
args: ./ci/steps/release-static.sh
- name: Upload release artifacts
uses: actions/upload-artifact@v2
with:
name: release-github
path: ./release-github/*
name: release-packages
path: ./release-packages

linux-arm64:
needs: release
runs-on: ubuntu-arm64-latest
steps:
- uses: actions/checkout@v1
- name: Download npm package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2
with:
name: npm-package
- name: Run ./ci/steps/static-release.sh
path: ./release
- name: Run ./ci/steps/release-static.sh
uses: ./ci/container
with:
args: ./ci/steps/static-release.sh
args: ./ci/steps/release-static.sh
- name: Upload release artifacts
uses: actions/upload-artifact@v2
with:
name: release-github
path: ./release-github/*
name: release-packages
path: ./release-packages

macos:
needs: release
runs-on: macos-latest
steps:
- uses: actions/checkout@v1
- name: Download npm package
uses: actions/download-artifact@v1
uses: actions/download-artifact@v2
with:
name: npm-package
path: ./release
- run: brew unlink node@12
- run: brew install node
- run: ./ci/steps/static-release.sh
- run: ./ci/steps/release-static.sh
env:
# Otherwise we get rate limited when fetching the ripgrep binary.
GITHUB_TOKEN: ${{ secrets.github_token }}
- name: Upload release artifacts
uses: actions/upload-artifact@v2
with:
name: release-github
path: ./release-github/*
name: release-packages
path: ./release-packages
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ dist*
out*
release/
release-static/
release-github/
release-packages/
release-gcp/
node_modules
11 changes: 5 additions & 6 deletions ci/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ This directory contains scripts used for the development of code-server.
## build

This directory contains the scripts used to build code-server.
You can disable minification by setting `MINIFY=`.

- [./lib.sh](./lib.sh)
- Contains code duplicated across these scripts.
Expand All @@ -50,12 +51,11 @@ This directory contains the scripts used to build code-server.
- Useful to do a clean build.
- [./build/code-server.sh](./build/code-server.sh)
- Copied into static releases to run code-server with the bundled node binary.
- [./build/archive-static-release.sh](./build/archive-static-release.sh)
- Archives `./release-static` into a tar/zip for CI with the proper directory name scheme
- [./build/test-release.sh](./build/test-static-release.sh)
- Ensures code-server in the `./release-static` directory runs
- [./build/build-static-pkgs.sh](./build/build-static-pkgs.sh) (`yarn pkg`)
- Uses [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm from a static release
- [./build/build-packages.sh](./build/build-static-pkgs.sh) (`yarn package`)
- Packages `./release-static` into an archive in `./release-packages`
- If on linux, [nfpm](https://github.com/goreleaser/nfpm) is used to generate .deb and .rpm
- [./build/nfpm.yaml](./build/nfpm.yaml)
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
Expand All @@ -80,5 +80,4 @@ Just helps avoid clobbering .travis.yml.
- Runs the full release process
- Generates the npm package at `./release`
- [./steps/static-release.sh](./steps/static-release.sh)
- Takes the output of the previous script and bundles it into a self-contained archive into `./github-release`
- Also outputs .deb/.rpm if on linux.
- Takes the output of the previous script and generates a static release and packages
41 changes: 0 additions & 41 deletions ci/build/archive-static-release.sh

This file was deleted.

59 changes: 59 additions & 0 deletions ci/build/build-packages.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/usr/bin/env bash
set -euo pipefail

# Packages code-server for the current OS and architecture into ./release-packages.
# This script assumes that a static release is built already into ./release-static.

main() {
cd "$(dirname "${0}")/../.."
source ./ci/lib.sh

export VERSION
VERSION="$(pkg_json_version)"

local OS
OS="$(os)"

export ARCH
ARCH="$(arch)"

local archive_name="code-server-$VERSION-$OS-$ARCH"
mkdir -p release-packages

local ext
if [[ $OS == "linux" ]]; then
ext=".tar.gz"
tar -czf "release-packages/$archive_name$ext" --transform "s/^\.\/release-static/$archive_name/" ./release-static
else
mv ./release-static "./$archive_name"
ext=".zip"
zip -r "release-packages/$archive_name$ext" "./$archive_name"
mv "./$archive_name" ./release-static
fi

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

release_gcp

if [[ $OSTYPE == linux* ]]; then
release_nfpm
fi
}

release_gcp() {
mkdir -p "release-gcp/$VERSION"
cp "release-packages/$archive_name$ext" "./release-gcp/$VERSION/$OS-$ARCH$ext"
mkdir -p "release-gcp/latest"
cp "./release-packages/$archive_name$ext" "./release-gcp/latest/$OS-$ARCH$ext"
}

# Generates deb and rpm packages.
release_nfpm() {
local nfpm_config
nfpm_config=$(envsubst < ./ci/build/nfpm.yaml)

nfpm pkg -f <(echo "$nfpm_config") --target release-packages/code-server-"$VERSION-$ARCH.deb"
nfpm pkg -f <(echo "$nfpm_config") --target release-packages/code-server-"$VERSION-$ARCH.rpm"
}

main "$@"
5 changes: 2 additions & 3 deletions ci/build/build-release.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail

# This script requires code-server and vscode to be built with matching MINIFY.
# This script requires vscode to be built with matching MINIFY.

# MINIFY controls whether minified vscode is bundled and whether
# any included node_modules are pruned for production.
# MINIFY controls whether minified vscode is bundled.
MINIFY="${MINIFY-true}"

main() {
Expand Down
24 changes: 0 additions & 24 deletions ci/build/build-static-pkgs.sh

This file was deleted.

Empty file modified ci/build/lib.sh
100644 → 100755
Empty file.
17 changes: 12 additions & 5 deletions ci/build/test-static-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@ set -euo pipefail
main() {
cd "$(dirname "${0}")/../.."

local output
output=$(./release-static/bin/code-server --list-extensions 2>&1)
if echo "$output" | grep 'was compiled against a different Node.js version'; then
echo "$output"
local EXTENSIONS_DIR
EXTENSIONS_DIR="$(mktemp -d)"

echo "Testing static release"

./release-static/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python
local installed_extensions
installed_extensions="$(./release-static/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
if [[ $installed_extensions != "ms-python.python" ]]; then
echo "Unexpected output from listing extensions:"
echo "$installed_extensions"
exit 1
fi

echo "Build ran successfully"
echo "Static release works correctly"
}

main "$@"
2 changes: 1 addition & 1 deletion ci/release-container/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \
mkdir -p /etc/fixuid && \
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml

COPY release-github/code-server*.deb /tmp/
COPY release-packages/code-server*.deb /tmp/
RUN dpkg -i /tmp/code-server*.deb && rm /tmp/code-server*.deb

EXPOSE 8080
Expand Down
6 changes: 1 addition & 5 deletions ci/steps/static-release.sh → ci/steps/release-static.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ main() {

yarn release:static
./ci/build/test-static-release.sh
./ci/build/archive-static-release.sh

if [[ $OSTYPE == linux* ]]; then
yarn pkg
fi
yarn package
}

main "$@"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build:vscode": "./ci/build/build-vscode.sh",
"release": "./ci/build/build-release.sh",
"release:static": "./ci/build/build-static-release.sh",
"pkg": "./ci/build/build-static-pkgs.sh",
"package": "./ci/build/build-packages.sh",
"_____": "",
"fmt": "./ci/dev/fmt.sh",
"lint": "./ci/dev/lint.sh",
Expand Down

0 comments on commit 6282cd7

Please sign in to comment.