Skip to content

Instantly share code, notes, and snippets.

@meganlkm
Created July 15, 2016 05:13
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 meganlkm/d57bd7c6bfb56c122a572b87ea75ca64 to your computer and use it in GitHub Desktop.
Save meganlkm/d57bd7c6bfb56c122a572b87ea75ca64 to your computer and use it in GitHub Desktop.
bump VERSION and tag
#!/bin/bash
VERSION=$(<VERSION)
echo "Current VERSION: ${VERSION}"
V_LIST=(`echo $VERSION | tr '.' ' '`)
V_MAJOR=${V_LIST[0]}
V_MINOR=${V_LIST[1]}
V_PATCH=${V_LIST[2]}
case "$1" in
major)
V_MAJOR=$((V_MAJOR + 1))
V_MINOR=0
V_PATCH=0
;;
minor)
V_MINOR=$((V_MINOR + 1))
V_PATCH=0
;;
patch)
V_PATCH=$((V_PATCH + 1))
;;
*)
echo $"Usage: $0 {major|minor|patch} [push]"
exit 1
esac
NEW_VERSION="$V_MAJOR.$V_MINOR.$V_PATCH"
echo "${NEW_VERSION}" > VERSION
echo "New VERSION: ${NEW_VERSION}"
if [[ $2 == "push" ]]; then
echo "Commit updated VERSION"
git add VERSION
git commit -m "Bump version to ${NEW_VERSION}"
echo "Create tag for ${NEW_VERSION}"
git tag -a "${NEW_VERSION}" -m "v${NEW_VERSION}"
git push origin $NEW_VERSION
git push upstream $NEW_VERSION
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment