npm-publish #377
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: npm-publish | |
| on: | |
| workflow_dispatch: | |
| # release: | |
| # types: [published] | |
| permissions: | |
| id-token: write # 需要给 GitHub Action 添加 id-token 权限,否则无法生成 OIDC 令牌 | |
| packages: write | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| npm-publish: | |
| name: npm-publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v5 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 # npm CLI 的版本需要在 11.5.1 版本或以上才支持 OIDC | |
| registry-url: https://registry.npmjs.org | |
| - name: Publish | |
| run: | | |
| npm publish | |
| # 不再需要配置 NPM TOKEN | |
| # env: | |
| # NODE_AUTH_TOKEN: ${{ secrets.npm_token }} |