Last active
March 6, 2020 18:24
-
-
Save dreamstarter/c06d198d6ffcf69ea24b6c5da0af6d20 to your computer and use it in GitHub Desktop.
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 | |
# enable debug | |
#set -x | |
# variables | |
VERSIONFILE="$HOME/current-version.sh" | |
# functions | |
function saveVersion () { | |
echo "#!/bin/bash | |
MAJOR=${1} | |
MINOR=${2} | |
MAINT=${3} | |
BUILD=${4}" > $5 | |
} | |
# load current VERSION | |
. $VERSIONFILE | |
# main | |
# check paramater to see which number to increment | |
case $1 in | |
release) | |
MAJOR=$[$MAJOR + 1] | |
MINOR=0 | |
MAINT=0 | |
BUILD=0 | |
;; | |
feature) | |
MINOR=$[$MINOR + 1] | |
;; | |
maint) | |
MAINT=$[$MAINT + 1] | |
;; | |
bug) | |
BUILD=$[$BUILD + 1] | |
;; | |
current) | |
echo "Current version: ${MAJOR}.${MINOR}.${MAINT}.${BUILD}" | |
exit 0 | |
;; | |
*) | |
echo "Current version: ${MAJOR}.${MINOR}.${MAINT}.${BUILD}" | |
echo " " | |
echo "Usage: $(basename $0) (current || release || feature || maint || bug)" | |
exit 1 | |
esac | |
# echo the new VERSION number | |
echo "NEW VERSION: ${MAJOR}.${MINOR}.${MAINT}.${BUILD}" | |
saveVersion "${MAJOR}" "${MINOR}" "${MAINT}" "${BUILD}" "$VERSIONFILE" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a suggested revision of that shell script: