fix(ci): use Node 24 for publish workflow + add workflow_dispatch#239
Conversation
…grade The 5.7.3 publish run failed at the "Ensure npm >= 11.5.1" step because `npm install -g npm@latest` crashes with `Cannot find module 'promise-retry'` on Node 22.22.2 — a known regression in npm self-upgrade on hosted runners. Switch the publish job to Node 24, which already ships with npm 11.x, so the explicit upgrade step is no longer needed. Replace it with a guard that fails fast if the bundled npm ever falls below 11.5.1 (required for npm Trusted Publishing). Also add a workflow_dispatch trigger with a tag input so the publish can be retriggered for an existing release tag without recreating the GitHub release. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
| Filename | Overview |
|---|---|
| .github/workflows/publish.yml | Upgrades Node to 24, replaces broken npm self-upgrade with a version guard, and adds workflow_dispatch — but the version guard reads process.argv[1] instead of process.argv[2], making it a no-op. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A([release: published]) --> D
B([workflow_dispatch\ntag input]) --> C{Checkout}
C -- tag input --> E[git ref = inputs.tag]
C -- release event --> F[git ref = github.ref]
E --> G[Setup Node 24]
F --> G
D([ci job]) --> G
G --> H[Verify npm >= 11.5.1\n⚠️ guard is no-op]
H --> I[Build all packages\nyarn install + all:prepare]
I --> J{Verify versions\nmatch TAG}
J -- mismatch --> K([exit 1])
J -- match --> L[Publish 5 packages\nwith --provenance]
Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
.github/workflows/publish.yml:48-53
**Wrong `process.argv` index — version guard is a no-op**
When Node.js runs `node -e "script" "$NPM_VERSION"`, `process.argv[1]` is set to an empty string (not the argument); the npm version string lands at `process.argv[2]`. As a result `process.argv[1].split('.')` always produces `['']`, `Number('')` is `NaN`, and every comparison (`NaN < 11`, `NaN === 11`) evaluates to `false` — so the guard never fires regardless of the actual npm version.
```suggestion
node -e "
const [maj, min, patch] = process.argv[2].split('.').map(Number);
if (maj < 11 || (maj === 11 && (min < 5 || (min === 5 && patch < 1)))) {
console.error('npm ' + process.argv[2] + ' is below required 11.5.1');
process.exit(1);
}
" "$NPM_VERSION"
```
Reviews (1): Last reviewed commit: "fix(ci): use Node 24 for publish workflo..." | Re-trigger Greptile
Replace the inline node -e version check with a sort -V comparison. The previous version worked on Node 22+ (process.argv[1] is the first user arg when using `-e` since there's no script-file entry), but the indexing differs from script-file invocation and was easy to misread. The bash sort -V approach is unambiguous and platform-agnostic. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Greptile finding addressed in Technical note on the original report: the claim that That said, the inline if [ "$(printf '%s\n%s\n' "11.5.1" "$NPM_VERSION" | sort -V | head -n1)" != "11.5.1" ]; then
echo "::error::npm $NPM_VERSION is below required 11.5.1"
exit 1
fiValidated locally against |
Summary
npm install -g npm@latestcrashed withCannot find module 'promise-retry'on Node 22.22.2 — a known regression in npm self-upgrade on hosted runners.workflow_dispatchtrigger with ataginput so the publish can be retriggered for an existing release tag (e.g. 5.7.3) without recreating the GitHub release.Test plan
maingh workflow run publish.yml --ref main -f tag=5.7.3🤖 Generated with Claude Code