Skip to content

Commit fc37eeb

Browse files
committed
✨ feat: add release workflow for automated GitHub releases
1 parent 0579171 commit fc37eeb

1 file changed

Lines changed: 77 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v6
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v6
21+
with:
22+
node-version: "lts/*"
23+
cache: "npm"
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Run tests
29+
uses: coactions/setup-xvfb@v1
30+
with:
31+
run: npm test
32+
33+
- name: Package extension
34+
run: |
35+
npx @vscode/vsce package
36+
37+
- name: Get version from tag
38+
id: get_version
39+
run: |
40+
VERSION=${GITHUB_REF#refs/tags/v}
41+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
42+
echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
43+
44+
- name: Extract changelog for version
45+
id: changelog
46+
run: |
47+
VERSION=${GITHUB_REF#refs/tags/v}
48+
# Extract changelog section for this version
49+
sed -n "/## \[$VERSION\]/,/## \[/p" CHANGELOG.md | sed '$d' > release_notes.md
50+
if [ ! -s release_notes.md ]; then
51+
echo "No changelog found for version $VERSION"
52+
echo "# Release $VERSION" > release_notes.md
53+
echo "See CHANGELOG.md for details." >> release_notes.md
54+
fi
55+
56+
- name: Create GitHub Release
57+
uses: ncipollo/release-action@v1
58+
with:
59+
artifacts: "*.vsix"
60+
bodyFile: "release_notes.md"
61+
draft: false
62+
prerelease: false
63+
name: "Release ${{ steps.get_version.outputs.TAG }}"
64+
tag: ${{ steps.get_version.outputs.TAG }}
65+
token: ${{ secrets.GITHUB_TOKEN }}
66+
67+
# Publishing to marketplaces requires secrets to be configured
68+
# VSCE_PAT and OVSX_PAT need to be added as repository secrets
69+
# Uncomment and configure these steps when ready to publish
70+
71+
# - name: Publish to VS Code Marketplace
72+
# run: npx @vscode/vsce publish --pat ${{ secrets.VSCE_PAT }}
73+
# if: secrets.VSCE_PAT != null
74+
75+
# - name: Publish to Open VSX Registry
76+
# run: npx ovsx publish *.vsix --pat ${{ secrets.OVSX_PAT }}
77+
# if: secrets.OVSX_PAT != null

0 commit comments

Comments
 (0)