Last active
November 30, 2023 23:57
-
-
Save donnyquixotic/f1d8772030de0b67ad79aa64820e9a87 to your computer and use it in GitHub Desktop.
creates git alias 'vtag' that signs, verifies, and pushes local tag to remote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# description: | |
# creates git alias 'vtag' that signs, verifies, and pushes local tag to remote | |
# usage: `git vtag <tag-name> [<target branch>]` e.g. `git vtag v1.2.3` | |
# params: | |
# <tag name> name of tag e.g. 'v1.2.3' | |
# <target branch> optional argument, branch to be tagged e.g. 'feature-branch', default is 'master' | |
# executed commands: | |
# - checkout master (or optionally <target branch>) | |
# - update local with remote | |
# - signs tag with annotation of tag name | |
# - verifies tag | |
# - pushes tag to remote | |
# assumptions: | |
# - GPG signing key is set in git config | |
# - repo permissions and git credentials allow pushing directly | |
# create alias: | |
# copypasta script below and execute in terminal or save file and run `chmod u+x $HOME/verifyTag.sh | . $HOME/verifyTag.sh` | |
git config --global alias.vtag '! _() { | |
if [ -z "${2}" ]; then | |
git checkout master | |
echo "verifying tag on master branch" | |
else | |
git checkout ${2} | |
echo "verifying tag on ${2} branch" | |
fi | |
git pull && | |
git tag -s "$1" -m "$1" && | |
git tag -v "$1" && | |
git push origin "$1" | |
}; _' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment