2

I receive an error from sematic-release triggered by CI on test branch

Command failed with exit code 128: git tag vX.XX.XX <commit id>
fatal: tag 'vX.XX.XX' already exists

The issue started when I pushed invalid code that wasn't released, so to rollback changes I did git reset --hard <to-id-with-last valid version>.

* commitB my invalid changes 
| 
* commitA - refactor: last publish working version # => v4.2.0 
|
* commit0 - older code 
|

after reset git reset --hard commitA

* commitA - refactor: last publish working # now failed
|
* commit0 - older code # => v4.1.0 
|

code looks good, but semantic-release failed with error:

Command failed with exit code 128: git tag v4.2.0  commitA
fatal: tag 'v4.2.0 ' already exists

I found troubleshooting in docs, that suits the situation - reference already exists error when pushing tag:

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. (...) 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.

Version v4.2.0 was published but now it's not. When I pushed newer code it also fails with the same error.

* commitC - chore: newer changes # failed
|
* commitA - refactor: # failed
|
* commit0 - older code # => v4.1.0 
|
Command failed with exit code 128: git tag v4.2.0 commitC
fatal: tag 'v4.2.0' already exists

All issue could be fixed if I would be able to release this code with the next version v4.3.0 or 4.2.1 and skip invalid release.

eudaimonia
  • 1,406
  • 1
  • 15
  • 28

1 Answers1

1

I had the same issue after a failing build. Within the Azure build pipeline, I got the error Command failed with exit code 128: git tag 'v1.0.0-beta.39' already exists in the semantic-release task.

My solution was:

  • Pull develop (affected branch) and create new feature branch from it
  • delete tag local: git tag -d v1.0.0-beta.39
  • delete tag remote: git push origin :refs/tags/v1.0.0-beta.39
  • Change package.json & package-lock.json to previous version: "version": "1.0.0-beta.38"
  • Pull Request from new branch into develop
Astrophage
  • 1,231
  • 1
  • 12
  • 38