Simplify packaging and improve scripts

Much better test now as well.
This commit is contained in:
Anmol Sethi 2020-05-08 00:34:20 -04:00
parent bc453b5f0d
commit 6282cd7e7b
No known key found for this signature in database
GPG Key ID: 8CEF1878FF10ADEB
13 changed files with 100 additions and 102 deletions

View File

@ -1,3 +1,3 @@
** **
!release-github !release-packages
!ci !ci

View File

@ -32,18 +32,19 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Download npm package - name: Download npm package
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: npm-package name: npm-package
- name: Run ./ci/steps/static-release.sh path: ./release
- name: Run ./ci/steps/release-static.sh
uses: ./ci/container uses: ./ci/container
with: with:
args: ./ci/steps/static-release.sh args: ./ci/steps/release-static.sh
- name: Upload release artifacts - name: Upload release artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: release-github name: release-packages
path: ./release-github/* path: ./release-packages
linux-arm64: linux-arm64:
needs: release needs: release
@ -51,18 +52,19 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Download npm package - name: Download npm package
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: npm-package name: npm-package
- name: Run ./ci/steps/static-release.sh path: ./release
- name: Run ./ci/steps/release-static.sh
uses: ./ci/container uses: ./ci/container
with: with:
args: ./ci/steps/static-release.sh args: ./ci/steps/release-static.sh
- name: Upload release artifacts - name: Upload release artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: release-github name: release-packages
path: ./release-github/* path: ./release-packages
macos: macos:
needs: release needs: release
@ -70,17 +72,18 @@ jobs:
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v1
- name: Download npm package - name: Download npm package
uses: actions/download-artifact@v1 uses: actions/download-artifact@v2
with: with:
name: npm-package name: npm-package
path: ./release
- run: brew unlink node@12 - run: brew unlink node@12
- run: brew install node - run: brew install node
- run: ./ci/steps/static-release.sh - run: ./ci/steps/release-static.sh
env: env:
# Otherwise we get rate limited when fetching the ripgrep binary. # Otherwise we get rate limited when fetching the ripgrep binary.
GITHUB_TOKEN: ${{ secrets.github_token }} GITHUB_TOKEN: ${{ secrets.github_token }}
- name: Upload release artifacts - name: Upload release artifacts
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v2
with: with:
name: release-github name: release-packages
path: ./release-github/* path: ./release-packages

2
.gitignore vendored
View File

@ -4,6 +4,6 @@ dist*
out* out*
release/ release/
release-static/ release-static/
release-github/ release-packages/
release-gcp/ release-gcp/
node_modules node_modules

View File

@ -32,6 +32,7 @@ This directory contains scripts used for the development of code-server.
## build ## build
This directory contains the scripts used to build code-server. This directory contains the scripts used to build code-server.
You can disable minification by setting `MINIFY=`.
- [./lib.sh](./lib.sh) - [./lib.sh](./lib.sh)
- Contains code duplicated across these scripts. - Contains code duplicated across these scripts.
@ -50,12 +51,11 @@ This directory contains the scripts used to build code-server.
- Useful to do a clean build. - Useful to do a clean build.
- [./build/code-server.sh](./build/code-server.sh) - [./build/code-server.sh](./build/code-server.sh)
- Copied into static releases to run code-server with the bundled node binary. - 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) - [./build/test-release.sh](./build/test-static-release.sh)
- Ensures code-server in the `./release-static` directory runs - Ensures code-server in the `./release-static` directory runs
- [./build/build-static-pkgs.sh](./build/build-static-pkgs.sh) (`yarn pkg`) - [./build/build-packages.sh](./build/build-static-pkgs.sh) (`yarn package`)
- Uses [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm from a static release - 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) - [./build/nfpm.yaml](./build/nfpm.yaml)
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm - Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh) - [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
@ -80,5 +80,4 @@ Just helps avoid clobbering .travis.yml.
- Runs the full release process - Runs the full release process
- Generates the npm package at `./release` - Generates the npm package at `./release`
- [./steps/static-release.sh](./steps/static-release.sh) - [./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` - Takes the output of the previous script and generates a static release and packages
- Also outputs .deb/.rpm if on linux.

View File

@ -1,41 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# Generates static code-server releases for CI.
# This script assumes that a static release is built already.
main() {
cd "$(dirname "${0}")/../.."
source ./ci/lib.sh
VERSION="$(pkg_json_version)"
local OS
OS="$(os)"
local ARCH
ARCH="$(arch)"
local archive_name="code-server-$VERSION-$OS-$ARCH"
mkdir -p release-github
local ext
if [[ $OS == "linux" ]]; then
ext=".tar.gz"
tar -czf "release-github/$archive_name$ext" --transform "s/^\.\/release-static/$archive_name/" ./release-static
else
mv ./release-static "./$archive_name"
ext=".zip"
zip -r "release-github/$archive_name$ext" "./$archive_name"
mv "./$archive_name" ./release-static
fi
echo "done (release-github/$archive_name)"
mkdir -p "release-gcp/$VERSION"
cp "release-github/$archive_name$ext" "./release-gcp/$VERSION/$OS-$ARCH$ext"
mkdir -p "release-gcp/latest"
cp "./release-github/$archive_name$ext" "./release-gcp/latest/$OS-$ARCH$ext"
}
main "$@"

59
ci/build/build-packages.sh Executable file
View File

@ -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 "$@"

View File

@ -1,10 +1,9 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail 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 # MINIFY controls whether minified vscode is bundled.
# any included node_modules are pruned for production.
MINIFY="${MINIFY-true}" MINIFY="${MINIFY-true}"
main() { main() {

View File

@ -1,24 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
# Generates deb and rpm packages for CI.
# Assumes a static release has already been built.
main() {
cd "$(dirname "${0}")/../.."
source ./ci/lib.sh
VERSION="$(pkg_json_version)"
export VERSION
ARCH="$(arch)"
export ARCH
local nfpm_config
nfpm_config=$(envsubst < ./ci/build/nfpm.yaml)
nfpm pkg -f <(echo "$nfpm_config") --target release-github/code-server-"$VERSION-$ARCH.deb"
nfpm pkg -f <(echo "$nfpm_config") --target release-github/code-server-"$VERSION-$ARCH.rpm"
}
main "$@"

0
ci/build/lib.sh Normal file → Executable file
View File

View File

@ -7,14 +7,21 @@ set -euo pipefail
main() { main() {
cd "$(dirname "${0}")/../.." cd "$(dirname "${0}")/../.."
local output local EXTENSIONS_DIR
output=$(./release-static/bin/code-server --list-extensions 2>&1) EXTENSIONS_DIR="$(mktemp -d)"
if echo "$output" | grep 'was compiled against a different Node.js version'; then
echo "$output" 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 exit 1
fi fi
echo "Build ran successfully" echo "Static release works correctly"
} }
main "$@" main "$@"

View File

@ -34,7 +34,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \
mkdir -p /etc/fixuid && \ mkdir -p /etc/fixuid && \
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml 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 RUN dpkg -i /tmp/code-server*.deb && rm /tmp/code-server*.deb
EXPOSE 8080 EXPOSE 8080

View File

@ -6,11 +6,7 @@ main() {
yarn release:static yarn release:static
./ci/build/test-static-release.sh ./ci/build/test-static-release.sh
./ci/build/archive-static-release.sh yarn package
if [[ $OSTYPE == linux* ]]; then
yarn pkg
fi
} }
main "$@" main "$@"

View File

@ -17,7 +17,7 @@
"build:vscode": "./ci/build/build-vscode.sh", "build:vscode": "./ci/build/build-vscode.sh",
"release": "./ci/build/build-release.sh", "release": "./ci/build/build-release.sh",
"release:static": "./ci/build/build-static-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", "fmt": "./ci/dev/fmt.sh",
"lint": "./ci/dev/lint.sh", "lint": "./ci/dev/lint.sh",