Skip to content

Commit 8ecabd8

Browse files
ci: use the correct npm version for releases (#11423)
Trusted publishing requires the installed npm to be at least 11.5.1. We get this automatically via Node 24.
1 parent a897d20 commit 8ecabd8

File tree

4 files changed

+47
-22
lines changed

4 files changed

+47
-22
lines changed

.github/workflows/changesets.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ jobs:
2727
- name: Install Dependencies
2828
uses: ./.github/actions/install-dependencies
2929
with:
30+
node-version: 24
3031
turbo-api: ${{ secrets.TURBO_API }}
3132
turbo-team: ${{ secrets.TURBO_TEAM }}
3233
turbo-token: ${{ secrets.TURBO_TOKEN }}
3334
turbo-signature: ${{ secrets.TURBO_REMOTE_CACHE_SIGNATURE_KEY }}
3435

36+
- name: Check npm version
37+
run: node -r esbuild-register tools/deployments/check-npm-version.ts
38+
3539
- name: Check the changesets
3640
run: node -r esbuild-register tools/deployments/validate-changesets.ts
3741

pnpm-lock.yaml

Lines changed: 21 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { execSync } from "node:child_process";
2+
import { compare } from "semver";
3+
4+
/**
5+
* For Trusted Publishing to work, we need npm version 11.5.1 or higher.
6+
*/
7+
function checkNpmVersion() {
8+
const npmVersionBuffer = execSync("npm --version");
9+
const npmVersion = npmVersionBuffer.toString().trim();
10+
if (compare(npmVersion, "11.5.1") === -1) {
11+
console.error(
12+
`Error: npm version 11.5.1 or higher is required for Trusted Publishing to work, found version ${npmVersion}`
13+
);
14+
process.exit(1);
15+
}
16+
}
17+
18+
if (require.main === module) {
19+
checkNpmVersion();
20+
}

tools/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
"@cloudflare/eslint-config-shared": "workspace:*",
1515
"@cloudflare/workers-tsconfig": "workspace:*",
1616
"@octokit/webhooks-types": "^7.6.1",
17+
"@types/semver": "^7.5.1",
1718
"@typescript-eslint/eslint-plugin": "catalog:default",
1819
"@typescript-eslint/parser": "catalog:default",
1920
"eslint": "catalog:default",
2021
"find-up": "^6.3.0",
2122
"glob": "^11.0.3",
23+
"semver": "^7.7.1",
2224
"ts-dedent": "^2.2.0",
2325
"undici": "catalog:default",
2426
"wrangler": "workspace:*"

0 commit comments

Comments
 (0)