Last active
January 13, 2016 19:14
-
-
Save perichus/ca5fd926066d51c79341 to your computer and use it in GitHub Desktop.
Bump Git Tag - Shell Script
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
| function tag() { | |
| VERSION=`git describe --abbrev=0 --tags` | |
| VERSION_BITS=("${(@s/./)VERSION}") | |
| MAJOR=$VERSION_BITS[1] | |
| MINOR=$VERSION_BITS[2] | |
| HF=$VERSION_BITS[3] | |
| if [ "$1" = "major" ]; | |
| then | |
| MAJOR=$((MAJOR+1)) | |
| MINOR='0' | |
| HF='0' | |
| elif [ "$1" = "minor" ]; | |
| then | |
| MINOR=$((MINOR+1)) | |
| HF='0' | |
| elif [ "$1" = "hotfix" ]; | |
| then | |
| HF=$((HF+1)) | |
| fi | |
| NEW_TAG="$MAJOR.$MINOR.$HF" | |
| echo "Want to bump tag from $VERSION to $NEW_TAG (y/n)" | |
| read yn | |
| case $yn in | |
| [Yy]* ) git tag $NEW_TAG;; | |
| [Nn]* ) return;; | |
| * ) echo "Please answer yes or no.";; | |
| esac | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment