Skip to content

Commit 11c0b15

Browse files
committed
add release workflow
1 parent ccd507c commit 11c0b15

3 files changed

Lines changed: 143 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Release Extension
2+
3+
on:
4+
push:
5+
branches: [release]
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: write
10+
11+
jobs:
12+
release:
13+
name: Build and Publish Extension
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: "20"
26+
27+
- name: Install just
28+
uses: extractions/setup-just@v2
29+
30+
- name: Install dependencies
31+
run: just deps
32+
33+
- name: Get version
34+
id: version
35+
run: |
36+
VERSION=$(node -p "require('./package.json').version")
37+
echo "version=v$VERSION" >> $GITHUB_OUTPUT
38+
echo "version_number=$VERSION" >> $GITHUB_OUTPUT
39+
echo "📦 Version: v$VERSION"
40+
41+
- name: Check if release exists
42+
id: check
43+
run: |
44+
if gh release view "v$(node -p "require('./package.json').version")" &>/dev/null; then
45+
echo "exists=true" >> $GITHUB_OUTPUT
46+
echo "⚠️ Release already exists, skipping"
47+
else
48+
echo "exists=false" >> $GITHUB_OUTPUT
49+
fi
50+
env:
51+
GH_TOKEN: ${{ github.token }}
52+
53+
- name: Build extension
54+
if: steps.check.outputs.exists == 'false'
55+
run: just package
56+
57+
- name: Generate changelog
58+
id: changelog
59+
if: steps.check.outputs.exists == 'false'
60+
run: |
61+
CURRENT="v$(node -p "require('./package.json').version")"
62+
PREVIOUS=$(git tag --sort=-v:refname | grep -v "$CURRENT" | head -1 || echo "")
63+
64+
if [ -z "$PREVIOUS" ]; then
65+
echo "changelog=Initial release of quick command buttons extension" >> $GITHUB_OUTPUT
66+
else
67+
CHANGELOG=$(git log $PREVIOUS..HEAD --pretty=format:"- %s" --no-merges)
68+
echo "changelog<<EOF" >> $GITHUB_OUTPUT
69+
echo "$CHANGELOG" >> $GITHUB_OUTPUT
70+
echo "EOF" >> $GITHUB_OUTPUT
71+
fi
72+
73+
- name: Create GitHub Release
74+
if: steps.check.outputs.exists == 'false'
75+
uses: softprops/action-gh-release@v1
76+
with:
77+
tag_name: ${{ steps.version.outputs.version }}
78+
name: ${{ steps.version.outputs.version }}
79+
body: |
80+
## 🎉 What's New in ${{ steps.version.outputs.version }}
81+
82+
${{ steps.changelog.outputs.changelog }}
83+
files: |
84+
quick-command-buttons-${{ steps.version.outputs.version_number }}.vsix
85+
generate_release_notes: true
86+
env:
87+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88+
89+
- name: Publish to marketplaces
90+
if: steps.check.outputs.exists == 'false'
91+
run: just publish both
92+
env:
93+
VSCE_ACCESS_TOKEN: ${{ secrets.VSCE_PAT }}
94+
OVSX_ACCESS_TOKEN: ${{ secrets.OVSX_PAT }}
95+
96+
- name: Update release with success status
97+
if: success() && steps.check.outputs.exists == 'false'
98+
run: |
99+
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
100+
gh release view "${{ steps.version.outputs.version }}" --json body -q .body > body.txt
101+
echo "" >> body.txt
102+
echo "---" >> body.txt
103+
echo "" >> body.txt
104+
echo "✅ **Successfully published to both marketplaces!**" >> body.txt
105+
echo "" >> body.txt
106+
echo "- VSCode Marketplace: https://marketplace.visualstudio.com/items?itemName=KubrickCode.quick-command-buttons" >> body.txt
107+
echo "- Open VSX Registry: https://open-vsx.org/extension/KubrickCode/quick-command-buttons" >> body.txt
108+
echo "" >> body.txt
109+
echo "🕐 Published at: $TIMESTAMP" >> body.txt
110+
gh release edit "${{ steps.version.outputs.version }}" --notes-file body.txt
111+
env:
112+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
114+
- name: Update release on failure
115+
if: failure() && steps.check.outputs.exists == 'false'
116+
run: |
117+
gh release view "${{ steps.version.outputs.version }}" --json body -q .body > body.txt
118+
echo "" >> body.txt
119+
echo "---" >> body.txt
120+
echo "" >> body.txt
121+
echo "❌ **Marketplace publishing failed!**" >> body.txt
122+
echo "" >> body.txt
123+
echo "Please check the GitHub Actions logs for details." >> body.txt
124+
gh release edit "${{ steps.version.outputs.version }}" --notes-file body.txt
125+
env:
126+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,13 @@
7979
"shortcut": "c",
8080
"command": "export IS_SANDBOX=1 && claude --dangerously-skip-permissions",
8181
"useVsCodeApi": false
82+
},
83+
{
84+
"name": "Release",
85+
"color": "Orange",
86+
"command": "just release",
87+
"useVsCodeApi": false,
88+
"terminalName": "Release"
8289
}
8390
],
8491
"quickCommandButtons.refreshButton": {

justfile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@ publish target="both":
5858
fi
5959
fi
6060

61+
release version="patch":
62+
@echo "🚀 Creating {{version}} release..."
63+
npm version {{version}}
64+
git push origin main --tags
65+
git checkout release
66+
git merge main
67+
git push origin release
68+
git checkout main
69+
@echo "✅ Release complete! Check GitHub Actions."
70+
6171
run-view:
6272
cd "{{ web_view_dir }}" && yarn dev
6373

0 commit comments

Comments
 (0)