-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (52 loc) · 1.8 KB
/
release.yml
File metadata and controls
64 lines (52 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# 推送形如 v0.2.0 的 tag 时:校验版本、打 VSIX、创建 GitHub Release、发布到 VS Code 市场。
# 仓库 Settings → Secrets → Actions 中配置 VSCE_PAT(Azure DevOps PAT,勾选 Marketplace > Manage)。
# 发版前请先把 package.json 的 version 改成与 tag 一致(tag 去掉前缀 v)。
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: "20"
cache: yarn
- name: Install
run: yarn install --frozen-lockfile
- name: Compile
run: yarn compile
- name: Lint
run: yarn lint
- name: Match package.json version to tag
run: |
TAG="${GITHUB_REF#refs/tags/v}"
VER=$(node -p "require('./package.json').version")
if [ "$VER" != "$TAG" ]; then
echo "::error::package.json version ($VER) must equal git tag without v prefix ($TAG)"
exit 1
fi
- name: Package VSIX
run: yarn vsix
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: "*.vsix"
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to VS Code Marketplace
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
run: |
if [ -z "$VSCE_PAT" ]; then
echo "::error::Missing secret VSCE_PAT. Create a PAT at https://dev.azure.com (Marketplace > Manage) and add it under Repo Settings → Secrets → Actions."
exit 1
fi
VSIX=$(ls -1 ./*.vsix | head -1)
npx vsce publish --pat "$VSCE_PAT" --packagePath "$VSIX"