Skip to content

Instantly share code, notes, and snippets.

@paulormart
Created October 15, 2019 23:44
Show Gist options
  • Save paulormart/7e54c6e2f883c81c32c719ba4e357ce5 to your computer and use it in GitHub Desktop.
Save paulormart/7e54c6e2f883c81c32c719ba4e357ce5 to your computer and use it in GitHub Desktop.
Version script
#!/bin/bash
#
# > make a file executable
# chmod +x ./bump-release.sh
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.
# once the new version number is determined, the script will
# pull a list of changes from git history, prepend this to
# a file called CHANGES (under the title of the new version
# number) and create a GIT tag.
git fetch --tags
git checkout staging
if [ -f VERSION ]; then
BASE_STRING=`cat VERSION`
BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`)
V_MAJOR=${BASE_LIST[0]}
V_MINOR=${BASE_LIST[1]}
V_PATCH=${BASE_LIST[2]}
echo "Current version : $BASE_STRING"
read -p "Do you want to RELEASE the current a version $BASE_STRING to General Availability (GA)? [y]" RESPONSE
if [ "$RESPONSE" = "" ]; then RESPONSE="y"; fi
if [ "$RESPONSE" = "Y" ]; then RESPONSE="y"; fi
if [ "$RESPONSE" = "Yes" ]; then RESPONSE="y"; fi
if [ "$RESPONSE" = "yes" ]; then RESPONSE="y"; fi
if [ "$RESPONSE" = "YES" ]; then RESPONSE="y"; fi
if [ "$RESPONSE" = "y" ]; then
git pull origin staging
git checkout -b "release-$BASE_STRING" staging
git checkout master
git pull origin master
git merge --no-ff "release-$BASE_STRING" -m "Merge branch release-$BASE_STRING"
git push origin master
git tag -a -m "Tagging version $BASE_STRING" "$BASE_STRING"
git push origin $BASE_STRING
git checkout staging
git merge --no-ff "release-$BASE_STRING" -m "Merge branch release-$BASE_STRING"
git checkout develop
git merge --no-ff "release-$BASE_STRING" -m "Merge branch release-$BASE_STRING"
git branch -d "release-$BASE_STRING"
git push origin develop
else
echo "Could not find a VERSION file. Run bump-staging.sh script first."
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment