You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
gh release create: Allow tag names for --target #5855
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:
# Asserts that <tag> is an actual tag, not a branch name or other ref.
git rev-parse --verify "<tag>^{tag}">/dev/null
# Translate from tag into commit for `gh release create --target`.
commit="$(git rev-parse --verify "<tag>^{commit}")"
gh release create <tag> --target "$commit"
Proposed solution
This can be greatly simplified if gh release create --target accepts a tag name:
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 --target only 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 create will never automatically create the git tag is to first ensure that the git tag is pushed.
I see it calls the Releases API, where --target maps to target_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 create also 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.
I'm just guessing, but maybe target_commitish can't be a tag for /repos/{owner}/{repo}/releases because tag_name is 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-tag which overrides the default behavior of creating the tag if it doesn't exist.
Reacted by Michael Dresser, Kaelan Patel, Spenser Black and Petr Ruzicka
@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!
Activity
spenserblack commentedon Jun 27, 2022
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?mislav commentedon Jul 11, 2022
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.victorlin commentedon Jul 11, 2022
I see it calls the Releases API, where
--targetmaps totarget_commitish:@mislav thanks for pointing out that this is a platform issue.
mislav commentedon Jul 11, 2022
Note that CLI documentation for
release createalso says: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.
spenserblack commentedon Jul 11, 2022
I'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 sayIf 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.0victorlin commentedon Jul 11, 2022
@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.michaelmdresser commentedon Nov 3, 2022
I am also interested in having a flag like @victorlin is suggesting to ensure that
gh release createdoes not create a tag.victorlin commentedon Nov 4, 2022
@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!
feat(release): Add configurable release_conf.yml support