Skip to content

Commit ac0fd79

Browse files
committed
chore: 更新 GitHub Actions 工作流和文档
- 修改 README 和 README-CN,更新徽章链接 - 新增 env.yml 文件以共享环境变量 - 更新 CI、PR 检查、夜间构建和发布工作流,使用共享环境变量 - 删除旧的 release.yml 文件,整合发布流程至新的 github-release.yml 和 publish-marketplace.yml 文件
1 parent b233321 commit ac0fd79

File tree

9 files changed

+171
-161
lines changed

9 files changed

+171
-161
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,24 @@ jobs:
1414
strategy:
1515
matrix:
1616
os: [ubuntu-latest, windows-latest, macos-latest]
17-
node-version: [18, 20]
1817

1918
steps:
19+
- name: Call env workflow
20+
uses: ./.github/workflows/env.yml
21+
id: env
22+
2023
- name: Checkout
2124
uses: actions/checkout@v4
2225

23-
- name: Setup Node.js ${{ matrix.node-version }}
26+
- name: Setup Node.js ${{ steps.env.outputs.node_version }}
2427
uses: actions/setup-node@v4
2528
with:
26-
node-version: ${{ matrix.node-version }}
29+
node-version: ${{ steps.env.outputs.node_version }}
2730

2831
- name: Setup pnpm
2932
uses: pnpm/action-setup@v4
3033
with:
31-
version: latest
34+
version: ${{ steps.env.outputs.pnpm_version }}
3235

3336
- name: Get pnpm store directory
3437
shell: bash
@@ -64,7 +67,7 @@ jobs:
6467
- name: Upload build artifacts
6568
uses: actions/upload-artifact@v4
6669
with:
67-
name: vscode-syncing-${{ matrix.os }}-${{ matrix.node-version }}
70+
name: vscode-syncing-${{ matrix.os }}-${{ steps.env.outputs.node_version }}
6871
path: |
6972
*.vsix
7073
dist/
@@ -76,18 +79,22 @@ jobs:
7679
if: github.event_name == 'pull_request'
7780

7881
steps:
82+
- name: Call env workflow
83+
uses: ./.github/workflows/env.yml
84+
id: env
85+
7986
- name: Checkout
8087
uses: actions/checkout@v4
8188

8289
- name: Setup Node.js
8390
uses: actions/setup-node@v4
8491
with:
85-
node-version: 20
92+
node-version: ${{ steps.env.outputs.node_version }}
8693

8794
- name: Setup pnpm
8895
uses: pnpm/action-setup@v4
8996
with:
90-
version: latest
97+
version: ${{ steps.env.outputs.pnpm_version }}
9198

9299
- name: Install dependencies
93100
run: pnpm install --frozen-lockfile

.github/workflows/env.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Shared Env Variables
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
node_version:
7+
value: ${{ jobs.set-env.outputs.node_version }}
8+
pnpm_version:
9+
value: ${{ jobs.set-env.outputs.pnpm_version }}
10+
11+
jobs:
12+
set-env:
13+
runs-on: ubuntu-latest
14+
outputs:
15+
node_version: "22.13.0"
16+
pnpm_version: "9.15.0"
17+
steps:
18+
- name: Output env
19+
run: echo "Providing shared env values..."
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: GitHub Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
workflow_dispatch:
8+
inputs:
9+
tag_name:
10+
description: "Tag name to use for the release"
11+
required: false
12+
13+
jobs:
14+
release:
15+
name: GitHub Release
16+
runs-on: ubuntu-latest
17+
18+
outputs:
19+
version: ${{ steps.version.outputs.version }}
20+
21+
steps:
22+
- name: Call env workflow
23+
uses: ./.github/workflows/env.yml
24+
id: env
25+
26+
- name: Checkout
27+
uses: actions/checkout@v4
28+
29+
- name: Setup Node.js
30+
uses: actions/setup-node@v4
31+
with:
32+
node-version: ${{ steps.env.outputs.node_version }}
33+
34+
- name: Setup pnpm
35+
uses: pnpm/action-setup@v4
36+
with:
37+
version: ${{ steps.env.outputs.pnpm_version }}
38+
39+
- name: Install dependencies
40+
run: pnpm install --frozen-lockfile
41+
42+
- name: Compile
43+
run: pnpm run compile
44+
45+
- name: Package extension
46+
run: pnpm run package:vsix
47+
48+
- name: Extract version
49+
id: version
50+
run: |
51+
TAG=${{ github.event.inputs.tag_name }}
52+
if [ -z "$TAG" ]; then
53+
TAG=${GITHUB_REF#refs/tags/}
54+
fi
55+
echo "version=$TAG" >> $GITHUB_OUTPUT
56+
57+
- name: Upload Release
58+
uses: ncipollo/release-action@v1
59+
with:
60+
artifacts: "*.vsix"
61+
token: ${{ secrets.GITHUB_TOKEN }}
62+
tag: ${{ steps.version.outputs.version }}
63+
name: Release ${{ steps.version.outputs.version }}

.github/workflows/nightly.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ jobs:
1212
runs-on: ubuntu-latest
1313

1414
steps:
15+
- name: Call env workflow
16+
uses: ./.github/workflows/env.yml
17+
id: env
18+
1519
- name: Checkout
1620
uses: actions/checkout@v4
1721

1822
- name: Setup Node.js
1923
uses: actions/setup-node@v4
2024
with:
21-
node-version: 20
25+
node-version: ${{ steps.env.outputs.node_version }}
2226

2327
- name: Setup pnpm
2428
uses: pnpm/action-setup@v4
2529
with:
26-
version: latest
30+
version: ${{ steps.env.outputs.pnpm_version }}
2731

2832
- name: Get pnpm store directory
2933
shell: bash
@@ -67,7 +71,7 @@ jobs:
6771
- name: Upload nightly build
6872
uses: actions/upload-artifact@v4
6973
with:
70-
name: vscode-syncing-nightly-${{ github.sha }}
74+
name: vscode-syncing-nightly-${{ steps.env.outputs.node_version }}-${{ github.sha }}
7175
path: |
7276
*.vsix
7377
dist/

.github/workflows/pr-check.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,22 @@ jobs:
1010
runs-on: ubuntu-latest
1111

1212
steps:
13+
- name: Call env workflow
14+
uses: ./.github/workflows/env.yml
15+
id: env
16+
1317
- name: Checkout
1418
uses: actions/checkout@v4
1519

1620
- name: Setup Node.js
1721
uses: actions/setup-node@v4
1822
with:
19-
node-version: 20
23+
node-version: ${{ steps.env.outputs.node_version }}
2024

2125
- name: Setup pnpm
2226
uses: pnpm/action-setup@v4
2327
with:
24-
version: latest
28+
version: ${{ steps.env.outputs.pnpm_version }}
2529

2630
- name: Get pnpm store directory
2731
shell: bash
@@ -78,18 +82,22 @@ jobs:
7882
runs-on: ubuntu-latest
7983

8084
steps:
85+
- name: Call env workflow
86+
uses: ./.github/workflows/env.yml
87+
id: env
88+
8189
- name: Checkout
8290
uses: actions/checkout@v4
8391

8492
- name: Setup Node.js
8593
uses: actions/setup-node@v4
8694
with:
87-
node-version: 20
95+
node-version: ${{ steps.env.outputs.node_version }}
8896

8997
- name: Setup pnpm
9098
uses: pnpm/action-setup@v4
9199
with:
92-
version: latest
100+
version: ${{ steps.env.outputs.pnpm_version }}
93101

94102
- name: Install dependencies
95103
run: pnpm install --frozen-lockfile
@@ -118,18 +126,22 @@ jobs:
118126
os: [ubuntu-latest, windows-latest, macos-latest]
119127

120128
steps:
129+
- name: Call env workflow
130+
uses: ./.github/workflows/env.yml
131+
id: env
132+
121133
- name: Checkout
122134
uses: actions/checkout@v4
123135

124136
- name: Setup Node.js
125137
uses: actions/setup-node@v4
126138
with:
127-
node-version: 20
139+
node-version: ${{ steps.env.outputs.node_version }}
128140

129141
- name: Setup pnpm
130142
uses: pnpm/action-setup@v4
131143
with:
132-
version: latest
144+
version: ${{ steps.env.outputs.pnpm_version }}
133145

134146
- name: Get pnpm store directory
135147
shell: bash
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Publish to Marketplace
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag_name:
7+
description: "Tag name to publish"
8+
required: true
9+
10+
jobs:
11+
publish:
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Call env workflow
16+
uses: ./.github/workflows/env.yml
17+
id: env
18+
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: ${{ steps.env.outputs.node_version }}
26+
27+
- name: Setup pnpm
28+
uses: pnpm/action-setup@v4
29+
with:
30+
version: ${{ steps.env.outputs.pnpm_version }}
31+
32+
- name: Install dependencies
33+
run: pnpm install --frozen-lockfile
34+
35+
- name: Package VSIX
36+
run: pnpm run package:vsix
37+
38+
- name: Publish to VS Code Marketplace
39+
env:
40+
VSCODE_MARKETPLACE_TOKEN: ${{ secrets.VSCODE_MARKETPLACE_TOKEN }}
41+
run: |
42+
VSIX_FILE=$(ls *.vsix | head -n1)
43+
if [ -n "$VSCODE_MARKETPLACE_TOKEN" ]; then
44+
echo "Publishing $VSIX_FILE to VS Code Marketplace..."
45+
npx @vscode/vsce publish --packagePath "$VSIX_FILE" -p "$VSCODE_MARKETPLACE_TOKEN"
46+
else
47+
echo "VSCODE_MARKETPLACE_TOKEN not set, skipping"
48+
fi

0 commit comments

Comments
 (0)