Repository navigation
fix(release): fail the publish job instead of swallowing npm errors - #2925
Conversation
scripts/publish.ts caught every `npm publish` failure as "may already exist" and still exited 0, so an auth or registry failure would release nothing and stay green. It also ran `changeset tag` unconditionally: on every push to main without a release, CI tried to republish all 22 packages, `changeset tag` printed "New tag:" for each, changesets/action read that as a release, and `gh release create v11.0.0` failed with HTTP 422 (publish runs of 2026-09-02 for #2906 and #2907). Now each package is checked with `npm view name@version` first: an exact match is skipped, E404 is published, any other lookup error or publish failure stops the run with exit 1. Tags are only created when something was published. The entry point is guarded by `import.meta.main` so the script can be imported by its test without publishing.
|
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
publishAll takes the packages directory and the command runner, so the tests can check without a registry: no tags when everything is already on npm, only missing packages published with workspace deps resolved, and a failed publish stopping the run with its package.json restored.
There was a problem hiding this comment.
All reported issues were addressed across 2 files (changes from recent commits).
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2925 +/- ##
===========================================
- Coverage 99.64% 98.63% -1.01%
===========================================
Files 69 70 +1
Lines 1961 2056 +95
Branches 599 624 +25
===========================================
+ Hits 1954 2028 +74
- Misses 7 28 +21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
scripts/publish.tsswallowed everynpm publisherror as "may already exist" and always ranchangeset tag. Two consequences:mainthat is not a release goes red. The Publish runs for fix(ci): build all workspace deps before bundling the action #2906 and chore: run the action on node24, refresh v12 backlog #2907 (2026-09-02) both failed at 📦 Create Aggregated GitHub Release withHTTP 422: Validation Failed.Why the 422: with nothing to publish,
changeset tagstill printsNew tag:for all 22 packages. changesets/action v1 reads those lines as a release and setspublished=true, so the workflow runsgh release create v11.0.0for a release that already exists.The entry point is now behind
import.meta.main, soisPublishedcan be imported by a test without running a publish.Evidence
Before (run for chore: run the action on node24, refresh v12 backlog #2907): 22×
npm error You cannot publish over the previously published versions: 11.0.0.→Failed to publish … (may already exist), then 22×New tag:, thenHTTP 422: Validation Failed.After: run locally against the real registry, with a fake
npmthat refusespublish.Already on npm: @node-minify/…@11.0.0, thenNothing to publish, no tags created., exit 0, no new tags.benchmark@99.0.0-shimtest):Publishing …, thenPublish failed: Command failed: npm publish …, exit 1,package.jsonrestored, no tags.scripts/__tests__/publish.test.ts(newscriptsvitest project):Full suite: 71 files, 1051 tests pass. Biome,
lint:rootand the type-suppression guard are clean.Registry check: all 22 public packages on
mainare on npm at 11.0.0, so no past run silently skipped a package.Merge Danger
Door: two-way. It only changes the release script and adds a test project; revert restores the old behaviour.
Blast Radius: release job.
main. If nothing is pending, that run should now be green and create no release.changeset tagfails after a successful publish, a re-run finds everything published and skips tagging. Runchangeset tagby hand in that case.Summary by cubic
Fixes the release script so
npm publisherrors fail the publish job instead of being logged as "may already exist", which previously let an auth or registry failure release nothing while the job stayed green.scripts/publish.tschecks each package withnpm view <name>@<version>first: an exact match is skipped, E404 proceeds to publish, and any other lookup or publish failure exits 1.changeset tagruns only when at least one package was published, so a no-op push no longer triggers a failing GitHub Release step (the 422 fromgh release createon already-released versions).publishAlltakes the packages directory and a command runner, and the entry point is behindimport.meta.main, so the newscriptsvitest project tests the loop without a registry. Tests cover the already-published, mixed, and failed-publish paths and restore each rewrittenpackage.json.Written for commit a12c4fd. Summary will update on new commits.