-
Notifications
You must be signed in to change notification settings - Fork 664
How to release
#!/bin/sh : '
AlaSQL uses git flow to manage development and Semantic Versioning to manage versioning. In practice the result is that the master branch is never updated without updating the version number. That includes changes like corrections to documentation files such as README.md.
The formatting of this document is a bit funny because it works both as a markdown document and a sh
script. Running the command
> npm run release
will curl
the content of this wiki page to sh
.
' go(){
#Please update the following checklist where you see a better way...
run "Make sure you have the last version of both master and develop" "git checkout master && git pull && git checkout develop && git pull"
run "Install node modules" "yarn install"
run "Make sure all node modules are up to date" "yarn uptodate"
echo "For the checklist to continue build+test must be OK" && hitkey
yarn test || exit 1
hitkey && br
commitUrl="https://github.com/agershun/alasql/commits/develop"
roadmapUrl="https://trello.com/b/qxz65pVi/alasql-roadmap"
run "Identify next version number.${CR}First, determine if the changes involved are:${CR}Bug fixes, Added functinality or Incompatible API changes" 'open $commitUrl 2>/dev/null || { echo "No browser found to open: $commitUrl" && hitkey ; }'
preVersion=`npm list alasql --silent --depth=0 | grep -o "alasql@[^ ]*" | cut -c8-` # Dancing around as npm view .. version will give info about any globally installed package before the local one
while true; do
echo "\033[0;32mVersion is now $preVersion"
echo "For the format X.Y.Z select part to bump:"
echo " X) MAJOR - incompatible API changes"
echo " Y) MINOR - added functionality in a backwards-compatible manner"
echo " Z) PATCH - backwards-compatible bug fixes\033[0m"
echo " Q) Do not bump the version"
read -p ": " v
case $v in
[Xx]* ) ./node_modules/.bin/mversion major ; break ;;
[Yy]* ) ./node_modules/.bin/mversion minor ; break ;;
[Zz]* ) ./node_modules/.bin/mversion patch ; break ;;
[Qq]* ) echo "No changes made" ; break ;;
* ) echo "Please answer X, Y, Z or Q" && echo ;;
esac
done
hitkey
br
thisVersion=`npm list alasql --silent --depth=0 | grep -o "alasql@[^ ]*" | cut -c8-` # Dancing around as 'npm view .. version' will give info about any globally installed package before the local one
echo "Version was bumped: $preVersion -> $thisVersion"
# Switch to or create a release branch git flow release start x.y.z
(in source tree click "git flow" at the top right). Name it exactly as the new version number (for example "0.2.0").
if grep -m 1 -q 'release/' <<< "`git branch`" ; then
git stash --quiet && git checkout -q "release/$thisVersion" 2> /dev/null && git stash pop --quiet || echo "Problem switching to branch release/$thisVersion${CR}but there is a branch named `git branch | grep -m 1 -o 'release/.*'`" && git stash pop --quiet && flee "Please delete the `git branch | grep -m 1 -o 'release/.*'` branch or rerun this checklist ${CR}making sure the version bump matches the existing branch version" ;
else
run "Create and switch to a new release branch" "git stash --quiet; git flow release start $thisVersion ; git stash pop --quiet"
fi
# Update CHANGELOG.md with some words to what has changed. Select a city name the flavor of the day as part of the title. You can see the commits and the roadmap for inspiration to what to write
run "Update CHANGELOG.md with some words to what has changed.${CR}${CR}Set title as '$thisVersion \"CITYNAME\" (DD.MM.YYYY)'${CR}For example '$thisVersion \"Athens\" (13.07.2015)'${CR}${CR}Select a city name (flavor of the day) as part of the title." '{ open $commitUrl 2>/dev/null || echo "No browser found to open: $commitUrl" ; } && { open $roadmapUrl 2>/dev/null || echo "No browser found to open: $roadmapUrl" && hitkey ; } && { open CHANGELOG.md || vim CHANGELOG.md ; } && echo "Please edit CHANGELOG.md before continuing"'
# Copy al content from https://github.com/agershun/alasql/wiki/readme into README.md
run "Update README.md with the one on the wiki" "curl https://raw.githubusercontent.com/wiki/agershun/alasql/readme.md -o README.md"
echo "For the checklist to continue build+test must be OK and a test cover report will be created" && hitkey
yarn test || exit 1
yarn test-cover
hitkey
br
run "push package to npm" "npm publish"
run "Add and commit changed files" "git commit -am 'Updated version in files to $thisVersion'"
# Finish release git flow release finish x.y.z
(for source tree just clicking "git-flow" at the top right corner)
run "Finish git-flow release" "git flow release finish $thisVersion"
run "Push develop and master + tags to github" "git checkout master && git push && git checkout develop && git push && git push --tags"
# Create a new github release Same description as CHANGELOG.md and with release title as "CITYNAME" (TODAY)
for example "Athens" (19.01.2038)
You should be able to find it in the dropdown in "Tag version" - and select master as branch.
releaseUrl="https://github.com/agershun/alasql/releases/new"
run "Create a new github release.${CR}${CR}Same title and description as in CHANGELOG.md but without title version number${CR}${CR}You should be able to find $thisVersion in the dropdown \"Tag version\"${CR}${CR}Please select MASTER as branch(!)${CR}" '{ open CHANGELOG.md || vim CHANGELOG.md ; } & { open $releaseUrl 2>/dev/null || echo "No browser found to open: $releaseUrl" && hitkey ; }'
allOK
}
check(){
clear && echo
echo "How to release a new version of AlaSQL" && hr
info "Checking all is OK to start the checklist..." && echo
node -v > /dev/null 2>&1 || flee "Please install npm before continuing"
yarn -v > /dev/null 2>&1 || flee "Please install npm before continuing"
[ -f ./package.json ] || flee "Please cd to package root folder"
[ "alasql" = "$(npm view .. name)" ] || flee "This checklist is ment for AlaSQL"
git version > /dev/null 2>&1 || flee "Please install git before continuing"
git flow version > /dev/null 2>&1 || flee "Please install git-flow before continuing"
grep -q 'gitflow' ./.git/config || run "To run the checklist you must prepare the repo for git-flow${CR}Its recommended to accept the suggested values" "git flow init" || flee "Please 'git flow init' before restarting this checklist"
go
}
pause() {
OLDCONFIG=`stty -g`
stty -icanon -echo min 1 time 0
dd count=1 2>/dev/null
stty $OLDCONFIG
}
todo(){
echo "$(echo "\033[0;101mManual action:\033[0m \033[0;32m$1\033[0m ")"
if [ -n "$2" ]; then
echo "This might help you: \033[1;36m$2\033[0m"
fi
info "Hit a key when its done..."
pause
br
}
CR=`echo '\n.'` ###### Get a carriage return into `CR`
CR=${CR%.}
hr () {
echo "‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗‗" && echo
}
br () {
clear && hr
}
run () { ###### Aks if user wants to execute something
while true; do
read -p "$(echo "\033[0;32m$1\033[0m")${CR}Would you like to execute: $CR$(echo "\033[1;30m$2\033[0m")$CR(Yes) " yn
case ${yn:-Y} in
[Yy]* ) { { eval $2 && hitkey } || flee "Please solve the problem manually and restart this checklist"; } ; } && br && return;;
[Nn]* ) echo "$(echo "\033[0;101mThis step was skipped - Please fix manually...\033[0m")" && hitkey && br && return 1;;
[Qq]* ) echo "Are you a quitter?" && exit;;
* ) echo "${CR}Please answer $(echo "\033[0;32mY\033[0mes or \033[0;31mN\033[0mo")";;
esac
done
}
info () {
echo "\033[1;30m$1\033[0m"
}
hitkey () {
info "Hit a key to continue..." && pause
}
alert(){
echo "\033[0;101m$1\033[0m"
}
flee(){
echo && alert "$1" && echo && exit 1
}
allOK(){
br
echo "\033[0;32mAll Done!\033[0m${CR}"
}
check
© 2014-2024, Andrey Gershun & Mathias Rangel Wulff
Please help improve the documentation by opening a PR on the wiki repo