Skip to content

Instantly share code, notes, and snippets.

@TommyLau
Created April 12, 2016 07:23
Show Gist options
  • Save TommyLau/0c985574a19a574beaae9077581daa2f to your computer and use it in GitHub Desktop.
Save TommyLau/0c985574a19a574beaae9077581daa2f to your computer and use it in GitHub Desktop.
Generate version string based on the git repository
VERSION=$(git branch | sed -n -e 's/^\* release\/\(.*\)/\1/p')
if [ "$VERSION" == "" ]; then
echo "Develop branch"
VERSION="DEV"
else
VERSION="V$VERSION"
fi
BUILD=`git log --pretty=format:'' | wc -l | tr -d '[[:space:]]'`
HASH=`git log --pretty=format:'%h' -n 1`
TIME=`date '+%y%m%d%H%M'`
STRING="$VERSION build $BUILD ($HASH-$TIME)"
echo $STRING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment