Created
April 12, 2016 07:23
-
-
Save TommyLau/0c985574a19a574beaae9077581daa2f to your computer and use it in GitHub Desktop.
Generate version string based on the git repository
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
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