Skip to content

Instantly share code, notes, and snippets.

@lfaoro
Created May 17, 2018 10:34
Show Gist options
  • Save lfaoro/711e92d8ce6885961d336c5af0fb7b65 to your computer and use it in GitHub Desktop.
Save lfaoro/711e92d8ce6885961d336c5af0fb7b65 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
BASE=(`cat VERSION | tr '.' ' '`)
MAJOR=${BASE[0]}
MINOR=${BASE[1]}
PATCH=${BASE[2]}
case $1 in
"major")
let "MAJOR++"
MINOR=0
PATCH=0
;;
"minor")
let "MINOR++"
PATCH=0
;;
"patch")
let "PATCH++"
;;
*)
echo "
Usage: ./bump.sh major|minor|patch
"
esac
VER="$MAJOR.$MINOR.$PATCH"
echo "Bumping version from `cat VERSION` to $VER"
read -p "[enter] to confirm / [ctrl-c] to cancel" -n 1 -r
echo $VER > VERSION
git checkout -b "release-v$VER"
git add VERSION
git commit -m "Bumped version to v$VER"
git tag -a -m "Tag version v$VER." "v$VER"
git push -u origin "release-v$VER"
git push origin --tags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment