Repository navigation
gh release create: Allow tag names for --target #5855
Description
Activity
Related? #4357
I would also think it's already a feature based on the issue's fix.Edit: IIRC the fix was to enforce that a local tag is pushed with an explicit warning that it only exists locally. Perhaps
--target <tag>should do the same?Thanks for the context everyone. I've just gone and looked at the platform code and it seems like
--targetonly works with branch names and commit SHAs, but not with tag names. I'm not sure if the exclusion of tag names was intentional (the original logic is 9 years old and remained intact all this time), but I'm guessing that the authors of the original logic did not anticipate this use-case.Will file this as a platform issue for now. For now, the only way to ensure that
gh release createwill never automatically create the git tag is to first ensure that the git tag is pushed.Reacted by Victor Lin- addedplatformProblems with the GitHub platform rather than the CLI clientProblems with the GitHub platform rather than the CLI clientand removedneeds-triageneeds to be reviewedneeds to be reviewed
on Jul 11, 2022 I see it calls the Releases API, where
--targetmaps totarget_commitish:Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually
master).@mislav thanks for pointing out that this is a platform issue.
Note that CLI documentation for
release createalso says:--target branch Target branch or full commit SHA (default: main branch)So there is no promise anywhere that tag names are valid input. In fact, they never worked for this API endpoint. I didn't spot this before and I'm sorry I misled you in the other thread. I'm currently asking internally whether there is a possibility that tag names get included in the commitish lookup.
Reacted by Victor LinI'm just guessing, but maybe
target_commitishcan't be a tag for/repos/{owner}/{repo}/releasesbecausetag_nameis already used for tags? In fact, the docs say[target_commitish is] unused if the Git tag already exists.
If a target can be a tag then it raises the question "what happens when the target tag and tag name don't match?" E.g.
gh repo create v1.0.0 --target v2.0.0@spenserblack I see, that's valid... in that case, another feature request that would solve the original problem in the issue description would be to have a flag like
--no-auto-tag/--fail-on-invalid-tagwhich overrides the default behavior of creating the tag if it doesn't exist.Reacted by Michael Dresser, Kaelan Patel, Spenser Black and Petr RuzickaI am also interested in having a flag like @victorlin is suggesting to ensure that
gh release createdoes not create a tag.@michaelmdresser I created a separate issue #6566 for that feature. I think it is based on CLI logic and shouldn't be blocked due to platform issues. Please give thumbs up there!
Reacted by Michael Dresser- addedgh-releaserelating to the gh release commandrelating to the gh release command
on Oct 2, 2023 - added a commit that references this issue
on Dec 13, 2025
Describe the feature or problem you’d like to solve
I want to create a release only if the tag exists (do not want auto tag creation with
gh release create <tag>). Currently, this can be done by:Proposed solution
This can be greatly simplified if
gh release create --targetaccepts a tag name:Additional context
In #2133 (comment), @mislav thought this was already a feature (I would think so too!). However, I did some testing and this is not the case: