Skip to content

fix(release): auto-sync the npm 'next' dist-tag to the highest published version#357

Open
latekvo wants to merge 2 commits into
mainfrom
fix/next-dist-tag-auto
Open

fix(release): auto-sync the npm 'next' dist-tag to the highest published version#357
latekvo wants to merge 2 commits into
mainfrom
fix/next-dist-tag-auto

Conversation

@latekvo

@latekvo latekvo commented Jun 17, 2026

Copy link
Copy Markdown
Member

Problem

The next dist-tag drifts. Right now:

npm dist-tag ls @swmansion/argent
latest: 0.11.0
next:   0.7.0-next.4   # 8 releases stale

A stable npm publish only moves latest, and npm publish --tag next moves next only when a prerelease ships. So once 0.7.0-next.4 was tagged next, every later stable release (0.7.0 → 0.11.0) left next frozen — hence the recurring "we set next once then forget" problem.

Fix

scripts/sync-next-dist-tag.mjs re-points next at the highest published version overall (prerelease or stable, per SemVer precedence). It is:

  • Automatic — runs as a final step in both publish.yml and publish-next.yml, so next self-heals on every publish.
  • Manual — exposed via a new Sync 'next' dist-tag workflow (workflow_dispatch, with a dry_run toggle) to repair the tag without republishing. Running it now would move next 0.7.0-next.4 → 0.11.0.
  • Idempotent — no-op when next already points at the max.
  • Dependency-free at runtime — no npm ci needed in the lightweight manual job.

Verification

  • Live dry-run against the real registry resolves next0.11.0 (the current max) as expected.
  • scripts/sync-next-dist-tag.test.mjs proves the hand-rolled SemVer comparator matches the semver library across every pair of the real version history plus prerelease edge cases. Wired into the unit-tests CI (npm run test:scripts); semver added as a devDep (test oracle only).
  • npm run lint, npm run typecheck:scripts, and prettier --check all pass.

Note (out of scope)

A stable npm publish of a backport (e.g. 0.8.2 while 0.11.0 is out) would still wrongly move latest — that's a separate, pre-existing npm behavior and not addressed here. The next sync handles backports correctly (it never regresses below the max).

…hed version

A stable `npm publish` only moves `latest`, and `npm publish --tag next`
moves `next` only when a prerelease ships. So once a prerelease was tagged
`next`, every later stable release left `next` frozen on an old prerelease
(currently next=0.7.0-next.4 while latest=0.11.0).

Add scripts/sync-next-dist-tag.mjs, which re-points `next` at the highest
published version (prerelease or stable). It runs after both publish
workflows and is exposed as a manual sync-next-tag workflow to repair the
tag without republishing. Idempotent and self-healing.

The script is dependency-free at runtime; a node:test proves its SemVer
comparator matches the `semver` library and runs in the unit-tests CI.
@latekvo latekvo marked this pull request as ready for review June 18, 2026 11:30
@latekvo latekvo requested a review from filip131311 June 19, 2026 11:42
# Conflicts:
#	package-lock.json
#	package.json

@filip131311 filip131311 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm view argent versions is broken here

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.

3 participants