From 89200f31098825d459e36c322ea72541eeef7c11 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 10 Feb 2021 17:53:25 +0800 Subject: [PATCH] Improve the bump tool --- tools/bump.sh | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/tools/bump.sh b/tools/bump.sh index 331fdce..c3f8b89 100755 --- a/tools/bump.sh +++ b/tools/bump.sh @@ -10,14 +10,14 @@ # # 2. Create a git-tag on release branch # -# 3. Build a rubygem package +# 3. Build a RubyGems package base on the latest git-tag # # -# Requires: gulp, rubygem +# Requires: Git, Gulp, RubyGems set -eu -auto_release=true +manual_release=false ASSETS=( "_sass/jekyll-theme-chirpy.scss" @@ -58,9 +58,8 @@ check() { } _bump_assets() { - _version="$1" for i in "${!ASSETS[@]}"; do - sed -i "s/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/v$_version/" "${ASSETS[$i]}" + sed -i "s/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/v$1/" "${ASSETS[$i]}" done gulp @@ -118,21 +117,33 @@ release() { _release_branch="$_major-$_minor-stable" + if $manual_release; then + echo -e "Bump version to $_version (manual release)\n" + bump "$_version" + exit 0 + fi + if [[ -z $(git branch -v | grep "$_release_branch") ]]; then git checkout -b "$_release_branch" else git checkout "$_release_branch" - # cherry-pick the latest 2 commit from master to release branch - git cherry-pick "$(git rev-parse master~1)" "$(git rev-parse master)" + # cherry-pick the latest commit from master branch to release branch + git cherry-pick "$(git rev-parse master)" fi + echo -e "Bump version to $_version\n" + bump "$_version" + echo -e "Create tag v$_version\n" git tag "v$_version" + echo -e "Build the gem pakcage for v$_version\n" build_gem # head back to master branch git checkout master + # cherry-pick the latest commit from release branch to master branch + git cherry-pick "$_release_branch" -x } @@ -152,16 +163,10 @@ main() { exit -1 fi - echo -e "Bump version to $_version\n" - bump "$_version" - - echo -e "Release to v$_version\n" - - if $auto_release; then - release "$_version" - fi + release "$_version" else + echo "Error: Illegal version number: '$_version'" fi @@ -171,7 +176,7 @@ while (($#)); do opt="$1" case $opt in -m | --manual) - auto_release=false + manual_release=true shift ;; *)