Skip to content

fix: autoincrement unpublished npm version on release publish - #76

Merged
amaldona merged 1 commit into
mainfrom
cursor/autoincrement-npm-publish-version-8173
Aug 21, 2026
Merged

amaldona merged 1 commit into
mainfrom
cursor/autoincrement-npm-publish-version-8173

Conversation

@alejouribesanchez

Copy link
Copy Markdown
Collaborator

Problem

Publishing a GitHub release fails when package.json still has a version that is already on npm:

npm error You cannot publish over the previously published versions: 1.4.8

That happened on the v1.5.0 release: the tag was 1.5.0, but package.json was still 1.4.8.

Change

The release workflow now chooses an unpublished version before npm publish:

  1. Prefer the GitHub release tag (v1.5.0 → 1.5.0) when it is valid semver.
  2. Otherwise use package.json.
  3. If that version is already on the registry, increment the patch until it is free.
  4. Apply the version once in the build job and share it with both npm and Nexus publish jobs.

package.json is also bumped to 1.5.0 so it matches the intended release.

How to publish next time

  • Create a GitHub release tagged with the version you want (v1.5.0, v1.6.0, …).
  • You no longer need to remember to bump package.json first.
  • Use a new major/minor in the tag when you want more than a patch bump.
  • Re-running a release whose version is already on npm publishes the next patch (for example 1.5.0 → 1.5.1).

Tests

Unit tests cover tag vs package.json vs already-published versions. Live registry check: v1.5.0 resolves to 1.5.0 because npm latest is still 1.4.8.

Open in Web Open in Cursor 

GitHub releases were publishing package.json as-is, so a v1.5.0
release failed by retrying already-published 1.4.8. CI now uses the
release tag and bumps patch until the version is free on npm.

Co-authored-by: alejandro <alejandro@veryfi.com>
@alejouribesanchez
alejouribesanchez marked this pull request as ready for review August 21, 2026 19:05
@amaldona
amaldona merged commit 2da0ee3 into main Aug 21, 2026
2 checks passed
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