Skip to content

Commit 6282cd7

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

13 files changed

+100
-102
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

+17-14
Original file line numberDiff line numberDiff line change
@@ -32,55 +32,58 @@ jobs:
3232
steps:
3333
- uses: actions/checkout@v1
3434
- name: Download npm package
35-
uses: actions/download-artifact@v1
35+
uses: actions/download-artifact@v2
3636
with:
3737
name: npm-package
38-
- name: Run ./ci/steps/static-release.sh
38+
path: ./release
39+
- name: Run ./ci/steps/release-static.sh
3940
uses: ./ci/container
4041
with:
41-
args: ./ci/steps/static-release.sh
42+
args: ./ci/steps/release-static.sh
4243
- name: Upload release artifacts
4344
uses: actions/upload-artifact@v2
4445
with:
45-
name: release-github
46-
path: ./release-github/*
46+
name: release-packages
47+
path: ./release-packages
4748

4849
linux-arm64:
4950
needs: release
5051
runs-on: ubuntu-arm64-latest
5152
steps:
5253
- uses: actions/checkout@v1
5354
- name: Download npm package
54-
uses: actions/download-artifact@v1
55+
uses: actions/download-artifact@v2
5556
with:
5657
name: npm-package
57-
- name: Run ./ci/steps/static-release.sh
58+
path: ./release
59+
- name: Run ./ci/steps/release-static.sh
5860
uses: ./ci/container
5961
with:
60-
args: ./ci/steps/static-release.sh
62+
args: ./ci/steps/release-static.sh
6163
- name: Upload release artifacts
6264
uses: actions/upload-artifact@v2
6365
with:
64-
name: release-github
65-
path: ./release-github/*
66+
name: release-packages
67+
path: ./release-packages
6668

6769
macos:
6870
needs: release
6971
runs-on: macos-latest
7072
steps:
7173
- uses: actions/checkout@v1
7274
- name: Download npm package
73-
uses: actions/download-artifact@v1
75+
uses: actions/download-artifact@v2
7476
with:
7577
name: npm-package
78+
path: ./release
7679
- run: brew unlink node@12
7780
- run: brew install node
78-
- run: ./ci/steps/static-release.sh
81+
- run: ./ci/steps/release-static.sh
7982
env:
8083
# Otherwise we get rate limited when fetching the ripgrep binary.
8184
GITHUB_TOKEN: ${{ secrets.github_token }}
8285
- name: Upload release artifacts
8386
uses: actions/upload-artifact@v2
8487
with:
85-
name: release-github
86-
path: ./release-github/*
88+
name: release-packages
89+
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

+12-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,21 @@ 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"
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+
local installed_extensions
17+
installed_extensions="$(./release-static/bin/code-server --extensions-dir "$EXTENSIONS_DIR" --list-extensions 2>&1)"
18+
if [[ $installed_extensions != "ms-python.python" ]]; then
19+
echo "Unexpected output from listing extensions:"
20+
echo "$installed_extensions"
1421
exit 1
1522
fi
1623

17-
echo "Build ran successfully"
24+
echo "Static release works correctly"
1825
}
1926

2027
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 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)