Skip to content

Instantly share code, notes, and snippets.

@perichus
Last active January 13, 2016 19:14
Show Gist options
  • Select an option

  • Save perichus/ca5fd926066d51c79341 to your computer and use it in GitHub Desktop.

Select an option

Save perichus/ca5fd926066d51c79341 to your computer and use it in GitHub Desktop.
Bump Git Tag - Shell Script
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