Skip to content

Commit eb72808

Browse files
ci: add release workflow for VS Code Marketplace and Open VSX
- semantic-release for automated versioning from conventional commits - publishes to Marketplace and Open VSX only on new releases - requires VSCE_PAT, OVSX_PAT and GH_TOKEN secrets
1 parent 89d0b08 commit eb72808

3 files changed

Lines changed: 131 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
issues: write
14+
pull-requests: write
15+
id-token: write
16+
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
token: ${{ secrets.GH_TOKEN }}
23+
24+
- name: Use Node.js
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 20
28+
cache: 'npm'
29+
30+
- name: Install dependencies
31+
run: npm ci
32+
33+
- name: Install vsce
34+
run: npm install -g @vscode/vsce
35+
36+
- name: Install ovsx
37+
run: npm install -g ovsx
38+
39+
- name: Package .VSIX
40+
run: npm run package
41+
42+
- name: Semantic Release
43+
id: semantic-release
44+
run: |
45+
echo "Running semantic-release..."
46+
npx semantic-release > semantic.log
47+
echo "new-release-published=false" >> $GITHUB_OUTPUT
48+
if grep -q "Published release" semantic.log; then
49+
echo "✅ Release published"
50+
echo "new-release-published=true" >> $GITHUB_OUTPUT
51+
else
52+
echo "ℹ️ No new release published"
53+
fi
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
56+
GIT_AUTHOR_NAME: github-actions[bot]
57+
GIT_AUTHOR_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
58+
GIT_COMMITTER_NAME: github-actions[bot]
59+
GIT_COMMITTER_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
60+
61+
- name: Publish to VS Code Marketplace
62+
if: steps.semantic-release.outputs.new-release-published == 'true'
63+
run: npx vsce publish --pat $VSCE_PAT --no-yarn
64+
env:
65+
VSCE_PAT: ${{ secrets.VSCE_PAT }}
66+
67+
- name: Publish to Open VSX Registry
68+
if: steps.semantic-release.outputs.new-release-published == 'true'
69+
run: npx ovsx publish --pat $OVSX_PAT
70+
env:
71+
OVSX_PAT: ${{ secrets.OVSX_PAT }}

.releaserc.json

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
[
6+
"@semantic-release/release-notes-generator",
7+
{
8+
"preset": "conventionalcommits",
9+
"presetConfig": {
10+
"types": [
11+
{ "type": "feat", "section": "Features" },
12+
{ "type": "fix", "section": "Bug Fixes" },
13+
{ "type": "perf", "section": "Performance Improvements" }
14+
]
15+
}
16+
}
17+
],
18+
[
19+
"@semantic-release/changelog",
20+
{
21+
"changelogFile": "CHANGELOG.md",
22+
"changelogTitle": "# Changelog\n\nAll notable changes to this project will be documented in this file."
23+
}
24+
],
25+
[
26+
"@semantic-release/npm",
27+
{
28+
"npmPublish": false
29+
}
30+
],
31+
[
32+
"@semantic-release/git",
33+
{
34+
"assets": ["CHANGELOG.md", "package.json"],
35+
"message": "chore(release): ${nextRelease.version} [skip ci]"
36+
}
37+
],
38+
[
39+
"@semantic-release/github",
40+
{
41+
"assets": [
42+
{
43+
"path": "dist/*.vsix",
44+
"label": "vicecode-${nextRelease.version}.vsix"
45+
}
46+
]
47+
}
48+
]
49+
]
50+
}

package.json

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,19 @@
3535
},
3636
"scripts": {
3737
"lint": "eslint .",
38-
"pretest": "npm run lint",
39-
"test": "vscode-test"
38+
"package": "vsce package --out ./dist/"
4039
},
4140
"devDependencies": {
42-
"@types/mocha": "^10.0.10",
43-
"@types/node": "22.x",
4441
"@types/vscode": "^1.120.0",
45-
"@vscode/test-cli": "^0.0.12",
46-
"@vscode/test-electron": "^2.5.2",
47-
"eslint": "^9.39.3"
42+
"@semantic-release/changelog": "^6.0.3",
43+
"@semantic-release/commit-analyzer": "^13.0.1",
44+
"@semantic-release/git": "^10.0.1",
45+
"@semantic-release/github": "^11.0.1",
46+
"@semantic-release/npm": "^12.0.1",
47+
"@semantic-release/release-notes-generator": "^14.0.3",
48+
"conventional-changelog-conventionalcommits": "^8.0.0",
49+
"eslint": "^9.39.3",
50+
"semantic-release": "^24.2.5"
4851
},
4952
"dependencies": {
5053
"@vscode/codicons": "^0.0.45"

0 commit comments

Comments
 (0)