Skip to content

Commit e47e031

Browse files
committed
chore: add GitHub Actions workflow for trusted publishing
1 parent dae396e commit e47e031

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

‎.github/workflows/publish.yml‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # 当推送以 v 开头的标签(如 v2.0.0)时触发发布
7+
8+
# 1. 添加 OIDC 令牌所需的权限
9+
permissions:
10+
id-token: write
11+
contents: read
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- uses: actions/setup-node@v4
20+
with:
21+
node-version: '20'
22+
registry-url: 'https://registry.npmjs.org'
23+
24+
# 2. 确保 npm 版本足够新(可信发布需要 v11.5.1 以上)
25+
- name: Update npm
26+
run: npm install -g npm@latest
27+
28+
- run: npm ci
29+
30+
# 3. 直接运行 npm publish,无需任何令牌
31+
- run: npm publish --access public --provenance

0 commit comments

Comments
 (0)