Skip to content

Commit fd6b5b3

Browse files
committed
ci: adopt multi-version testing and LTS publishing strategy
1 parent 59df3ff commit fd6b5b3

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,32 @@
11
name: Publish to GitHub Packages
22

33
on:
4-
# 允许手动触发 (方便测试)
54
workflow_dispatch:
6-
# 每次推送到 main 分支时自动触发 (确保构建正常, 可选)
75
push:
86
branches:
97
- "main"
108
tags:
119
- "v*"
1210

1311
jobs:
14-
build-and-publish:
12+
test:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
node-version: [20, 22, 24, 25]
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Setup Node.js ${{ matrix.node-version }}
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: ${{ matrix.node-version }}
23+
cache: "npm"
24+
- run: npm ci
25+
- run: npm run build
26+
- run: npm test
27+
28+
publish:
29+
needs: test
1530
runs-on: ubuntu-latest
1631
permissions:
1732
contents: read
@@ -21,10 +36,10 @@ jobs:
2136
- name: Checkout code
2237
uses: actions/checkout@v4
2338

24-
- name: Setup Node.js
39+
- name: Setup Node.js 24 (LTS)
2540
uses: actions/setup-node@v4
2641
with:
27-
node-version: "18"
42+
node-version: "24"
2843
registry-url: "https://npm.pkg.github.com"
2944
scope: "@PancrePal-xiaoyibao"
3045

@@ -34,9 +49,8 @@ jobs:
3449
- name: Build project
3550
run: npm run build
3651

37-
# 只有当 tag 触发,或者手动触发且 confirm 时才发布
3852
- name: Publish to GitHub Packages
3953
if: startsWith(github.ref, 'refs/tags/v')
4054
run: npm publish
4155
env:
42-
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)