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: Add flag to prevent a release if tag does not exist #6566
If a matching git tag does not yet exist, one will automatically get created from the latest state of the default branch. Use --target to override this.
However, using --target is not a solution because I simply don't want to create a release in this case, not release from another commit ID.
Proposed solution
Add a flag such as --no-auto-tag/--fail-on-missing-tag which overrides the default behavior of creating the tag if it doesn't exist.
Thanks for the suggestion. I'm not sure if this should be a separate issue, though. If we allow tag names for --target per #5855, then you should be able to achieve what you want with:
gh release create v1.2.3 --target=v1.2.3
Or did you have another idea for this feature in mind?
The workaround for you right now is to use the API to check if the tag already exists:
gh api --silent "repos/:owner/:repo/git/refs/tags/v1.2.3"&& gh release create v1.2.3 --notes ""
@mislav this feature request is slightly different. Instead of creating a release from an existing tag name using --target, don't use that flag and only create a release if the required parameter [<tag>] represents an existing tag. That ability shouldn't be blocked by platform limitations.
Instead of creating a release from an existing tag name using --target, don't use that flag and only create a release if the required parameter [<tag>] represents an existing tag.
Well, if --target (a platform feature) was allowed to point to a tag, then you could achieve what you want with:
gh release create v1.2.3 --target=v1.2.3
#=> (errors out if "v1.2.3" tag does not exist)
I've proposed this approach because it should solve both this use-case and the use-case proposed in the thread you've linked (explicitly referencing tag names using --target).
That ability shouldn't be blocked by platform limitations.
You're right that the CLI should be able to implement what you're asking without relying on new platform features being shipped. We could check for the existence of remote tags by querying the GitHub API for git tags.
We discussed this and agreed that a flag such as gh release create <tag> --verify-tag would be something we could implement in the gh client. We chose that name because --fail-on-missing-tag is a bit long, even if it's more accurate.
The implementation would then be: if the flag is set, query <tag> among repository tags via the GitHub API before creating the release, and abort the command if the tag was not found.
Activity
mislav commentedon Nov 5, 2022
Thanks for the suggestion. I'm not sure if this should be a separate issue, though. If we allow tag names for
--targetper #5855, then you should be able to achieve what you want with:Or did you have another idea for this feature in mind?
The workaround for you right now is to use the API to check if the tag already exists:
victorlin commentedon Nov 10, 2022
@mislav this feature request is slightly different. Instead of creating a release from an existing tag name using
--target, don't use that flag and only create a release if the required parameter[<tag>]represents an existing tag. That ability shouldn't be blocked by platform limitations.mislav commentedon Nov 14, 2022
Well, if
--target(a platform feature) was allowed to point to a tag, then you could achieve what you want with:gh release create v1.2.3 --target=v1.2.3 #=> (errors out if "v1.2.3" tag does not exist)I've proposed this approach because it should solve both this use-case and the use-case proposed in the thread you've linked (explicitly referencing tag names using
--target).You're right that the CLI should be able to implement what you're asking without relying on new platform features being shipped. We could check for the existence of remote tags by querying the GitHub API for git tags.
mislav commentedon Nov 14, 2022
We discussed this and agreed that a flag such as
gh release create <tag> --verify-tagwould be something we could implement in the gh client. We chose that name because--fail-on-missing-tagis a bit long, even if it's more accurate.The implementation would then be: if the flag is set, query
<tag>among repository tags via the GitHub API before creating the release, and abort the command if the tag was not found.@victorlin Does that sound good?
victorlin commentedon Nov 14, 2022
@mislav that sounds great, thanks for the attention on this!
Add --verify-tag flag for release creation command