Skip to content

Instantly share code, notes, and snippets.

@deletosh
Forked from viktorbenei/version_bump.sh
Created October 25, 2016 19:36
Show Gist options
  • Save deletosh/248e3106f89ffc3b3d97758de331c803 to your computer and use it in GitHub Desktop.
Save deletosh/248e3106f89ffc3b3d97758de331c803 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
THIS_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "${THIS_SCRIPT_DIR}/.."
# Check if there's something uncommitted (don't release if there are files
# not yet committed)
set +e
git_status="$(git status --porcelain)"
if [[ "${git_status}" != "" ]] ; then
echo " [!] Uncommitted files found! Commit before release!"
echo " (i) git_status: ${git_status}"
exit 1
fi
set -e
current_version="$(cat ./version)"
echo "current_version: ${current_version}"
#
# How to roll-back?
# * if you want to undo the last commit you can call:
# $ git reset --hard HEAD~1
# * to roll back to the remote state:
# $ git reset --hard origin/[branch-name]
#
set -x
bumped_version=$(ruby -e "splits='${current_version}'.split('.');major=splits[0];minor=splits[1];puts \"#{major}.#{minor.to_i.next}\"")
echo " [i] bumped_version: ${bumped_version}"
echo "${bumped_version}" > ./version
git add ./version
git commit -m "v${bumped_version}"
git checkout prod
git merge master -m "Merge master into prod, release: v${bumped_version}"
git tag "${bumped_version}"
git checkout master
# => DONE [OK]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment