-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (125 loc) · 4.58 KB
/
Copy pathci.yml
File metadata and controls
132 lines (125 loc) · 4.58 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: CI
on:
push:
branches: [master, feature/1.x.x]
tags:
- 'v*'
pull_request:
permissions:
contents: read
jobs:
# 闸门:类型检查 + lint + 生产构建(快门,ubuntu 单格)
lint-build:
name: Lint & Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm run check-types
- run: pnpm run lint
- run: pnpm run package
# 集成测试矩阵:main/tag 跑三平台,PR 仅 ubuntu 快门
test:
name: Test (${{ matrix.os }})
needs: lint-build
strategy:
fail-fast: false
matrix:
os: ${{ (github.event_name == 'pull_request') && fromJson('["ubuntu-latest"]') || fromJson('["ubuntu-latest", "macos-latest", "windows-latest"]') }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- name: 构建 dist/extension.js(集成测试需加载扩展)
run: node esbuild.js
- run: pnpm run test:unit
- name: 集成测试(Linux 需 xvfb 包装 Electron)
run: xvfb-run -a pnpm run test:integration
if: runner.os == 'Linux'
- name: 集成测试
run: pnpm run test:integration
if: runner.os != 'Linux'
# 打包 vsix(Linux 保 POSIX 文件属性)
package:
name: Package vsix
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
# rc tag 以 --pre-release 打包:VS Code 要求「预发布 VSIX」在打包时即标记,
# 否则 publish job 的 `vsce publish --pre-release` 会报「未以 pre-release 打包」而失败。
# 与 publish 步骤同款 PRE_FLAG 判定,保证同一枚 VSIX 贯穿 GitHub Release 与 Marketplace。
- name: 打包 vsix(rc tag 自动带 --pre-release)
run: |
PRE_FLAG=$([[ "${GITHUB_REF_NAME}" == *rc* ]] && echo "--pre-release" || echo "")
pnpm dlx @vscode/vsce package --no-yarn $PRE_FLAG
- uses: actions/upload-artifact@v7
with:
name: vsix
path: '*.vsix'
if-no-files-found: error
# GitHub Release:仅 tag 触发,将 .vsix 作为可本地安装资产附带(与市场 publish 解耦)
github-release:
name: GitHub Release (.vsix)
needs: package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
# 检出仓库:使 body_path 指向的 Release Note 文件可见
- uses: actions/checkout@v7
- uses: actions/download-artifact@v8
with:
name: vsix
- name: 创建/更新 GitHub Release 并附带 .vsix
uses: softprops/action-gh-release@v3
with:
files: '*.vsix'
prerelease: ${{ contains(github.ref_name, 'rc') }}
# Release 正文取自版本控制的 Release Note(单一事实源,按 tag 名取对应文件)
body_path: docs/releases/${{ github.ref_name }}.md
fail_on_unmatched_files: true
# 发布:仅 tag 触发;发布到 VS Code Marketplace,由 ENABLE_MARKETPLACE_PUBLISH 变量门控;生产环境审批门
publish:
name: Publish
needs: package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v7
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- uses: actions/download-artifact@v8
with:
name: vsix
# VS Code Marketplace 发布:由仓库变量 ENABLE_MARKETPLACE_PUBLISH 门控(=true 时发布)。
# 需配置 VSCE_PAT(Azure DevOps PAT,scope: Marketplace → Manage);rc tag 自动以 --pre-release 发预发布通道。
- name: 发布到 VS Code Marketplace
if: ${{ vars.ENABLE_MARKETPLACE_PUBLISH == 'true' }}
run: |
PRE_FLAG=$([[ "${GITHUB_REF_NAME}" == *rc* ]] && echo "--pre-release" || echo "")
pnpm dlx @vscode/vsce publish --packagePath *.vsix $PRE_FLAG
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}