release-it: ERROR fatal: tag already exists

We’ve setup release-it to run as a git pre-push hook, which works great.

If I try to push and don’t have the latest changes from the origin, I’ll get an error:

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

That’s fine and expected. However, release-it at this point has already created a new release version, so after I pull and try to push again, it runs release-it, which fails because the version tag already exists:

> release-it

� Let's release boss (8.0.59...8.0.60)
Changelog:
* release: v8.0.61 (2e6d2580)
* use support email for invitations (3a9bab47)
* release: v8.0.60 (3ca70003)
* comments (0cf15039)
* enable release-it pre-push (0cff2498)
✔ echo module.exports = {version: "'"8.0.60"'"} > $(git rev-parse --show-toplevel)/VERSI
ON
Changeset:
M VERSION
✔ Git commit
✖ Git tag
ERROR fatal: tag 'v8.0.60' already exists

Is there an option that will tell release-it to just increment to the next version if it finds a conflicting tag? My understanding was that part of the release-it process was to evaluate existing tags, then create a new version based on the last one found.

The current workaround is to git tag -d v8.0.60 and push again.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 30

Most upvoted comments

Hi @lucbas,

I have the following sequence in Gitlab:

- git pull origin $CI_BUILD_REF_NAME
- echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
- DEBUG=release-it:* npm run release:${RELEASE_TYPE}

The before:init hook is handled by release-it so it’s safe to say release-it executes it after the git pull. I’ve ran a few test releases and no issues so far 🎸