Skip to content

Commit 20357c5

Browse files
committed
ci: separate build and publish workflows
- Split build.yml into reusable build workflow and new publish.yml for publishing - Pin GitHub Actions to specific commit SHAs for security - Add workflow dispatch option to publish to either open-vsx or vsix archive Contributed on behalf of STMicroelectronics
1 parent 29d9cb8 commit 20357c5

File tree

3 files changed

+96
-18
lines changed

3 files changed

+96
-18
lines changed

.github/workflows/build.yml

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: Build and Publish VS Code Extensions
1+
name: Build VS Code Extensions
22
on:
3-
workflow_dispatch:
3+
workflow_call:
44
push:
55
branches:
66
- master
@@ -10,13 +10,12 @@ on:
1010
env:
1111
NODE_OPTIONS: --max-old-space-size=8192
1212
jobs:
13-
linux:
13+
build:
1414
runs-on: ubuntu-latest
1515
env:
1616
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17-
OVSX_PAT: ${{ secrets.OVSX_PAT}}
1817
steps:
19-
- uses: actions/checkout@v1
18+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
2019
- run: |
2120
git submodule init
2221
git submodule update
@@ -30,20 +29,18 @@ jobs:
3029
sudo update-rc.d xvfb defaults
3130
sudo service xvfb start
3231
name: Setup Build Environment
33-
- uses: actions/setup-node@v4
32+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
3433
with:
3534
node-version-file: vscode/.nvmrc
36-
- name: Check ovsx version
37-
run: npx ovsx --version
3835
- name: Bundle Extensions
3936
run: |
4037
npm i
4138
npm run build:extensions
4239
- name: Package Solid Version of Extensions
4340
run: npm run package-vsix
44-
- name: Create built-in extensions pack
45-
run: npm run create-extension-pack
46-
# Only publish the extensions if the workflow was manually triggered
47-
- if: ${{ github.event_name == 'workflow_dispatch' }}
48-
name: Publish Extensions to open-vsx.org
49-
run: npm run publish:vsix
41+
- name: Upload dist artifacts
42+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
43+
with:
44+
name: dist
45+
path: dist/
46+
retention-days: 7

.github/workflows/publish.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Publish VS Code Extensions
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
publish_target:
6+
description: 'Publish target'
7+
required: true
8+
type: choice
9+
options:
10+
- open-vsx
11+
- archive
12+
env:
13+
NODE_OPTIONS: --max-old-space-size=8192
14+
jobs:
15+
build:
16+
uses: ./.github/workflows/build.yml
17+
secrets: inherit
18+
19+
publish-openvsx:
20+
if: ${{ github.event.inputs.publish_target == 'open-vsx' }}
21+
needs: build
22+
runs-on: ubuntu-latest
23+
env:
24+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
OVSX_PAT: ${{ secrets.OVSX_PAT }}
26+
steps:
27+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
28+
- run: |
29+
git submodule init
30+
git submodule update
31+
name: Checkout VS Code
32+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
33+
with:
34+
node-version-file: vscode/.nvmrc
35+
- name: Install dependencies
36+
run: npm i
37+
- name: Download dist artifacts
38+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
39+
with:
40+
name: dist
41+
path: dist/
42+
- name: Check ovsx version
43+
run: npx ovsx --version
44+
- name: Create built-in extensions pack
45+
run: npm run create-extension-pack
46+
- name: Publish Extensions to open-vsx.org
47+
run: npm run publish:vsix
48+
49+
publish-archive:
50+
if: ${{ github.event.inputs.publish_target == 'archive' }}
51+
needs: build
52+
runs-on: ubuntu-latest
53+
env:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
steps:
56+
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
57+
- run: |
58+
git submodule init
59+
git submodule update
60+
name: Checkout VS Code
61+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
62+
with:
63+
node-version-file: vscode/.nvmrc
64+
- name: Install dependencies
65+
run: npm i
66+
- name: Download dist artifacts
67+
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
68+
with:
69+
name: dist
70+
path: dist/
71+
- name: Get external builtins
72+
run: npm run get-external-builtins
73+
- name: Compress VSIX files
74+
run: npm run compress-vsix
75+
- name: Upload archive artifact
76+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
77+
with:
78+
name: vscode-builtin-extensions-archive
79+
path: vscode-builtin-extensions-*.tar.gz
80+
retention-days: 7

doc/Publishing.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,9 @@ Building and packaging the built-ins is described in [Building.md](./Building.md
6060

6161
As an alternative to publishing on open-vsx.org, you can compress all packaged `.vsix` files into a single `tar.gz` archive for self-hosting (e.g., on GitHub Releases).
6262

63-
You can create the archive locally:
63+
To create an archive using GitHub Actions, use the `Publish VS Code Extensions` workflow and select `archive` as the publish target. This will build and package all extensions (including external builtins), and create a `vscode-builtin-extensions-<version>.tar.gz` archive that can be downloaded from the workflow artifacts.
64+
65+
Alternatively, you can create the archive locally:
6466

6567
npm run package-vsix
6668
npm run get-external-builtins
@@ -117,7 +119,6 @@ check out the correct version of VS Code upon `git submodule update`. The conven
117119
118120
Publishing is done using GitHub Actions. In the vscode-builtin-extensions repo, a publish token for open-vsx.org has been set, that can be used to publish under the identity of the openvsx publish bot.
119121

120-
Building and optionally publishing the extensions is done through the `Build and Publish VS Code Extensions` workflow.
121-
On any pull request and push to the `master` branch, the workflow will build and package all VS Code extensions to ensure that the build scripts still work as expected.
122+
On any pull request and push to the `master` branch, the `Build VS Code Extensions` workflow will build and package all VS Code extensions to ensure that the build scripts still work as expected.
122123

123-
Triggering the workflow through the GitHub UI using the `workflow_dispatch` trigger will additionally publish the built extensions to open-vsx.
124+
To publish, use the `Publish VS Code Extensions` workflow and select `open-vsx` as the publish target. This will build the extensions, create the extension pack, and publish everything to open-vsx.org.

0 commit comments

Comments
 (0)