npmsemantic-release

How to force a version in semantic release


I have a npm package that I need to release in npmjs.com but because I unpublished a previously wrong version now npmjs doesn't allow me to re-publish an artefact with the same version (it throws an error saying You cannot publish over the previously published versions)

In my project I use semantic-release which automatically calculates the version to give to an artefact based on the commits from the last published version.

Therefore I am wondering if there is a way to overwrite or force semantic-release to give a different version than the one it calculates, for example typing it in when running its command in CI


Solution

  • semantic-release uses tags to determine the last version and the new commits added since then. In order to skip the version that was unpublished from npm you can add a Git tag that correspond to that version on the commit associated with the latest version published.

    git tag v<latest-version-published> v<version-to-skip> git push --tags origin

    Then re-run your CI job that failed so semantic-release can run again, pick up the new tag and increment the version from there.