From fdbb6ff9b2d4562fb298b4c43797af1e277a560c Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 4 Aug 2025 14:50:42 +0800 Subject: [PATCH] chore: enable npm trusted publishing --- .github/workflows/release.yml | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 31e4999..11ad07c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ # This action will publish the package to npm and create a GitHub release. +# Ref: https://docs.npmjs.com/trusted-publishers/ name: Release on: @@ -16,18 +17,24 @@ permissions: jobs: publish: runs-on: ubuntu-latest + environment: npm steps: - name: Checkout uses: actions/checkout@v4 - - name: Install Pnpm - run: npm i -g corepack@latest --force && corepack enable - - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 22 - cache: "pnpm" + + # Update npm to the latest version to enable OIDC + # Use corepack to install pnpm + - name: Setup Package Managers + run: | + npm install -g npm@latest + npm --version + npm install -g corepack@latest --force + corepack enable - name: Install Dependencies run: pnpm install @@ -35,8 +42,7 @@ jobs: - name: Publish uses: JS-DevTools/npm-publish@v3 with: - token: ${{ secrets.NPM_TOKEN }} - provenance: true + token: empty - name: Create GitHub Release uses: ncipollo/release-action@v1