Improve the bump tool

This commit is contained in:
Cotes Chung 2021-02-10 17:53:25 +08:00
parent 136773481e
commit 89200f3109

View file

@ -10,14 +10,14 @@
# #
# 2. Create a git-tag on release branch # 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 set -eu
auto_release=true manual_release=false
ASSETS=( ASSETS=(
"_sass/jekyll-theme-chirpy.scss" "_sass/jekyll-theme-chirpy.scss"
@ -58,9 +58,8 @@ check() {
} }
_bump_assets() { _bump_assets() {
_version="$1"
for i in "${!ASSETS[@]}"; do 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 done
gulp gulp
@ -118,21 +117,33 @@ release() {
_release_branch="$_major-$_minor-stable" _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 if [[ -z $(git branch -v | grep "$_release_branch") ]]; then
git checkout -b "$_release_branch" git checkout -b "$_release_branch"
else else
git checkout "$_release_branch" git checkout "$_release_branch"
# cherry-pick the latest 2 commit from master to release branch # cherry-pick the latest commit from master branch to release branch
git cherry-pick "$(git rev-parse master~1)" "$(git rev-parse master)" git cherry-pick "$(git rev-parse master)"
fi fi
echo -e "Bump version to $_version\n"
bump "$_version"
echo -e "Create tag v$_version\n" echo -e "Create tag v$_version\n"
git tag "v$_version" git tag "v$_version"
echo -e "Build the gem pakcage for v$_version\n"
build_gem build_gem
# head back to master branch # head back to master branch
git checkout master 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 exit -1
fi fi
echo -e "Bump version to $_version\n" release "$_version"
bump "$_version"
echo -e "Release to v$_version\n"
if $auto_release; then
release "$_version"
fi
else else
echo "Error: Illegal version number: '$_version'" echo "Error: Illegal version number: '$_version'"
fi fi
@ -171,7 +176,7 @@ while (($#)); do
opt="$1" opt="$1"
case $opt in case $opt in
-m | --manual) -m | --manual)
auto_release=false manual_release=true
shift shift
;; ;;
*) *)