Skip to content

Commit b5611ef

Browse files
authored
Use VS Code packaging for releases (#7721)
* Allow setting the VS Code build target For the NPM package (and tests, at least for now), we will still use linux-x64, but this is going to allow using the platform build targets for our standalone releases so we can avoid having to copy all the packaging steps (like cleaning up modules). This does mean that the NPM package when installed will be missing those cleanup steps. Possibly we can try to break out the packaging step into a something that can be ran standalone (which will also require installing dev dependencies like gulp) but not sure how much work this would be. * Preserve dependencies for e2e tests To avoid having to install them again. Also moved an env block to the root of the job. * Refactor releases to use VS Code packaging Instead of building the linux-x64 package, stripping the modules, then installing them again, we build the correct target and use the modules as they are. This means we do not have to copy all the post-processing steps like the ones that delete unnecessary modules. For the NPM package we still publish the linux-x64 package (without modules of course). This means npm installations do not get that same post-processing. Another advantage of this is that we can run the release immediately without having to wait for the build step, or on a commit that no longer has a build artifact, since they all build individually now. We could try sharing the core-ci build step, but leaving that alone for now. I also converted the macOS jobs into a matrix. Deleted the CI readme because it was out of date and seemed to just repeat what should be described in the scripts anyway. Removed a section about Homebrew since we do not maintain that anymore. It looks like there is no need to symlink node_modules.asar anymore.
1 parent a5c1b6a commit b5611ef

20 files changed

+322
-795
lines changed

.github/workflows/build.yaml

Lines changed: 51 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ concurrency:
1515
group: ${{ github.workflow }}-${{ github.ref }}
1616
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
1717

18-
# Note: if: success() is used in several jobs -
19-
# this ensures that it only executes if all previous jobs succeeded.
20-
21-
# if: steps.cache-node-modules.outputs.cache-hit != 'true'
22-
# will skip running `npm install` if it successfully fetched from cache
23-
2418
jobs:
2519
changes:
2620
runs-on: ubuntu-latest
@@ -31,10 +25,8 @@ jobs:
3125
docs: ${{ steps.filter.outputs.docs }}
3226
helm: ${{ steps.filter.outputs.helm }}
3327
steps:
34-
- name: Checkout repo
35-
uses: actions/checkout@v6
36-
- name: Check changed files
37-
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
28+
- uses: actions/checkout@v6
29+
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
3830
id: filter
3931
with:
4032
filters: |
@@ -157,20 +149,25 @@ jobs:
157149
token: ${{ secrets.CODECOV_TOKEN }}
158150

159151
build:
160-
name: Build code-server
152+
name: linux-x64
161153
runs-on: ubuntu-22.04
162154
env:
163155
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
164156
DISABLE_V8_COMPILE_CACHE: 1
157+
VERSION: 0.0.0
158+
VSCODE_TARGET: linux-x64
159+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160+
165161
steps:
166-
- uses: actions/checkout@v6
167-
with:
168-
submodules: true
169162
- run: sudo apt update && sudo apt install -y libkrb5-dev
170163
- uses: awalsh128/cache-apt-pkgs-action@2c09a5e66da6c8016428a2172bd76e5e4f14bb17 # latest
171164
with:
172165
packages: quilt
173166
version: 1.0
167+
168+
- uses: actions/checkout@v6
169+
with:
170+
submodules: true
174171
- run: quilt push -a
175172
- uses: actions/setup-node@v6
176173
with:
@@ -181,51 +178,43 @@ jobs:
181178
test/package-lock.json
182179
- run: SKIP_SUBMODULE_DEPS=1 npm ci
183180
- run: npm run build
184-
env:
185-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186181
# Get Code's git hash. When this changes it means the content is
187182
# different and we need to rebuild.
188183
- name: Get latest lib/vscode rev
189184
id: vscode-rev
190185
run: echo "rev=$(git rev-parse HEAD:./lib/vscode)" >> $GITHUB_OUTPUT
191-
# We need to rebuild when we have a new version of Code, when any of
192-
# the patches changed, or when the code-server version changes (since
193-
# it gets embedded into the code). Use VSCODE_CACHE_VERSION to
194-
# force a rebuild.
195-
- name: Fetch prebuilt Code package from cache
186+
# We need to rebuild when we have a new version of Code, when any of the
187+
# patches changed, or when the code-server version changes (since it gets
188+
# embedded into the code). Use VSCODE_CACHE_VERSION to force a rebuild.
189+
- name: Fetch prebuilt linux-x64 Code package from cache
196190
id: cache-vscode
197191
uses: actions/cache@v4
198192
with:
199-
path: lib/vscode-reh-web-*
200-
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
193+
path: lib/vscode-reh-web-linux-x64
194+
key: vscode-linux-x64-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
201195
- name: Build vscode
202-
env:
203-
VERSION: "0.0.0"
204196
if: steps.cache-vscode.outputs.cache-hit != 'true'
205197
run: |
206198
pushd lib/vscode
207199
npm ci
208200
popd
209201
npm run build:vscode
210-
# The release package does not contain any native modules
211-
# and is neutral to architecture/os/libc version.
212-
- run: npm run release
213-
if: success()
214-
# https://github.com/actions/upload-artifact/issues/38
202+
# Push up an artifact containing the linux-x64 release.
203+
- run: KEEP_MODULES=1 npm run release
215204
- run: tar -czf package.tar.gz release
216205
- uses: actions/upload-artifact@v7
217206
with:
218-
name: npm-package
207+
name: linux-x64-package
219208
path: ./package.tar.gz
220209

221210
test-e2e:
222211
name: Run e2e tests
223212
runs-on: ubuntu-22.04
224213
needs: [changes, build]
225-
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.deps == 'true'
214+
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.deps == 'true' || needs.changes.outputs.ci == 'true'
215+
226216
steps:
227217
- uses: actions/checkout@v6
228-
- run: sudo apt update && sudo apt install -y libkrb5-dev
229218
- uses: actions/setup-node@v6
230219
with:
231220
node-version-file: .node-version
@@ -234,31 +223,47 @@ jobs:
234223
package-lock.json
235224
test/package-lock.json
236225
- run: SKIP_SUBMODULE_DEPS=1 npm ci
237-
- uses: actions/download-artifact@v8
238-
with:
239-
name: npm-package
240-
- run: tar -xzf package.tar.gz
241-
- run: cd release && npm install --unsafe-perm --omit=dev
242226
- name: Install Playwright OS dependencies
243227
run: |
244228
./test/node_modules/.bin/playwright install-deps
245229
./test/node_modules/.bin/playwright install
230+
231+
- uses: actions/download-artifact@v8
232+
with:
233+
name: linux-x64-package
234+
- run: tar -xzf package.tar.gz
235+
246236
- run: CODE_SERVER_TEST_ENTRY=./release npm run test:e2e
247237
- uses: actions/upload-artifact@v7
248238
if: always()
249239
with:
250240
name: failed-test-videos
251241
path: ./test/test-results
252-
- run: rm -rf ./release ./test/test-results
253242

254243
test-e2e-proxy:
255244
name: Run e2e tests behind proxy
256245
runs-on: ubuntu-22.04
246+
env:
247+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
257248
needs: [changes, build]
258-
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.deps == 'true'
249+
if: needs.changes.outputs.code == 'true' || needs.changes.outputs.deps == 'true' || needs.changes.outputs.ci == 'true'
250+
259251
steps:
252+
- name: Cache Caddy
253+
uses: actions/cache@v4
254+
id: caddy-cache
255+
with:
256+
path: |
257+
~/.cache/caddy
258+
key: cache-caddy-2.5.2
259+
- name: Install Caddy
260+
if: steps.caddy-cache.outputs.cache-hit != 'true'
261+
run: |
262+
gh release download v2.5.2 --repo caddyserver/caddy --pattern "caddy_2.5.2_linux_amd64.tar.gz"
263+
mkdir -p ~/.cache/caddy
264+
tar -xzf caddy_2.5.2_linux_amd64.tar.gz --directory ~/.cache/caddy
265+
260266
- uses: actions/checkout@v6
261-
- run: sudo apt update && sudo apt install -y libkrb5-dev
262267
- uses: actions/setup-node@v6
263268
with:
264269
node-version-file: .node-version
@@ -267,35 +272,20 @@ jobs:
267272
package-lock.json
268273
test/package-lock.json
269274
- run: SKIP_SUBMODULE_DEPS=1 npm ci
270-
- uses: actions/download-artifact@v8
271-
with:
272-
name: npm-package
273-
- run: tar -xzf package.tar.gz
274-
- run: cd release && npm install --unsafe-perm --omit=dev
275275
- name: Install Playwright OS dependencies
276276
run: |
277277
./test/node_modules/.bin/playwright install-deps
278278
./test/node_modules/.bin/playwright install
279-
- name: Cache Caddy
280-
uses: actions/cache@v4
281-
id: caddy-cache
279+
280+
- uses: actions/download-artifact@v8
282281
with:
283-
path: |
284-
~/.cache/caddy
285-
key: cache-caddy-2.5.2
286-
- name: Install Caddy
287-
env:
288-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
289-
if: steps.caddy-cache.outputs.cache-hit != 'true'
290-
run: |
291-
gh release download v2.5.2 --repo caddyserver/caddy --pattern "caddy_2.5.2_linux_amd64.tar.gz"
292-
mkdir -p ~/.cache/caddy
293-
tar -xzf caddy_2.5.2_linux_amd64.tar.gz --directory ~/.cache/caddy
282+
name: linux-x64-package
283+
- run: tar -xzf package.tar.gz
284+
294285
- run: ~/.cache/caddy/caddy start --config ./ci/Caddyfile
295286
- run: CODE_SERVER_TEST_ENTRY=./release npm run test:e2e:proxy
296287
- run: ~/.cache/caddy/caddy stop --config ./ci/Caddyfile
297288
if: always()
298-
299289
- uses: actions/upload-artifact@v7
300290
if: always()
301291
with:

.github/workflows/publish.yaml

Lines changed: 35 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
workflow_dispatch:
77
inputs:
88
version:
9-
description: The version to publish (include "v", i.e. "v4.9.1").
109
type: string
1110
required: true
1211

@@ -23,50 +22,45 @@ concurrency:
2322
jobs:
2423
npm:
2524
runs-on: ubuntu-latest
25+
env:
26+
TAG: ${{ inputs.version || github.ref_name }}
27+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
29+
NPM_ENVIRONMENT: "production"
30+
2631
steps:
27-
- name: Checkout code-server
28-
uses: actions/checkout@v6
32+
- name: Set version to tag without leading v
33+
run: |
34+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
2935
30-
- name: Install Node.js
31-
uses: actions/setup-node@v6
36+
- uses: actions/checkout@v6
37+
- uses: actions/setup-node@v6
3238
with:
3339
node-version-file: .node-version
3440

35-
- name: Download npm package from release artifacts
36-
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
41+
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
3742
with:
3843
repository: "coder/code-server"
3944
tag: ${{ inputs.version || github.ref_name }}
4045
fileName: "package.tar.gz"
4146
out-file-path: "release-npm-package"
4247

43-
# Strip out the v (v4.9.1 -> 4.9.1).
44-
- name: Get and set VERSION
45-
run: |
46-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
47-
48-
env:
49-
TAG: ${{ inputs.version || github.ref_name }}
50-
- run: npm run publish:npm
51-
env:
52-
VERSION: ${{ env.VERSION }}
53-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
54-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
55-
NPM_ENVIRONMENT: "production"
48+
- run: tar -xzf release-npm-package/package.tar.gz
49+
- run: |
50+
pushd release
51+
npm publish --access public
5652
5753
aur:
5854
runs-on: ubuntu-latest
5955
timeout-minutes: 10
6056
env:
6157
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
58+
TAG: ${{ inputs.version || github.ref_name }}
6259

6360
steps:
64-
# We need to checkout code-server so we can get the version
65-
- name: Checkout code-server
66-
uses: actions/checkout@v6
67-
with:
68-
fetch-depth: 0
69-
path: "./code-server"
61+
- name: Set version to tag without leading v
62+
run: |
63+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
7064
7165
- name: Checkout code-server-aur repo
7266
uses: actions/checkout@v6
@@ -86,27 +80,14 @@ jobs:
8680
git config --global user.name cdrci
8781
git config --global user.email opensource@coder.com
8882
89-
# Strip out the v (v4.9.1 -> 4.9.1).
90-
- name: Get and set VERSION
91-
run: |
92-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
93-
94-
env:
95-
TAG: ${{ inputs.version || github.ref_name }}
9683
- name: Validate package
9784
uses: heyhusen/archlinux-package-action@c9f94059ccbebe8710d31d582f33ef4e84fe575c # v3.0.0
98-
env:
99-
VERSION: ${{ env.VERSION }}
10085
with:
10186
pkgver: ${{ env.VERSION }}
10287
updpkgsums: true
10388
srcinfo: true
10489

10590
- name: Open PR
106-
# We need to git push -u otherwise gh will prompt
107-
# asking where to push the branch.
108-
env:
109-
VERSION: ${{ env.VERSION }}
11091
run: |
11192
git checkout -b update-version-${{ env.VERSION }}
11293
git add .
@@ -116,54 +97,40 @@ jobs:
11697
11798
docker:
11899
runs-on: ubuntu-latest
119-
steps:
120-
- name: Checkout code-server
121-
uses: actions/checkout@v6
100+
env:
101+
GITHUB_TOKEN: ${{ github.token }}
102+
TAG: ${{ inputs.version || github.ref_name }}
122103

123-
- name: Set up QEMU
124-
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
104+
steps:
105+
- name: Set version to tag without leading v
106+
run: |
107+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
125108
126-
- name: Set up Docker Buildx
127-
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
109+
- uses: actions/checkout@v6
110+
- uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3
111+
- uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3
128112

129-
- name: Login to Docker Hub
130-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
113+
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
131114
with:
132115
username: ${{ secrets.DOCKER_USERNAME }}
133116
password: ${{ secrets.DOCKER_PASSWORD }}
134-
135-
- name: Login to GHCR
136-
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
117+
- uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
137118
with:
138119
registry: ghcr.io
139120
username: ${{ github.actor }}
140121
password: ${{ secrets.GITHUB_TOKEN }}
141122

142-
# Strip out the v (v4.9.1 -> 4.9.1).
143-
- name: Get and set VERSION
144-
run: |
145-
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
146-
147-
env:
148-
TAG: ${{ inputs.version || github.ref_name }}
149-
- name: Download deb artifacts
150-
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
123+
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
151124
with:
152125
repository: "coder/code-server"
153126
tag: v${{ env.VERSION }}
154127
fileName: "*.deb"
155128
out-file-path: "release-packages"
156-
157-
- name: Download rpm artifacts
158-
uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
129+
- uses: robinraju/release-downloader@daf26c55d821e836577a15f77d86ddc078948b05 # v1.12
159130
with:
160131
repository: "coder/code-server"
161132
tag: v${{ env.VERSION }}
162133
fileName: "*.rpm"
163134
out-file-path: "release-packages"
164135

165-
- name: Publish to Docker
166-
run: ./ci/steps/docker-buildx-push.sh
167-
env:
168-
VERSION: ${{ env.VERSION }}
169-
GITHUB_TOKEN: ${{ github.token }}
136+
- run: npm run publish:docker

0 commit comments

Comments
 (0)