|
1 | 1 | # This workflow will run tests using node and then publish a package to the npm registry when a release is created |
2 | 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages |
| 3 | +# |
| 4 | +# Publishing uses npm Trusted Publishing (OIDC) — no NPM_TOKEN secret is |
| 5 | +# required. Each package must have a trusted publisher configured on npmjs.com |
| 6 | +# pointing at this workflow file. See: |
| 7 | +# https://docs.npmjs.com/trusted-publishers |
3 | 8 |
|
4 | 9 | name: Node.js Package |
5 | 10 |
|
|
9 | 14 | jobs: |
10 | 15 | publish-npm: |
11 | 16 | runs-on: ubuntu-latest |
| 17 | + permissions: |
| 18 | + contents: write # for `git push --follow-tags` of the version bump |
| 19 | + id-token: write # for npm OIDC trusted publishing |
12 | 20 | steps: |
13 | 21 | - uses: actions/setup-node@v6 |
14 | 22 | with: |
| 23 | + # OIDC trusted publishing needs npm >= 11.5.1, which requires |
| 24 | + # Node >= 20.17.0. setup-node's `20` resolves to the latest |
| 25 | + # 20.x, which satisfies that. |
15 | 26 | node-version: 20 |
16 | 27 | registry-url: https://registry.npmjs.org/ |
| 28 | + - name: Upgrade npm to >=11.5.1 (required for trusted publishing) |
| 29 | + run: npm install -g npm@latest |
17 | 30 | - name: Check out Etherpad core |
18 | 31 | uses: actions/checkout@v6 |
19 | 32 | with: |
@@ -63,12 +76,10 @@ jobs: |
63 | 76 | # already-used version number. By running `npm publish` after `git push`, |
64 | 77 | # back-to-back merges will cause the first merge's workflow to fail but |
65 | 78 | # the second's will succeed. |
66 | | - - |
67 | | - run: pnpm publish |
68 | | - env: |
69 | | - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
70 | | - #- |
71 | | - # name: Add package to etherpad organization |
72 | | - # run: pnpm access grant read-write etherpad:developers |
73 | | - # env: |
74 | | - # NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 79 | + # |
| 80 | + # Use `npm publish` directly (not `pnpm publish`) because OIDC trusted |
| 81 | + # publishing requires npm CLI >= 11.5.1 and `pnpm publish` shells out to |
| 82 | + # whichever `npm` is on PATH; calling `npm` directly avoids any shim |
| 83 | + # ambiguity. |
| 84 | + - name: Publish to npm via OIDC |
| 85 | + run: npm publish --provenance --access public |
0 commit comments