From 4b024827239e20174e15a366f31e1fa48055b642 Mon Sep 17 00:00:00 2001 From: myw Date: Thu, 11 Jun 2026 00:43:29 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=20npm=20publish=20?= =?UTF-8?q?=E5=B7=A5=E4=BD=9C=E6=B5=81=E7=A8=8B=EF=BC=8C=E5=8D=87=E7=B4=9A?= =?UTF-8?q?=20actions=20=E7=89=88=E6=9C=AC=E4=B8=A6=E4=BD=BF=E7=94=A8=20--?= =?UTF-8?q?provenance=20=E9=80=B2=E8=A1=8C=E7=99=BC=E5=B8=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index eee034d..9c4d17c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -3,17 +3,25 @@ name: npm publish on: release: types: [created] + jobs: build: runs-on: ubuntu-latest + + # 這是 Trusted Publishing 必須的權限 + permissions: + contents: read + id-token: write + steps: - - uses: actions/checkout@v2 - # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v1 + - uses: actions/checkout@v4 # 建議升級至較新版本的 checkout + + - uses: actions/setup-node@v4 # 建議升級至較新版本的 setup-node with: - node-version: '12.x' + node-version: '20.x' # 建議換成你目前使用的 Node LTS 版本 registry-url: 'https://registry.npmjs.org' + - run: npm install - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file + + # 使用 --provenance 進行發布,OIDC 自動完成驗證,不再需要 env.NODE_AUTH_TOKEN + - run: npm publish --provenance \ No newline at end of file