Skip to content

Instantly share code, notes, and snippets.

@alexbonhomme
Last active January 29, 2019 08:31
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 alexbonhomme/519ce0919bcb89d41e279c5480bab38b to your computer and use it in GitHub Desktop.
Save alexbonhomme/519ce0919bcb89d41e279c5480bab38b to your computer and use it in GitHub Desktop.
Release script
#! /bin/bash
if [[ "$#" -lt 1 ]]; then
printf "\033[0;31mUsage: $0 version \e[0m\n"
exit -1
fi
RELEASE_VERSION=$1
BRANCH_NAME="release-$RELEASE_VERSION"
printf "\033[1;35mCreates release \e[0m\n"
# branch creation
git checkout -b $BRANCH_NAME develop
if [ "$2" != "--no-bump" ]; then
# Adds release number at the beginning of the changelog file and open it
if [ ! -f "CHANGELOG.md" ]; then
touch CHANGELOG.md
fi
sed -i '' '1s/^/\'$'\n/g' CHANGELOG.md
sed -i '' "1s/^/# $RELEASE_VERSION/" CHANGELOG.md
sed -i '' '2s/^/\'$'\n/g' CHANGELOG.md
sed -i '' '2s/^/\'$'\n/g' CHANGELOG.md
sed -i '' '2s/^/\'$'\n- /g' CHANGELOG.md
nano CHANGELOG.md
git add CHANGELOG.md
# updates version number
./bump-version.py $RELEASE_VERSION
fi
# log modifications
git commit -am "🚀 Release version $RELEASE_VERSION"
# merge into master
git checkout master
git merge --no-ff --no-edit $BRANCH_NAME
# tag management
git tag -a $RELEASE_VERSION -m "Release version $RELEASE_VERSION"
# merge into develop
git checkout develop
git merge --no-ff --no-edit $BRANCH_NAME
# remove branch
git branch -d $BRANCH_NAME
printf "\033[1;35mPush commits release \e[0m\n"
# push branches
git push origin master --follow-tags
git push origin develop
printf "\033[1;32mRelease $RELEASE_VERSION DONE ! \e[0m\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment