ci: remove npm cache from release job by ku5ic · Pull Request #21 · ku5ic/foxhole · GitHub
Skip to content

ci: remove npm cache from release job - #21

Merged
ku5ic merged 1 commit into
mainfrom
fix/release-npm-cache
Jul 17, 2026
Merged

ku5ic merged 1 commit into
mainfrom
fix/release-npm-cache

Conversation

@ku5ic

@ku5ic ku5ic commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

  • The Release job's actions/setup-node npm cache was serving stale registry reads to changesets' publish-idempotency check.
  • Because the cache key is derived from the lockfile hash, a push that doesn't touch dependencies (e.g. commit aa9088e, a bare CI-actions bump) reuses the exact cache saved by the prior release. That cache reflected the registry state from just before the version was published, so changeset publish read a stale "not yet published" result and retried the publish, which npm then rejected as a duplicate (You cannot publish over the previously published versions: 1.0.5).
  • Removing cache: npm from this job's setup-node step eliminates the staleness at the source. Cost: this job installs 484 packages in ~6s uncached, negligible for a job that runs a handful of times a day.

Investigation

  • Compared the two Release runs on 2026-07-17: the 15:09 run showed npm cache is not found (fresh registry reads, published 1.0.5 successfully, then saved the cache). The 18:09 run on aa9088e showed Cache hit for: node-cache-Linux-x64-npm-3e33f580... (same key, since aa9088e didn't touch the lockfile) and failed with the duplicate-publish error.
  • Ruled out an npm-CLI-version theory: npm@latest resolved to 12.0.1 in both runs (12.0.1 was published on npm a week prior, so no version drift occurred between the two runs that same day).

Test plan

  • Merge and observe the next plain push to main (no changeset) succeeds without re-publishing.
  • Confirm a real Version Packages release (with a changeset) still publishes correctly once made.

The Release job's actions/setup-node cache was serving stale registry
reads to changesets' publish-idempotency check. When a push doesn't
touch the lockfile, the cache key is reused across runs, so a cached
"version not yet published" response can survive past the point the
version actually gets published, causing changeset publish to retry
and npm to reject it as a duplicate. The job installs 484 packages in
~6s uncached, so the cache bought negligible speed for real correctness
risk.
@ku5ic
ku5ic merged commit 24d0ff8 into main Jul 17, 2026
2 checks passed
@ku5ic
ku5ic deleted the fix/release-npm-cache branch July 17, 2026 18:38
ku5ic added a commit that referenced this pull request Jul 17, 2026
…24)

## Summary
- Root cause of today's recurring Release failures ("You cannot publish
over the previously published versions: 1.0.5"): npm 12 (installed by
the Release job's OIDC npm-upgrade step) changed `npm info --json` to
wrap its output in an array. `@changesets/cli@2.31.0`'s
`getPackageInfo()` reads `pkgInfo.versions` off the unwrapped result, so
under npm 12 it's always `undefined`, and `changeset publish` concludes
every already-published package is unpublished, then re-attempts
publishing it. npm correctly rejects the duplicate, and Release goes
red.
- This is a genuine upstream defect, not a misuse on our side: confirmed
via `changesets/changesets#2164` (closed), matching our exact symptom
and environment (npm 12.0.1, `@changesets/cli@2.31.0`, GitHub Actions).
Fixed by `changesets/changesets#2159`, released in
`@changesets/cli@2.31.1`.
- Bumped the lockfile to `2.31.1` (already permitted by the existing
`^2.31.0` range in package.json, no manifest change needed). Verified
the array-unwrap fix (`Array.isArray(parsed) ? parsed[0] : parsed`) is
present in the installed source.

## Why this wasn't caught by the earlier fixes today
- #21 (removing the release job's npm cache) and #22 (the audit-fix PR)
both happened to pass Release, but for unrelated reasons: #22's run took
`changesets/action`'s "open a Version Packages PR" path (since it
carried a pending changeset) rather than the "attempt to publish" path
that triggers this bug. The defect was still live underneath.

## Verification
- `run-checks.sh`: 4 passed, 0 failed, 0 skipped (typecheck, lint,
format, test).

## Sequencing
This should merge **before** #23 (the pending Version Packages PR), so
the eventual patch-release publish run uses the fixed `@changesets/cli`,
and so ordinary future pushes to main don't hit this bug again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant