Last active
August 29, 2015 14:07
-
-
Save neight-allen/97bc39fd0cafd9ed7e61 to your computer and use it in GitHub Desktop.
I use this to tag commits when I'm ready to deploy to production. I made this so I don't have to remember what the last version was, and so I don't have to type the command either. To use as a git command (git nexttag) save it as git-nexttag somewhere on the path, like /usr/local/bin.
This file contains 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 | |
lasttag=$(git describe --abbrev=0 --tags) | |
tagparts=(${lasttag//./ }) | |
if [ ! -z $1 ] && [ $1 == "--hotfix" ] | |
then | |
declare -i hotfix | |
hotfix=1 | |
if [ ${tagparts[2]} ] | |
then | |
hotfix=${tagparts[2]}+1 | |
fi | |
newVersion=${tagparts[0]}.${tagparts[1]}.$hotfix | |
message="Version 1.$stringMinorVersion Hotfix #$hotfix" | |
else | |
declare -i newMinorVersion | |
newMinorVersion=${tagparts[1]}+1 | |
stringMinorVersion="$(printf "%02d" $newMinorVersion)" | |
newVersion=${tagparts[0]}.$stringMinorVersion | |
message="Version 1.$stringMinorVersion" | |
fi | |
git tag -a $newVersion -m "$message" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment