Created
November 24, 2013 13:18
-
-
Save ferdinandhuebner/7627208 to your computer and use it in GitHub Desktop.
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 | |
function is_integer { | |
test "$1" && printf '%f' "$1" >/dev/null 2>/dev/null; | |
} | |
function increment_fix_version_with_snapshot { | |
currentVersion="$1" | |
if [ $(echo "$currentVersion" | egrep "SNAPSHOT$") ]; then | |
echo "$currentVersion" | |
else | |
currentFixVersion="$(echo "$currentVersion" | awk -F '.' '{print $NF}')" | |
if ( is_integer $currentFixVersion ); then | |
fixVersion="$(echo "$currentVersion" | awk -F '.' '{print $NF+1}')" | |
majorMinor="$(echo "$currentVersion" | sed -e 's:\.[0-9]*$::')" | |
echo "${majorMinor}.${fixVersion}-SNAPSHOT" | |
else | |
echo "${currentVersion}.0-SNAPSHOT" | |
fi | |
fi | |
} | |
increment_fix_version_with_snapshot "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment