-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (119 loc) · 3.8 KB
/
Copy pathci.yml
File metadata and controls
126 lines (119 loc) · 3.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
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
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: pnpm/action-setup@v6
- uses: actions/checkout@v7
- 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: pnpm/action-setup@v6
- uses: actions/checkout@v7
- 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: pnpm/action-setup@v6
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm dlx @vscode/vsce package --no-yarn
- 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:
- 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') }}
generate_release_notes: true
fail_on_unmatched_files: true
# 发布:仅 tag 触发,双市场(Marketplace + OpenVSX),生产环境审批门
publish:
name: Publish
needs: package
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
environment: production
steps:
- uses: pnpm/action-setup@v6
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: 22
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- uses: actions/download-artifact@v8
with:
name: vsix
- name: 发布到 VS Code Marketplace
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 }}
- name: 发布到 OpenVSX(覆盖 Cursor / Windsurf 等 AI IDE)
run: |
PRE_FLAG=$([[ "${GITHUB_REF_NAME}" == *rc* ]] && echo "--pre-release" || echo "")
pnpm dlx ovsx publish *.vsix $PRE_FLAG
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}