Last active
April 8, 2019 12:56
-
-
Save fanyeren/541b3fc551308a829b6d6ac0cadb8c2c to your computer and use it in GitHub Desktop.
buildNumber
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
#!/bin/bash | |
BUILD_NUM="" | |
if [[ ! -f buildNumber ]]; then | |
touch buildNumber | |
BUILD_NUM="b-0" | |
echo 0 > buildNumber | |
else | |
num=$(cat buildNumber | grep -E '^[0-9]+$' 2>/dev/null) | |
if [[ x$num == 'x' ]]; then | |
BUILD_NUM="b-0" | |
echo 0 > buildNumber | |
else | |
((num++)) | |
BUILD_NUM="b-${num}" | |
echo ${num} > buildNumber | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment