Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ferdinandhuebner/7627208 to your computer and use it in GitHub Desktop.
Save ferdinandhuebner/7627208 to your computer and use it in GitHub Desktop.
#!/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