Created
November 13, 2019 04:59
-
-
Save bchiang7/d8c396cffd9d581c4e1db0de8ef4cae7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
bold=$(tput bold) | |
normal=$(tput sgr0) | |
set -e | |
echo "-----------------------------------------------" | |
echo " 🚀 Creating a new release 🚀" | |
echo "-----------------------------------------------" | |
# Get the current version from the package.json | |
CURRENT=$(cat package.json \ | |
| grep version \ | |
| head -1 \ | |
| awk -F: '{ print $2 }' \ | |
| sed 's/[",]//g' \ | |
| tr -d '[[:space:]]') | |
# Prompt the user for the new release version | |
printf "Current release version:${bold} ${CURRENT} ${normal}\n" | |
printf "Please enter new release version: " | |
read -r RELEASE | |
if [ -z $RELEASE ]; then | |
echo "Please specify a release number" | |
exit 1 | |
fi | |
printf "Bumping version from ${bold} ${CURRENT} ${normal} 👉 ${bold} ${RELEASE} ${normal} \n" | |
# Show a little progress bar animation | |
prog() { | |
local w=80 p=$1; shift | |
# create a string of spaces, then change them to dots | |
printf -v dots "%*s" "$(( $p*$w/100 ))" ""; dots=${dots// /.}; | |
# print those dots on a fixed-width space plus the percentage etc. | |
printf "\r\e[K|%-*s| %3d %% %s" "$w" "$dots" "$p" "$*"; | |
} | |
# Fake a timeout for fun | |
for x in {1..100} ; do | |
prog "$x" | |
sleep .01 # do some work here | |
done ; echo | |
# Create & switch to the release branch | |
git checkout -b release-$RELEASE | |
# Bump the package.json & package-lock.json versions | |
# https://docs.npmjs.com/cli/version | |
npm version $RELEASE --no-git-tag-version | |
# Commit & push the release branch to GitHub | |
git add . | |
git commit -am "Bump version to $RELEASE" | |
git push origin release-$RELEASE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment