From ba6c7eceecfb1a4093688be4d2d67c9f870c141c Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Fri, 5 Feb 2021 01:41:35 +0800 Subject: [PATCH] Add a modification to `Gemfile.lock` in bump tool --- tools/bump.sh | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/tools/bump.sh b/tools/bump.sh index b3f5407..331fdce 100755 --- a/tools/bump.sh +++ b/tools/bump.sh @@ -5,16 +5,20 @@ # - assets/js/.copyright.js # - assets/js/dist/*.js (will be built by gulp later) # - jekyll-theme-chirpy.gemspec +# - Gemfile.lock # - package.json # -# 2. Create a git-tag +# 2. Create a git-tag on release branch # # 3. Build a rubygem package # +# # Requires: gulp, rubygem set -eu +auto_release=true + ASSETS=( "_sass/jekyll-theme-chirpy.scss" "assets/js/.copyright" @@ -22,6 +26,8 @@ ASSETS=( GEM_SPEC="jekyll-theme-chirpy.gemspec" +GEM_LOCK="Gemfile.lock" + NODE_META="package.json" _check_src() { @@ -54,26 +60,33 @@ 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$_version/" "${ASSETS[$i]}" done gulp } _bump_gemspec() { - sed -i "s/[[:digit:]]\.[[:digit:]]\.[[:digit:]]/$1/" "$GEM_SPEC" + sed -i "s/[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/$1/" "$GEM_SPEC" } _bump_node() { sed -i \ - "s,[\"]version[\"]: [\"][[:digit:]]\.[[:digit:]]\.[[:digit:]][\"],\"version\": \"$1\"," \ + "s,[\"]version[\"]: [\"][[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+[\"],\"version\": \"$1\"," \ $NODE_META } +_bump_gemlock() { + sed -i \ + "s/jekyll-theme-chirpy ([[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/jekyll-theme-chirpy ($1/" \ + $GEM_LOCK +} + bump() { _bump_assets "$1" _bump_gemspec "$1" _bump_node "$1" + _bump_gemlock "$1" if [[ -n $(git status . -s) ]]; then git add . @@ -143,7 +156,10 @@ main() { bump "$_version" echo -e "Release to v$_version\n" - release "$_version" + + if $auto_release; then + release "$_version" + fi else echo "Error: Illegal version number: '$_version'" @@ -151,4 +167,18 @@ main() { } +while (($#)); do + opt="$1" + case $opt in + -m | --manual) + auto_release=false + shift + ;; + *) + echo "unknown option '$opt'!" + exit 1 + ;; + esac +done + main