When running semantic-release you might encounter the following error:
npm ERR! publish Failed PUT 403npm ERR! code E403npm ERR! You do not have permission to publish "<package-name>". Are you logged in as the correct user? : <package-name>
It might also happen if the package name you are trying to publish already exists (in such case npm consider you are trying to publish a new version of a package that is not yours, hence the permission error).
To verify if your package name is available you can use npm-name-cli:
$ npm install --global npm-name-cli$ npm-name <package-name>
If the package name is not available, change it in your
package.json or consider using an npm scope.
semantic-release parses commits according to a commit message convention to figure out how they affect the codebase. Commits that doesn't follow the project's commit message convention are simply ignored.
When squashing commits most Git tools will by default generate a new commit message with a summary of the squashed commits. This commit message will most likely not be compliant with the project's commit message convention and therefore will be ignored by semantic-release.
When squashing commits make sure to rewrite the resulting commit message to be compliant with the project's commit message convention.
Note: if the resulting squashed commit would encompasses multiple changes (for example multiple unrelated features or fixes) then it's probably not a good idea to squash those commits together. A commit should contain exactly one self-contained functional change and a functional change should be contained in exactly one commit. See atomic commits.
semantic-release read Git tags that are present in the history of your release branch in order to determine the last release published. Then it determines the next version to release based on the commits pushed since then and create the corresponding tag. If a tag with the name already in your repository, Git will throw and error as tags must be unique across the repository. This situation happens when you have a version tag identical to the new one semantic-release is trying to create that is not in the history of the current branch.
If an actual release with that version number was published you need to merge all the commits up to that release into your release branch.
If there is no published release with that version number, the tag must be deleted.
# Verify if the commit exists in the repository$ git rev-list -1 <tag name># If a commit sha is returned, then the tag exists# Verify the branches having the tagged commit in their history$ git branch --contains <tag name># Delete the tag$ git tag -d <tag name>$ git push origin :refs/tags/<tag name>