Skip to content

Commit b978655

Browse files
authored
refactor: get version dynamically (#5753)
* refactor: get version dynamically * chore: remove version * fixup: missing quotes * refactor: drop global VERSION * wip: updating ersion in publish * refactor: update publish.yaml with version changes * refactor: release.yaml with new version changes * refactor: update build.yaml with version changes * chore: update maintainer * fixup: update version in build-vscode * fixup: fix github env version * try macos only * try again * last resort * joe again * this oneee * fixup: this should work * try using inputs * docs: update release notes * fixup!: use env.VERSION in docker step * fixup!: comment get and set version * fixup!: remove compress release package comment * fixup!: use $VERSION in npm-version * refactor: set VERSION in build VS Code step * refactor: use 0.0.0 in package.json version * refactor: delete release-prep script * Update ci/build/build-vscode.sh * fixup!: remove extra VERSION set in aur
1 parent 5a8bb2b commit b978655

File tree

10 files changed

+151
-178
lines changed

10 files changed

+151
-178
lines changed

.github/workflows/build.yaml

+9-5
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,6 @@ jobs:
187187
id: vscode-rev
188188
run: echo "::set-output name=rev::$(git rev-parse HEAD:./lib/vscode)"
189189

190-
- name: Get version
191-
id: version
192-
run: echo "::set-output name=version::$(jq -r .version package.json)"
193-
194190
# We need to rebuild when we have a new version of Code, when any of
195191
# the patches changed, or when the code-server version changes (since
196192
# it gets embedded into the code). Use VSCODE_CACHE_VERSION to
@@ -200,9 +196,11 @@ jobs:
200196
uses: actions/cache@v3
201197
with:
202198
path: lib/vscode-reh-web-*
203-
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ steps.version.outputs.version }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
199+
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
204200

205201
- name: Build vscode
202+
env:
203+
VERSION: "0.0.0"
206204
if: steps.cache-vscode.outputs.cache-hit != 'true'
207205
run: yarn build:vscode
208206

@@ -261,6 +259,12 @@ jobs:
261259
- name: Run ./ci/steps/publish-npm.sh
262260
run: yarn publish:npm
263261
env:
262+
# NOTE@jsjoeio
263+
# This is because npm enforces semantic versioning
264+
# so it has to be a valid version. We only use this
265+
# to publish dev versions from prs
266+
# and beta versions from main.
267+
VERSION: "0.0.0"
264268
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
265269
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
266270
# NOTE@jsjoeio

.github/workflows/publish.yaml

+40-17
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ on:
44
# Shows the manual trigger in GitHub UI
55
# helpful as a back-up in case the GitHub Actions Workflow fails
66
workflow_dispatch:
7+
inputs:
8+
version:
9+
description: The version to publish (include "v", i.e. "v4.9.1").
10+
type: string
11+
required: true
712

813
release:
914
types: [released]
@@ -24,21 +29,25 @@ jobs:
2429
- name: Checkout code-server
2530
uses: actions/checkout@v3
2631

27-
- name: Get version
28-
id: version
29-
run: echo "::set-output name=version::$(jq -r .version package.json)"
30-
3132
- name: Download npm package from release artifacts
3233
uses: robinraju/[email protected]
3334
with:
3435
repository: "coder/code-server"
35-
tag: v${{ steps.version.outputs.version }}
36+
tag: ${{ github.event.inputs.version || github.ref_name }}
3637
fileName: "package.tar.gz"
3738
out-file-path: "release-npm-package"
3839

40+
# NOTE@jsjoeio - we do this so we can strip out the v
41+
# i.e. v4.9.1 -> 4.9.1
42+
- name: Get and set VERSION
43+
run: |
44+
TAG="${{ github.event.inputs.version || github.ref_name }}"
45+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
46+
3947
- name: Publish npm package and tag with "latest"
4048
run: yarn publish:npm
4149
env:
50+
VERSION: ${{ env.VERSION }}
4251
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4352
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
4453
NPM_ENVIRONMENT: "production"
@@ -62,9 +71,18 @@ jobs:
6271
git config --global user.name cdrci
6372
git config --global user.email [email protected]
6473
74+
# NOTE@jsjoeio - we do this so we can strip out the v
75+
# i.e. v4.9.1 -> 4.9.1
76+
- name: Get and set VERSION
77+
run: |
78+
TAG="${{ github.event.inputs.version || github.ref_name }}"
79+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
80+
6581
- name: Bump code-server homebrew version
6682
env:
83+
VERSION: ${{ env.VERSION }}
6784
HOMEBREW_GITHUB_API_TOKEN: ${{secrets.HOMEBREW_GITHUB_API_TOKEN}}
85+
6886
run: ./ci/steps/brew-bump.sh
6987

7088
aur:
@@ -73,6 +91,7 @@ jobs:
7391
timeout-minutes: 10
7492
env:
7593
GH_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
94+
7695
steps:
7796
# We need to checkout code-server so we can get the version
7897
- name: Checkout code-server
@@ -81,13 +100,6 @@ jobs:
81100
fetch-depth: 0
82101
path: "./code-server"
83102

84-
- name: Get code-server version
85-
id: version
86-
run: |
87-
pushd code-server
88-
echo "::set-output name=version::$(jq -r .version package.json)"
89-
popd
90-
91103
- name: Checkout code-server-aur repo
92104
uses: actions/checkout@v3
93105
with:
@@ -106,10 +118,17 @@ jobs:
106118
git config --global user.name cdrci
107119
git config --global user.email [email protected]
108120
121+
# NOTE@jsjoeio - we do this so we can strip out the v
122+
# i.e. v4.9.1 -> 4.9.1
123+
- name: Get and set VERSION
124+
run: |
125+
TAG="${{ github.event.inputs.version || github.ref_name }}"
126+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
127+
109128
- name: Validate package
110129
uses: hapakaien/archlinux-package-action@v2
111130
with:
112-
pkgver: ${{ steps.version.outputs.version }}
131+
pkgver: ${{ env.VERSION }}
113132
updpkgsums: true
114133
srcinfo: true
115134

@@ -147,19 +166,23 @@ jobs:
147166
username: ${{ github.actor }}
148167
password: ${{ secrets.GITHUB_TOKEN }}
149168

150-
- name: Get version
151-
id: version
152-
run: echo "::set-output name=version::$(jq -r .version package.json)"
169+
# NOTE@jsjoeio - we do this so we can strip out the v
170+
# i.e. v4.9.1 -> 4.9.1
171+
- name: Get and set VERSION
172+
run: |
173+
TAG="${{ github.event.inputs.version || github.ref_name }}"
174+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
153175
154176
- name: Download release artifacts
155177
uses: robinraju/[email protected]
156178
with:
157179
repository: "coder/code-server"
158-
tag: v${{ steps.version.outputs.version }}
180+
tag: v${{ env.VERSION }}
159181
fileName: "*.deb"
160182
out-file-path: "release-packages"
161183

162184
- name: Publish to Docker
163185
run: yarn publish:docker
164186
env:
187+
VERSION: ${{ env.VERSION }}
165188
GITHUB_TOKEN: ${{ github.token }}

.github/workflows/release.yaml

+89-28
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ name: Draft release
22

33
on:
44
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: The version to publish (include "v", i.e. "v4.9.1").
8+
type: string
9+
required: true
510

611
permissions:
712
contents: write # For creating releases.
@@ -21,6 +26,7 @@ jobs:
2126
name: x86-64 Linux build
2227
runs-on: ubuntu-latest
2328
timeout-minutes: 15
29+
needs: npm-version
2430
container: "centos:7"
2531
env:
2632
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
@@ -51,15 +57,10 @@ jobs:
5157
- name: Install yarn
5258
run: npm install -g yarn
5359

54-
- name: Download artifacts
55-
uses: dawidd6/action-download-artifact@v2
56-
id: download
60+
- name: Download npm package
61+
uses: actions/download-artifact@v3
5762
with:
58-
branch: ${{ github.ref }}
59-
workflow: build.yaml
60-
workflow_conclusion: completed
61-
check_artifacts: true
62-
name: npm-package
63+
name: npm-release-package
6364

6465
- name: Decompress npm package
6566
run: tar -xzf package.tar.gz
@@ -91,7 +92,16 @@ jobs:
9192
token: ${{ secrets.CODECOV_TOKEN }}
9293
if: success()
9394

95+
# NOTE@jsjoeio - we do this so we can strip out the v
96+
# i.e. v4.9.1 -> 4.9.1
97+
- name: Get and set VERSION
98+
run: |
99+
TAG="${{ inputs.version || github.ref_name }}"
100+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
101+
94102
- name: Build packages with nfpm
103+
env:
104+
VERSION: ${{ env.VERSION }}
95105
run: yarn package
96106

97107
- uses: softprops/action-gh-release@v1
@@ -123,6 +133,7 @@ jobs:
123133
name: Linux cross-compile builds
124134
runs-on: ubuntu-18.04
125135
timeout-minutes: 15
136+
needs: npm-version
126137
strategy:
127138
matrix:
128139
include:
@@ -159,15 +170,10 @@ jobs:
159170
env:
160171
PACKAGE: ${{ format('g++-{0}', matrix.prefix) }}
161172

162-
- name: Download artifacts
163-
uses: dawidd6/action-download-artifact@v2
164-
id: download
173+
- name: Download npm package
174+
uses: actions/download-artifact@v3
165175
with:
166-
branch: ${{ github.ref }}
167-
workflow: build.yaml
168-
workflow_conclusion: completed
169-
check_artifacts: true
170-
name: npm-package
176+
name: npm-release-package
171177

172178
- name: Decompress npm package
173179
run: tar -xzf package.tar.gz
@@ -181,7 +187,16 @@ jobs:
181187
tar -xf node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}.tar.xz node-${NODE_VERSION}-linux-${NPM_CONFIG_ARCH}/bin/node --strip-components=2
182188
mv ./node ./release-standalone/lib/node
183189
190+
# NOTE@jsjoeio - we do this so we can strip out the v
191+
# i.e. v4.9.1 -> 4.9.1
192+
- name: Get and set VERSION
193+
run: |
194+
TAG="${{ inputs.version || github.ref_name }}"
195+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
196+
184197
- name: Build packages with nfpm
198+
env:
199+
VERSION: ${{ env.VERSION }}
185200
run: yarn package ${NPM_CONFIG_ARCH}
186201

187202
- uses: softprops/action-gh-release@v1
@@ -194,6 +209,7 @@ jobs:
194209
name: x86-64 macOS build
195210
runs-on: macos-latest
196211
timeout-minutes: 15
212+
needs: npm-version
197213
steps:
198214
- name: Checkout repo
199215
uses: actions/checkout@v3
@@ -209,15 +225,10 @@ jobs:
209225
curl -sSfL https://github.com/goreleaser/nfpm/releases/download/v2.3.1/nfpm_2.3.1_`uname -s`_`uname -m`.tar.gz | tar -C ~/.local/bin -zxv nfpm
210226
echo "$HOME/.local/bin" >> $GITHUB_PATH
211227
212-
- name: Download artifacts
213-
uses: dawidd6/action-download-artifact@v2
214-
id: download
228+
- name: Download npm package
229+
uses: actions/download-artifact@v3
215230
with:
216-
branch: ${{ github.ref }}
217-
workflow: build.yaml
218-
workflow_conclusion: completed
219-
check_artifacts: true
220-
name: npm-package
231+
name: npm-release-package
221232

222233
- name: Decompress npm package
223234
run: tar -xzf package.tar.gz
@@ -241,7 +252,16 @@ jobs:
241252
- name: Run native module tests on standalone release
242253
run: yarn test:native
243254

255+
# NOTE@jsjoeio - we do this so we can strip out the v
256+
# i.e. v4.9.1 -> 4.9.1
257+
- name: Get and set VERSION
258+
run: |
259+
TAG="${{ inputs.version || github.ref_name }}"
260+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
261+
244262
- name: Build packages with nfpm
263+
env:
264+
VERSION: ${{ env.VERSION }}
245265
run: yarn package
246266

247267
- uses: softprops/action-gh-release@v1
@@ -254,6 +274,23 @@ jobs:
254274
name: Upload npm package
255275
runs-on: ubuntu-latest
256276
timeout-minutes: 15
277+
needs: npm-version
278+
steps:
279+
- name: Download npm package
280+
uses: actions/download-artifact@v3
281+
with:
282+
name: npm-release-package
283+
284+
- uses: softprops/action-gh-release@v1
285+
with:
286+
draft: true
287+
discussion_category_name: "📣 Announcements"
288+
files: ./package.tar.gz
289+
290+
npm-version:
291+
name: Modify package.json version
292+
runs-on: ubuntu-latest
293+
timeout-minutes: 15
257294
steps:
258295
- name: Download artifacts
259296
uses: dawidd6/action-download-artifact@v2
@@ -265,8 +302,32 @@ jobs:
265302
check_artifacts: true
266303
name: npm-package
267304

268-
- uses: softprops/action-gh-release@v1
305+
- name: Decompress npm package
306+
run: tar -xzf package.tar.gz
307+
308+
# NOTE@jsjoeio - we do this so we can strip out the v
309+
# i.e. v4.9.1 -> 4.9.1
310+
- name: Get and set VERSION
311+
run: |
312+
TAG="${{ inputs.version || github.ref_name }}"
313+
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
314+
315+
- name: Modify version
316+
env:
317+
VERSION: ${{ env.VERSION )}}
318+
run: |
319+
echo "Updating version in root package.json"
320+
npm version --prefix release "$VERSION"
321+
322+
echo "Updating version in lib/vscode/product.json"
323+
tmp=$(mktemp)
324+
jq '.codeServerVersion = "$VERSION"' release/lib/vscode/product.json > "$tmp" && mv "$tmp" release/lib/vscode/product.json
325+
326+
- name: Compress release package
327+
run: tar -czf package.tar.gz release
328+
329+
- name: Upload npm package artifact
330+
uses: actions/upload-artifact@v3
269331
with:
270-
draft: true
271-
discussion_category_name: "📣 Announcements"
272-
files: ./package.tar.gz
332+
name: npm-release-package
333+
path: ./package.tar.gz

ci/build/nfpm.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ platform: "linux"
44
version: "v${VERSION}"
55
section: "devel"
66
priority: "optional"
7-
maintainer: "Anmol Sethi <[email protected]>"
7+
maintainer: "Joe Previte <[email protected]>"
88
description: |
99
Run VS Code in the browser.
1010
vendor: "Coder"

0 commit comments

Comments
 (0)