Skip to content

Commit 8940fef

Browse files
margropclaude
andcommitted
ci: npm 改用 Trusted Publishing(OIDC)发布,不再需要 NPM_TOKEN
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent d936126 commit 8940fef

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

‎.github/workflows/packages.yml‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ jobs:
6666
if-no-files-found: error
6767

6868
# 发布单独成一个 Job:npm 发布失败不影响安装包上传到 Release
69+
# 使用 npm Trusted Publishing(OIDC),无需 NPM_TOKEN;需在 npmjs.com 包设置中登记本仓库的 packages.yml
6970
npm-publish:
7071
name: Publish to npm
7172
needs: npm
@@ -75,10 +76,10 @@ jobs:
7576
contents: read
7677
id-token: write
7778
steps:
79+
# Trusted Publishing 需要 npm 11.5.1 及以上,Node.js 24 自带
7880
- uses: actions/setup-node@v4
7981
with:
80-
node-version: '22'
81-
registry-url: 'https://registry.npmjs.org'
82+
node-version: '24'
8283

8384
- uses: actions/download-artifact@v4
8485
with:
@@ -87,16 +88,11 @@ jobs:
8788

8889
- name: Publish
8990
shell: bash
90-
env:
91-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
9291
run: |
93-
if [ -z "$NODE_AUTH_TOKEN" ]; then
94-
echo "未配置 NPM_TOKEN,跳过 npm 发布"
95-
exit 0
96-
fi
92+
npm --version
9793
tag=latest
9894
if [[ "$GITHUB_REF_NAME" == *-* ]]; then tag=next; fi
99-
npm publish ./dist/wrong-notebook-*.tgz --access public --provenance --tag "$tag"
95+
npm publish ./dist/wrong-notebook-*.tgz --access public --tag "$tag"
10096
10197
desktop:
10298
name: Desktop (${{ matrix.name }})

‎doc/INSTALL_PACKAGES.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ node scripts/package/build.mjs fnos --arch x86 # 需要 PATH 中有 fnpac
6969

7070
推送 `v*` 标签后,`.github/workflows/packages.yml` 在各平台 Runner 上构建全部安装包并上传到对应的 GitHub Release;也可以在 Actions 页面手动运行,只生成构建产物。
7171

72-
npm 发布需要在仓库 Secrets 中配置 `NPM_TOKEN`,未配置时跳过发布;带 `-` 的预发布标签发布到 npm 的 `next` 标签。
72+
npm 使用 [Trusted Publishing](https://docs.npmjs.com/trusted-publishers)(OIDC)发布,不需要 `NPM_TOKEN`。npmjs.com 上 `wrong-notebook` 包的 Settings → Trusted Publisher 已登记 GitHub Actions:`margrop/wrong-notebook`、工作流 `packages.yml`;重命名该工作流文件时需同步修改登记。带 `-` 的预发布标签发布到 npm 的 `next` 标签。npm 发布在独立的 Job 中,失败不影响安装包上传到 Release。
7373

7474
## 目录结构
7575

0 commit comments

Comments
 (0)