Is it possible to have hub release create [TAG]
use the same message as the referenced tag? I don't want it to open the editor for me to add a message when I already added a tag.
I imagine I can create a sub script to load the tag message and then use hub release create -m $tag-message
, but is there any chance this feature already exists and I couldn't find it?
Hi thank you for your suggestion! To clarify: are you talking about annotated git tags, and your proposed flow would be that hub release create TAG
would re-use the title and message from the annotated tag without opening the editor?
Would you be open to the idea that hub would instead pre-populate the contents of the text editor with the message from the git tag, but still open the text editor unless you passed some flag such as --no-edit
? The reason I suggest this is that I think it would be confusing that hub release create
sometimes opens the text editor, and sometimes not.
Yes, annotated git tags. As you probably know, Github Releases doesn't generate annotated tags (nor does it gives us options to do so). To use annotated tags, then, I tag manually.
At the end of the process, I have to copy/paste the tag title/message, manually open Github Releases and create a new one based on the recently pushed annotated tag. Having the possibility of the Release feature with tag's title/message automatically would help automate this process. There are more people around the web with the same problem.
Would you be open to the idea that hub would instead pre-populate the contents of the text editor with the message from the git tag, but still open the text editor unless you passed some flag such as
--no-edit
?
Yes, absolutely. I totally understand the UX concerns and I agree, it needs to be coherent. In my use case, though, I would only use --no-edit
and I'd probably only use the editor when manually calling hub.
p.s.: for context, I currently run a bin/release
script I created which will form release notes based on past commits and then create an annotated tag (among other things) with it as message. If hub
created annotated tags, I'd probably bypass the git tag
part entirely and just use hub
standalone.
To programatically create a GitHub Release by reusing the subject & body of an annotated git tag:
git for-each-ref --format="%(subject)%0a%0a%(body)" refs/tags/<TAG> | \
hub release create -F- <TAG>
This assumes that the tag was already pushed to the remote. You could incorporate this into your release process.
I agree that this is unwieldy. I'll keep this issue open as a todo item to explore how hub could better support annotated tags. Thank you for the suggestion!
Just want to add another alternative to the list
This utilize git tag --list
. For example:
TAG=${GITHUB_REF##*/} # in case you use it in github action
git tag --list ${TAG} --format='%(contents:subject)%0a%0a%(contents:body)' | hub release create --draft -F- ${TAG}
Note that instead of using %(subject)%0a%0a%(body)
, it's better to write it as %(contents:subject)%0a%0a%(contents:body)
to avoid printing PGP SIGNATURE in case the tag is signed. This behavior also found on git for-each-ref
.
Most helpful comment
To programatically create a GitHub Release by reusing the subject & body of an annotated git tag:
This assumes that the tag was already pushed to the remote. You could incorporate this into your release process.
I agree that this is unwieldy. I'll keep this issue open as a todo item to explore how hub could better support annotated tags. Thank you for the suggestion!