Skip to content

Commit 2ea8a72

Browse files
committed
Simplify packaging and improve scripts
Much better test now as well.
1 parent bc453b5 commit 2ea8a72

13 files changed

+91
-100
lines changed

.dockerignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
**
2-
!release-github
2+
!release-packages
33
!ci

.github/workflows/ci.yaml

+11-11
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ jobs:
3535
uses: actions/download-artifact@v1
3636
with:
3737
name: npm-package
38-
- name: Run ./ci/steps/static-release.sh
38+
- name: Run ./ci/steps/release-static.sh
3939
uses: ./ci/container
4040
with:
41-
args: ./ci/steps/static-release.sh
41+
args: ./ci/steps/release-static.sh
4242
- name: Upload release artifacts
4343
uses: actions/upload-artifact@v2
4444
with:
45-
name: release-github
46-
path: ./release-github/*
45+
name: release-packages
46+
path: ./release-packages/*
4747

4848
linux-arm64:
4949
needs: release
@@ -54,15 +54,15 @@ jobs:
5454
uses: actions/download-artifact@v1
5555
with:
5656
name: npm-package
57-
- name: Run ./ci/steps/static-release.sh
57+
- name: Run ./ci/steps/release-static.sh
5858
uses: ./ci/container
5959
with:
60-
args: ./ci/steps/static-release.sh
60+
args: ./ci/steps/release-static.sh
6161
- name: Upload release artifacts
6262
uses: actions/upload-artifact@v2
6363
with:
64-
name: release-github
65-
path: ./release-github/*
64+
name: release-packages
65+
path: ./release-packages/*
6666

6767
macos:
6868
needs: release
@@ -75,12 +75,12 @@ jobs:
7575
name: npm-package
7676
- run: brew unlink node@12
7777
- run: brew install node
78-
- run: ./ci/steps/static-release.sh
78+
- run: ./ci/steps/release-static.sh
7979
env:
8080
# Otherwise we get rate limited when fetching the ripgrep binary.
8181
GITHUB_TOKEN: ${{ secrets.github_token }}
8282
- name: Upload release artifacts
8383
uses: actions/upload-artifact@v2
8484
with:
85-
name: release-github
86-
path: ./release-github/*
85+
name: release-packages
86+
path: ./release-packages/*

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ dist*
44
out*
55
release/
66
release-static/
7-
release-github/
7+
release-packages/
88
release-gcp/
99
node_modules

ci/README.md

+5-6
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ This directory contains scripts used for the development of code-server.
3232
## build
3333

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

3637
- [./lib.sh](./lib.sh)
3738
- Contains code duplicated across these scripts.
@@ -50,12 +51,11 @@ This directory contains the scripts used to build code-server.
5051
- Useful to do a clean build.
5152
- [./build/code-server.sh](./build/code-server.sh)
5253
- Copied into static releases to run code-server with the bundled node binary.
53-
- [./build/archive-static-release.sh](./build/archive-static-release.sh)
54-
- Archives `./release-static` into a tar/zip for CI with the proper directory name scheme
5554
- [./build/test-release.sh](./build/test-static-release.sh)
5655
- Ensures code-server in the `./release-static` directory runs
57-
- [./build/build-static-pkgs.sh](./build/build-static-pkgs.sh) (`yarn pkg`)
58-
- Uses [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm from a static release
56+
- [./build/build-packages.sh](./build/build-static-pkgs.sh) (`yarn package`)
57+
- Packages `./release-static` into an archive in `./release-packages`
58+
- If on linux, [nfpm](https://github.com/goreleaser/nfpm) is used to generate .deb and .rpm
5959
- [./build/nfpm.yaml](./build/nfpm.yaml)
6060
- Used to configure [nfpm](https://github.com/goreleaser/nfpm) to generate .deb and .rpm
6161
- [./build/code-server-nfpm.sh](./build/code-server-nfpm.sh)
@@ -80,5 +80,4 @@ Just helps avoid clobbering .travis.yml.
8080
- Runs the full release process
8181
- Generates the npm package at `./release`
8282
- [./steps/static-release.sh](./steps/static-release.sh)
83-
- Takes the output of the previous script and bundles it into a self-contained archive into `./github-release`
84-
- Also outputs .deb/.rpm if on linux.
83+
- Takes the output of the previous script and generates a static release and packages

ci/build/archive-static-release.sh

-41
This file was deleted.

ci/build/build-packages.sh

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Packages code-server for the current OS and architecture into ./release-packages.
5+
# This script assumes that a static release is built already into ./release-static.
6+
7+
main() {
8+
cd "$(dirname "${0}")/../.."
9+
source ./ci/lib.sh
10+
11+
export VERSION
12+
VERSION="$(pkg_json_version)"
13+
14+
local OS
15+
OS="$(os)"
16+
17+
export ARCH
18+
ARCH="$(arch)"
19+
20+
local archive_name="code-server-$VERSION-$OS-$ARCH"
21+
mkdir -p release-packages
22+
23+
local ext
24+
if [[ $OS == "linux" ]]; then
25+
ext=".tar.gz"
26+
tar -czf "release-packages/$archive_name$ext" --transform "s/^\.\/release-static/$archive_name/" ./release-static
27+
else
28+
mv ./release-static "./$archive_name"
29+
ext=".zip"
30+
zip -r "release-packages/$archive_name$ext" "./$archive_name"
31+
mv "./$archive_name" ./release-static
32+
fi
33+
34+
echo "done (release-packages/$archive_name)"
35+
36+
release_gcp
37+
38+
if [[ $OSTYPE == linux* ]]; then
39+
release_nfpm
40+
fi
41+
}
42+
43+
release_gcp() {
44+
mkdir -p "release-gcp/$VERSION"
45+
cp "release-packages/$archive_name$ext" "./release-gcp/$VERSION/$OS-$ARCH$ext"
46+
mkdir -p "release-gcp/latest"
47+
cp "./release-packages/$archive_name$ext" "./release-gcp/latest/$OS-$ARCH$ext"
48+
}
49+
50+
# Generates deb and rpm packages.
51+
release_nfpm() {
52+
local nfpm_config
53+
nfpm_config=$(envsubst < ./ci/build/nfpm.yaml)
54+
55+
nfpm pkg -f <(echo "$nfpm_config") --target release-packages/code-server-"$VERSION-$ARCH.deb"
56+
nfpm pkg -f <(echo "$nfpm_config") --target release-packages/code-server-"$VERSION-$ARCH.rpm"
57+
}
58+
59+
main "$@"

ci/build/build-release.sh

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

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

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

109
main() {

ci/build/build-static-pkgs.sh

-24
This file was deleted.

ci/build/lib.sh

100644100755
File mode changed.

ci/build/test-static-release.sh

+9-6
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ set -euo pipefail
77
main() {
88
cd "$(dirname "${0}")/../.."
99

10-
local output
11-
output=$(./release-static/bin/code-server --list-extensions 2>&1)
12-
if echo "$output" | grep 'was compiled against a different Node.js version'; then
13-
echo "$output"
14-
exit 1
10+
local EXTENSIONS_DIR
11+
EXTENSIONS_DIR="$(mktemp -d)"
12+
13+
echo "Testing static release"
14+
15+
./release-static/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --install-extension ms-python.python
16+
if ! ./release-static/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions | grep -q ms-python.python; then
17+
./release-static/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions
1518
fi
1619

17-
echo "Build ran successfully"
20+
echo "Static release works correctly"
1821
}
1922

2023
main "$@"

ci/release-container/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ RUN ARCH="$(dpkg --print-architecture)" && \
3434
mkdir -p /etc/fixuid && \
3535
printf "user: coder\ngroup: coder\n" > /etc/fixuid/config.yml
3636

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

4040
EXPOSE 8080

ci/steps/static-release.sh renamed to ci/steps/release-static.sh

+1-5
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ main() {
66

77
yarn release:static
88
./ci/build/test-static-release.sh
9-
./ci/build/archive-static-release.sh
10-
11-
if [[ $OSTYPE == linux* ]]; then
12-
yarn pkg
13-
fi
9+
yarn package
1410
}
1511

1612
main "$@"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"build:vscode": "./ci/build/build-vscode.sh",
1818
"release": "./ci/build/build-release.sh",
1919
"release:static": "./ci/build/build-static-release.sh",
20-
"pkg": "./ci/build/build-static-pkgs.sh",
20+
"package": "./ci/build/build-packages.sh",
2121
"_____": "",
2222
"fmt": "./ci/dev/fmt.sh",
2323
"lint": "./ci/dev/lint.sh",

0 commit comments

Comments
 (0)