Skip to content

Commit bc453b5

Browse files
committed
Switch to a single job to build the npm package
The architecture specific jobs pull it in and then build releases. Much faster!
1 parent 0ec1c69 commit bc453b5

File tree

8 files changed

+104
-72
lines changed

8 files changed

+104
-72
lines changed

.github/workflows/ci.yaml

+34-10
Original file line numberDiff line numberDiff line change
@@ -12,48 +12,72 @@ jobs:
1212
with:
1313
args: ./ci/steps/test.sh
1414

15-
linux-amd64:
15+
release:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- uses: actions/checkout@v1
1919
- name: Run ./ci/steps/release.sh
2020
uses: ./ci/container
2121
with:
2222
args: ./ci/steps/release.sh
23-
- name: Upload release artifacts
24-
uses: actions/upload-artifact@v2
25-
with:
26-
name: release-github
27-
path: ./release-github/*
2823
- name: Upload npm package artifact
2924
uses: actions/upload-artifact@v2
3025
with:
3126
name: npm-package
3227
path: ./release
3328

29+
linux-amd64:
30+
needs: release
31+
runs-on: ubuntu-latest
32+
steps:
33+
- uses: actions/checkout@v1
34+
- name: Download npm package
35+
uses: actions/download-artifact@v1
36+
with:
37+
name: npm-package
38+
- name: Run ./ci/steps/static-release.sh
39+
uses: ./ci/container
40+
with:
41+
args: ./ci/steps/static-release.sh
42+
- name: Upload release artifacts
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: release-github
46+
path: ./release-github/*
47+
3448
linux-arm64:
49+
needs: release
3550
runs-on: ubuntu-arm64-latest
3651
steps:
3752
- uses: actions/checkout@v1
38-
- name: Run ./ci/steps/release.sh
53+
- name: Download npm package
54+
uses: actions/download-artifact@v1
55+
with:
56+
name: npm-package
57+
- name: Run ./ci/steps/static-release.sh
3958
uses: ./ci/container
4059
with:
41-
args: ./ci/steps/release.sh
60+
args: ./ci/steps/static-release.sh
4261
- name: Upload release artifacts
4362
uses: actions/upload-artifact@v2
4463
with:
4564
name: release-github
4665
path: ./release-github/*
4766

4867
macos:
68+
needs: release
4969
runs-on: macos-latest
5070
steps:
5171
- uses: actions/checkout@v1
72+
- name: Download npm package
73+
uses: actions/download-artifact@v1
74+
with:
75+
name: npm-package
5276
- run: brew unlink node@12
5377
- run: brew install node
54-
- run: ./ci/steps/release.sh
78+
- run: ./ci/steps/static-release.sh
5579
env:
56-
# Otherwise we get a rate limited when fetching the ripgrep binary.
80+
# Otherwise we get rate limited when fetching the ripgrep binary.
5781
GITHUB_TOKEN: ${{ secrets.github_token }}
5882
- name: Upload release artifacts
5983
uses: actions/upload-artifact@v2

ci/README.md

+11-5
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ This directory contains scripts used for the development of code-server.
3333

3434
This directory contains the scripts used to build code-server.
3535

36+
- [./lib.sh](./lib.sh)
37+
- Contains code duplicated across these scripts.
3638
- [./build/build-code-server.sh](./build/build-code-server.sh) (`yarn build`)
3739
- Builds code-server into ./out and bundles the frontend into ./dist.
3840
- [./build/build-vscode.sh](./build/build-vscode.sh) (`yarn build:vscode`)
3941
- Builds vscode into ./lib/vscode/out-vscode.
4042
- [./build/build-release.sh](./build/build-release.sh) (`yarn release`)
41-
- Bundles the output of the above two scripts into a single node module at ./release.
42-
- Will build a static release with node/node_modules into `./release-static`
43-
if `STATIC=1` is set.
43+
- Bundles the output of the above two scripts into a single node module at `./release`.
44+
- [./build/build-static-release.sh](./build/build-static-release.sh) (`yarn release:static`)
45+
- Requires a release already built in `./release`.
46+
- Will build a static release with node and node_modules into `./release-static`
4447
- [./build/clean.sh](./build/clean.sh) (`yarn clean`)
4548
- Removes all git ignored files like build artifacts.
4649
- Will also `git reset --hard lib/vscode`
@@ -74,5 +77,8 @@ Just helps avoid clobbering .travis.yml.
7477
- [./steps/test.sh](./steps/test.sh)
7578
- Runs `yarn ci` after ensuring VS Code is patched
7679
- [./steps/release.sh](./steps/release.sh)
77-
- Runs the full static build process for CI
78-
- Packages the release into a .deb and .rpm for linux
80+
- Runs the full release process
81+
- Generates the npm package at `./release`
82+
- [./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.

ci/build/build-release.sh

+6-50
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# This script requires code-server and vscode to be built with
5-
# matching MINIFY.
6-
7-
# RELEASE_PATH is the destination directory for the release from the root.
8-
# Defaults to release
9-
RELEASE_PATH="${RELEASE_PATH-release}"
10-
11-
# STATIC controls whether node and node_modules are packaged into the release.
12-
# Disabled by default.
13-
STATIC="${STATIC-}"
4+
# This script requires code-server and vscode to be built with matching MINIFY.
145

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

19-
VSCODE_SRC_PATH="lib/vscode"
20-
21-
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
22-
2310
main() {
2411
cd "$(dirname "${0}")/../.."
25-
source ./ci/lib.sh
12+
source ./ci/build/lib.sh
13+
14+
VSCODE_SRC_PATH="lib/vscode"
15+
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
2616

2717
mkdir -p "$RELEASE_PATH"
2818

@@ -32,20 +22,6 @@ main() {
3222
rsync README.md "$RELEASE_PATH"
3323
rsync LICENSE.txt "$RELEASE_PATH"
3424
rsync ./lib/vscode/ThirdPartyNotices.txt "$RELEASE_PATH"
35-
36-
if [[ $STATIC ]]; then
37-
rsync "$RELEASE_PATH/" "$RELEASE_PATH-static"
38-
RELEASE_PATH+=-static
39-
VSCODE_OUT_PATH="$RELEASE_PATH/lib/vscode"
40-
41-
bundle_node
42-
else
43-
rm -Rf "$VSCODE_OUT_PATH/extensions/node_modules"
44-
fi
45-
}
46-
47-
rsync() {
48-
command rsync -a --del "$@"
4925
}
5026

5127
bundle_code_server() {
@@ -76,6 +52,7 @@ bundle_vscode() {
7652
mkdir -p "$VSCODE_OUT_PATH"
7753
rsync "$VSCODE_SRC_PATH/out-vscode${MINIFY+-min}/" "$VSCODE_OUT_PATH/out"
7854
rsync "$VSCODE_SRC_PATH/.build/extensions/" "$VSCODE_OUT_PATH/extensions"
55+
rm -Rf "$VSCODE_OUT_PATH/extensions/node_modules"
7956
rsync "$VSCODE_SRC_PATH/extensions/package.json" "$VSCODE_OUT_PATH/extensions"
8057
rsync "$VSCODE_SRC_PATH/extensions/yarn.lock" "$VSCODE_OUT_PATH/extensions"
8158
rsync "$VSCODE_SRC_PATH/extensions/postinstall.js" "$VSCODE_OUT_PATH/extensions"
@@ -103,25 +80,4 @@ EOF
10380
jq 'del(.scripts)' < "$VSCODE_SRC_PATH/package.json" > "$VSCODE_OUT_PATH/package.json"
10481
}
10582

106-
bundle_node() {
107-
# We cannot find the path to node from $PATH because yarn shims a script to ensure
108-
# we use the same version it's using so we instead run a script with yarn that
109-
# will print the path to node.
110-
local node_path
111-
node_path="$(yarn -s node <<< 'console.info(process.execPath)')"
112-
113-
mkdir -p "$RELEASE_PATH/bin"
114-
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
115-
rsync "$node_path" "$RELEASE_PATH/lib/node"
116-
117-
rsync node_modules "$RELEASE_PATH"
118-
rsync "$VSCODE_SRC_PATH/node_modules" "$VSCODE_OUT_PATH"
119-
120-
if [[ $MINIFY ]]; then
121-
pushd "$RELEASE_PATH"
122-
yarn --production
123-
popd
124-
fi
125-
}
126-
12783
main "$@"

ci/build/build-static-release.sh

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
cd "$(dirname "${0}")/../.."
6+
source ./ci/build/lib.sh
7+
8+
rsync "$RELEASE_PATH/" "$RELEASE_PATH-static"
9+
RELEASE_PATH+=-static
10+
11+
# We cannot find the path to node from $PATH because yarn shims a script to ensure
12+
# we use the same version it's using so we instead run a script with yarn that
13+
# will print the path to node.
14+
local node_path
15+
node_path="$(yarn -s node <<< 'console.info(process.execPath)')"
16+
17+
mkdir -p "$RELEASE_PATH/bin"
18+
rsync ./ci/build/code-server.sh "$RELEASE_PATH/bin/code-server"
19+
rsync "$node_path" "$RELEASE_PATH/lib/node"
20+
21+
cd "$RELEASE_PATH"
22+
yarn --production
23+
}
24+
25+
main "$@"

ci/build/lib.sh

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env bash
2+
source ./ci/lib.sh
3+
4+
# RELEASE_PATH is the destination directory for the release from the root.
5+
# Defaults to release
6+
RELEASE_PATH="${RELEASE_PATH-release}"
7+
8+
rsync() {
9+
command rsync -a --del "$@"
10+
}

ci/steps/release.sh

+1-7
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,7 @@ main() {
88
yarn vscode
99
yarn build
1010
yarn build:vscode
11-
STATIC=1 yarn release
12-
./ci/build/test-static-release.sh
13-
./ci/build/archive-static-release.sh
14-
15-
if [[ $OSTYPE == linux* ]]; then
16-
yarn pkg
17-
fi
11+
yarn release
1812
}
1913

2014
main "$@"

ci/steps/static-release.sh

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
main() {
5+
cd "$(dirname "$0")/../.."
6+
7+
yarn release:static
8+
./ci/build/test-static-release.sh
9+
./ci/build/archive-static-release.sh
10+
11+
if [[ $OSTYPE == linux* ]]; then
12+
yarn pkg
13+
fi
14+
}
15+
16+
main "$@"

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"build": "./ci/build/build-code-server.sh",
1717
"build:vscode": "./ci/build/build-vscode.sh",
1818
"release": "./ci/build/build-release.sh",
19+
"release:static": "./ci/build/build-static-release.sh",
1920
"pkg": "./ci/build/build-static-pkgs.sh",
2021
"_____": "",
2122
"fmt": "./ci/dev/fmt.sh",

0 commit comments

Comments
 (0)