Skip to content

Commit b66b4e1

Browse files
committed
ci: add vscode extension release workflow
1 parent dae0c01 commit b66b4e1

5 files changed

Lines changed: 103 additions & 6 deletions

File tree

‎.github/actions/install-dependencies/action.yml‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ runs:
2323
else
2424
echo "No missing libraries"
2525
fi
26+
- name: Use repository npm version
27+
shell: bash
28+
run: |
29+
npm_version=$(node -p "require('./package.json').devDependencies.npm")
30+
npm install --global "npm@$npm_version"
2631
# When the main workflow calls many workspace workflows, we can reuse this cache for all of them.
2732
# Since this is caching the node_modules directory, DO NOT add partial-match restore keys!
2833
- uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
@@ -31,9 +36,10 @@ runs:
3136
path: |
3237
node_modules
3338
packages/*/node_modules
39+
platforms/*/node_modules
3440
packages/*/src/generated
3541
packages/scratch-gui/static/microbit
36-
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }}
42+
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json', '.github/actions/install-dependencies/action.yml') }}
3743
- if: steps.restore-node-modules-cache.outputs.cache-hit != 'true'
3844
name: Install NPM dependencies
3945
shell: bash
@@ -44,6 +50,7 @@ runs:
4450
path: |
4551
node_modules
4652
packages/*/node_modules
53+
platforms/*/node_modules
4754
packages/*/src/generated
4855
packages/scratch-gui/static/microbit
49-
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json') }}
56+
key: ${{ runner.os }}-npm-${{ hashFiles('.nvmrc', 'package-lock.json', '.github/actions/install-dependencies/action.yml') }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Release VS Code Extension
2+
3+
on:
4+
push:
5+
tags:
6+
- 'vscode-v*'
7+
8+
permissions:
9+
contents: read
10+
11+
concurrency:
12+
group: ${{ github.workflow }}-${{ github.ref }}
13+
cancel-in-progress: false
14+
15+
jobs:
16+
release:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
20+
with:
21+
persist-credentials: false
22+
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
23+
with:
24+
cache: npm
25+
node-version-file: .nvmrc
26+
- name: Check release version
27+
env:
28+
RELEASE_TAG: ${{ github.ref_name }}
29+
run: |
30+
version=$(node -p "require('./platforms/vscode/package.json').version")
31+
if [[ "$RELEASE_TAG" != "vscode-v$version" ]]; then
32+
echo "Expected tag vscode-v$version for platforms/vscode/package.json, got $RELEASE_TAG" >&2
33+
exit 1
34+
fi
35+
- uses: ./.github/actions/install-dependencies
36+
- name: Build packages
37+
run: npm run build
38+
- name: Package VS Code extension
39+
run: npm exec --workspace=platforms/vscode -- vsce package --no-dependencies --out blockflow-vscode.vsix
40+
- name: Upload VSIX
41+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
42+
with:
43+
name: ${{ github.ref_name }}
44+
path: platforms/vscode/blockflow-vscode.vsix
45+
if-no-files-found: error
46+
- name: Publish to VS Code Marketplace
47+
run: npm exec --workspace=platforms/vscode -- vsce publish --packagePath blockflow-vscode.vsix --skip-duplicate
48+
env:
49+
VSCE_PAT: ${{ secrets.VSCE_TOKEN }}
50+
- name: Publish to Open VSX
51+
run: npx --yes ovsx@0.10.6 publish platforms/vscode/blockflow-vscode.vsix --skip-duplicate
52+
env:
53+
OVSX_PAT: ${{ secrets.OVSX_TOKEN }}

‎AGENTS.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ order. The same applies to the root `package.json`.
135135
**Do not publish packages manually.** Every package has a `prepublishOnly` script that will error if you try.
136136
Publishing is handled exclusively by the CI release pipeline.
137137

138+
### VS Code extension releases
139+
140+
`.github/workflows/release-vscode.yml` builds the workspaces and publishes `platforms/vscode` to the
141+
VS Code Marketplace and Open VSX on `vscode-v<version>` tags. The tag must match the extension's
142+
`package.json` version. Publishing uses the `VSCE_TOKEN` and `OVSX_TOKEN` repository secrets.
143+
See `platforms/vscode/README.md` for the release commands.
144+
138145
## Before submitting changes
139146

140147
Review all changes and confirm:

‎platforms/vscode/README.md‎

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ Simply open a `.blockflow` or `.sb3` file in VS Code. The extension will automat
1818

1919
```bash
2020
# Install dependencies (from monorepo root)
21-
npm install
21+
npm ci
22+
23+
# Build all workspaces, including the extension and its worker dependencies
24+
npm run build
2225

2326
# Build the extension
2427
cd platforms/vscode
@@ -30,3 +33,30 @@ npm run watch
3033
# Package the extension as .vsix
3134
npm run package
3235
```
36+
37+
## Releases
38+
39+
The `Release VS Code Extension` workflow publishes to the VS Code Marketplace and Open VSX when a
40+
`vscode-v<version>` tag is pushed. The tag must match the version in `platforms/vscode/package.json`.
41+
The workflow builds all workspaces, packages the bundled extension without npm dependencies, and saves
42+
the `.vsix` as a workflow artifact before publishing the same file to both registries.
43+
44+
Configure these repository secrets for the `openpatch` publisher:
45+
46+
- `VSCE_TOKEN`: VS Code Marketplace personal access token with Marketplace management permission.
47+
- `OVSX_TOKEN`: Open VSX personal access token with access to the `openpatch` namespace.
48+
49+
To release, update the extension version and root lockfile, commit those changes, then push the matching tag.
50+
For example, from the monorepo root:
51+
52+
```bash
53+
npm version 0.1.1 --workspace=platforms/vscode --no-git-tag-version
54+
git add platforms/vscode/package.json package-lock.json
55+
git commit -m "chore(vscode): release 0.1.1"
56+
git tag vscode-v0.1.1
57+
git push origin HEAD
58+
git push origin vscode-v0.1.1
59+
```
60+
61+
If publishing succeeds in one registry but fails in the other, rerun the failed workflow. Both publish
62+
commands skip versions that already exist.

‎platforms/vscode/package.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
"scripts": {
4646
"build": "NODE_ENV=production webpack --mode production",
4747
"build:dev": "webpack --mode development",
48-
"watch": "webpack --mode development --watch",
49-
"package": "npm run build && vsce package",
50-
"clean": "rimraf dist"
48+
"clean": "rimraf dist",
49+
"package": "npm run build && vsce package --no-dependencies",
50+
"watch": "webpack --mode development --watch"
5151
},
5252
"devDependencies": {
5353
"@types/vscode": "^1.80.0",

0 commit comments

Comments
 (0)