github.com/saymoon/flop@v0.1.6-0.20201205092451-00912199cc96/tag.sh (about) 1 #!/usr/bin/env bash 2 3 if [[ $1 == '-h' || $1 == '--help' ]];then 4 echo 'Tag the current git branch based on the version in the VERSION file.' 5 exit 0 6 fi 7 8 set -e 9 10 # make sure we're in the right directory 11 cd $(dirname $0) 12 13 echo "getting project version from VERSION file" 14 VERSION=$(head -n 1 VERSION) 15 TAGS=$(git tag -l) 16 17 echo "checking existing tags" 18 if [[ "$TAGS" != '' ]];then 19 for tag in "$TAGS";do 20 if [[ "$tag" == "$VERSION" ]];then 21 echo "tag for version '$VERSION' already exists. the version must be bumped before pushing it as a new tag." 22 exit 1 23 fi 24 done 25 fi 26 27 echo "tagging as '$VERSION'" 28 git tag -a "$VERSION" -m "$VERSION" 29 echo "pushing tags" 30 git push --tags