Skip to content

Cutting prerelease versions does not check if a tag already exists #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
AlexPaven opened this issue Feb 5, 2025 · 2 comments
Open
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@AlexPaven
Copy link

Cutting a new prerelease version using the --prerelease parameter with the same value can fail when tagging if the tag already exists; this can happen if two features are in prerelease at the same time and multiple versions of each are interleaved. I believe only the latest tag is checked (or maybe only the package.json version?)

Current behavior
Git tag is not checked prior to creating it

Expected behavior
Git tag existence should probably be checked and the version incremented if it already exists

Environment

  • commit-and-tag-version version(s): 12.5
  • Node/npm version: Node 22
  • OS: Ubuntu (github actions)

Possible Solution
I have solved this in my github workflow by running a dry-run first, parsing the version number from the output, and grepping it in the output of git tag; if it already exists, increment the final component of the version and try again. Then use the first version that isn't already tagged with --release-as. Something similar can probably be done internally?

Additional context
Roughly the following commands have been executed:

commit-and-tag-version -a --prerelease xyz
commit-and-tag-version -a --prerelease abc
commit-and-tag-version -a --prerelease xyz

Output of last command:
✔ bumping version in package.json from 1.4.3-abc.0 to 1.4.3-xyz.0
✔ bumping version in package-lock.json from 1.4.3-abc.0 to 1.4.3-xyz.0
✔ outputting changes to CHANGELOG.md
✔ committing package-lock.json and package.json and CHANGELOG.md and all staged files
✔ tagging release v1.4.3-xyz.0
fatal: tag 'v1.4.3-xyz.0' already exists

Command failed: git tag -a v1.4.3-xyz.0 -m chore(release): 1.4.3-xyz.0
fatal: tag 'v1.4.3-xyz.0' already exists

@AlexPaven AlexPaven added the bug Something isn't working label Feb 5, 2025
@jaakkotuosa
Copy link

I encountered this as well. The cause for this bug seems to be that latest-semver-tag.js takes literally the latest tag (abc) even if making different prerelease (xyz)

@TimothyJones
Copy link
Member

Thanks for the report and the investigation! A fix for this would be welcome (and looks like #213 is an improvement too)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants