You can create an alias that first populates the temporary file with the desired content, and then runs the git tag with the -F <file> / --file=<file> option to pass the contents of the temp file to the tag message. Theoretically, something like this:
[alias] tag-prepare = !~/bin/prepare_file.sh && git tag --file="/home/user/temp/temp.txt"
Then you invoke it with git tag-prepare v1.2.3 .
Please note that the prepare_file.sh script needs to create the entire tag message, because the --file parameter does not open the editor to edit the content anymore, it only accepts w / e in the provided file and uses it as a message.
source share