File tree Expand file tree Collapse file tree 1 file changed +21
-7
lines changed
Expand file tree Collapse file tree 1 file changed +21
-7
lines changed Original file line number Diff line number Diff line change 11name : Publish to GitHub Packages
22
33on :
4- # 允许手动触发 (方便测试)
54 workflow_dispatch :
6- # 每次推送到 main 分支时自动触发 (确保构建正常, 可选)
75 push :
86 branches :
97 - " main"
108 tags :
119 - " v*"
1210
1311jobs :
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
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 }}
You can’t perform that action at this time.
0 commit comments