File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,22 +46,26 @@ jobs:
4646 fi
4747
4848 # Omit registry-url: setup-node otherwise sets NODE_AUTH_TOKEN to a placeholder and npm publish uses that instead of OIDC.
49+ # Node 24 ships npm 11.x (≥11.5.1 in current LTS line). Node 22’s npm is 10.x; Corepack `prepare npm@11` does not replace
50+ # the toolcache `npm` binary on GitHub-hosted runners, so `npm publish` stayed on 10.x and OIDC trusted publishing never ran.
4951 - name : Setup Node
5052 if : steps.gate.outputs.publish == 'true'
5153 uses : actions/setup-node@v6
5254 with :
53- node-version : 22
55+ node-version : 24
5456 cache : npm
5557
56- # Corepack avoids `npm install -g npm` when the bundled global npm is broken (e.g. missing promise-retry).
57- - name : Upgrade npm for trusted publishing (OIDC)
58+ - name : Assert npm supports trusted publishing (OIDC)
5859 if : steps.gate.outputs.publish == 'true'
59- env :
60- COREPACK_ENABLE_DOWNLOAD_PROMPT : 0
6160 run : |
62- corepack enable
63- corepack prepare npm@11.5.1 --activate
64- npm --version
61+ set -euo pipefail
62+ ver="$(npm --version)"
63+ echo "npm ${ver}"
64+ node -e "
65+ const v = process.argv[1].split('.').map(Number);
66+ const ok = v[0] > 11 || (v[0] === 11 && (v[1] > 5 || (v[1] === 5 && (v[2] || 0) >= 1)));
67+ if (!ok) { console.error('npm ' + process.argv[1] + ' < 11.5.1; trusted publishing OIDC requires npm >= 11.5.1'); process.exit(1); }
68+ " "$ver"
6569
6670 - name : Ensure versions match
6771 if : steps.gate.outputs.publish == 'true'
You can’t perform that action at this time.
0 commit comments