Skip to content

Commit ff9cf35

Browse files
committed
ci: add GitHub Actions workflow for auto-release
- Trigger on tag push (v*) - Build and package VSIX - Create GitHub Release with VSIX artifact - Support beta/alpha prereleases
1 parent 34a0538 commit ff9cf35

1 file changed

Lines changed: 70 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Release VS Code Extension
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # 匹配 v0.1.56, v1.0.0 等格式的 tag
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
permissions:
13+
contents: write # 需要写权限来创建 Release
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
cache: 'npm'
24+
25+
- name: Install dependencies
26+
run: npm ci
27+
28+
- name: Install vsce
29+
run: npm install -g @vscode/vsce
30+
31+
- name: Compile TypeScript
32+
run: npm run compile
33+
34+
- name: Package extension
35+
run: vsce package --allow-missing-repository
36+
37+
- name: Get package info
38+
id: package
39+
run: |
40+
VSIX_FILE=$(ls *.vsix)
41+
echo "vsix_file=$VSIX_FILE" >> $GITHUB_OUTPUT
42+
VERSION=$(echo ${{ github.ref_name }} | sed 's/^v//')
43+
echo "version=$VERSION" >> $GITHUB_OUTPUT
44+
45+
- name: Create Release
46+
uses: softprops/action-gh-release@v1
47+
with:
48+
name: Release ${{ github.ref_name }}
49+
body: |
50+
## VSCode Dotnet Deploy ${{ github.ref_name }}
51+
52+
### 安装方式
53+
1. 下载下方的 `.vsix` 文件
54+
2. 在 VS Code 中打开命令面板 (Ctrl+Shift+P / Cmd+Shift+P)
55+
3. 输入 "Install from VSIX" 并选择下载的文件
56+
57+
### 更新内容
58+
请查看 [CHANGELOG](https://github.com/${{ github.repository }}/blob/main/CHANGELOG.md) 获取详细更新内容。
59+
files: ${{ steps.package.outputs.vsix_file }}
60+
draft: false
61+
prerelease: ${{ contains(github.ref_name, 'beta') || contains(github.ref_name, 'alpha') }}
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
65+
- name: Upload artifact
66+
uses: actions/upload-artifact@v4
67+
with:
68+
name: vsix-package
69+
path: "*.vsix"
70+
retention-days: 30

0 commit comments

Comments
 (0)