Skip to content

Commit c60e376

Browse files
committed
fix: update npm release workflow for provenance
- Add registry-url to setup-node to correctly configure authentication via .npmrc. - Append --provenance and --access public to the publish command for secure OIDC delivery.
1 parent 50c460f commit c60e376

1 file changed

Lines changed: 10 additions & 18 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,19 @@
1-
name: Release
2-
3-
on:
4-
push:
5-
branches:
6-
- main # Trigger on every push to main
7-
8-
permissions:
9-
contents: read
10-
id-token: write # Required for provenance / (optional) NPM Trusted Publishing
11-
121
jobs:
132
publish:
143
runs-on: ubuntu-latest
4+
permissions:
5+
contents: read
6+
id-token: write # OIDC 必须权限
7+
158
steps:
169
- uses: actions/checkout@v4
1710

1811
- name: Setup Node.js
1912
uses: actions/setup-node@v4
2013
with:
2114
node-version: '20'
15+
# 👇 关键修正 1:添加这行,让 Action 自动配置 .npmrc 认证
16+
registry-url: 'https://registry.npmjs.org'
2217

2318
- name: Install dependencies
2419
run: yarn install
@@ -27,12 +22,9 @@ jobs:
2722
run: yarn build
2823

2924
- name: Publish to NPM
30-
# It will only publish if the version in package.json is new.
31-
# Publish auth:
32-
# - Recommended: set repo secret NPM_TOKEN (an npm "Automation" token with publish access).
33-
# - Optional: if you've configured NPM Trusted Publishing for this package, it can publish without NPM_TOKEN.
3425
env:
26+
# 这一步会读取 Setup Node.js 生成的 .npmrc 配置
3527
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36-
run: |
37-
npm publish
38-
28+
# 👇 关键修正 2:添加 --provenance 参数
29+
# 同时添加 --access public 确保包是公开的(OIDC 目前主要支持公开包)
30+
run: npm publish --provenance --access public

0 commit comments

Comments
 (0)