fix(semantic-release): only emit tag output for newly created releases#49
Merged
fix(semantic-release): only emit tag output for newly created releases#49
Conversation
The 'Resolve release outputs' step used `git tag --points-at HEAD` to discover the released tag, which also picked up tags created by prior workflow runs on different branches. After a main→develop backmerge of the same commit, the develop run would re-emit the main release tag (e.g. v1.5.0), causing downstream upload steps to fail with 'asset under the same name already exists'. Snapshot the tag set at HEAD before running semantic-release and only emit tags that did not exist beforehand. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
Resolve release outputsstep uses:TAG=$(git tag --points-at HEAD --sort=-v:refname | head -1)This picks up any tag pointing at HEAD, including tags created by a prior workflow run on a different branch. In our main↔develop backmerge flow that causes a real failure:
develop→main(commitX)mainworkflow runs semantic-release → createsv1.5.0atX, uploads release assets, then backmergesmain→develop(push of identical SHAX)developworkflow on commitXdevelophas nothing new to releasegit tag --points-at HEADreturnsv1.5.0(created by the main run), sooutputs.tag=v1.5.0is emittedgh release upload v1.5.0 …fails:asset under the same name already existsObserved in:
Fix
Snapshot the tag set at HEAD before running semantic-release, then diff with the post-run set. Only tags that did not previously exist are reported as new releases.
Verified
Manually tested the shell logic: