Skip to content

Instantly share code, notes, and snippets.

@yvesvanbroekhoven
Created October 22, 2013 07:38
Show Gist options
  • Save yvesvanbroekhoven/7096598 to your computer and use it in GitHub Desktop.
Save yvesvanbroekhoven/7096598 to your computer and use it in GitHub Desktop.
Simple sofware version release incrementation script
#!/usr/bin/env bash
if ! [[ -a "VERSION" ]]; then
echo "VERSION file initialized"
touch "VERSION"
echo "0.0.0" > "VERSION"
fi
version=$(cat VERSION)
version_arr=(${version//./ })
if [[ -z "$1" ]]; then
echo "Please provide the release type: major, minor or patch"
exit 1
fi
if [[ "$1" != 'major' ]] && [[ "$1" != 'minor' ]] && [[ "$1" != 'patch' ]]; then
echo "Please provide the correct release type: major, minor or patch"
exit 1
fi
if [[ "$1" == 'patch' ]]; then
let version_arr[2]=${version_arr[2]}+1
echo "Released patch version:"
fi
if [[ "$1" == 'minor' ]]; then
let version_arr[1]=${version_arr[1]}+1
version_arr[2]=0
echo "Released minor version"
fi
if [[ "$1" == 'major' ]]; then
let version_arr[0]=${version_arr[0]}+1
version_arr[1]=0
version_arr[2]=0
echo "Released major version"
fi
version=${version_arr[@]}
echo ${version// /.} > "VERSION"
cat "VERSION"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment