Skip to content

Commit 89200f3

Browse files
committed
Improve the bump tool
1 parent 1367734 commit 89200f3

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

tools/bump.sh

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
#
1111
# 2. Create a git-tag on release branch
1212
#
13-
# 3. Build a rubygem package
13+
# 3. Build a RubyGems package base on the latest git-tag
1414
#
1515
#
16-
# Requires: gulp, rubygem
16+
# Requires: Git, Gulp, RubyGems
1717

1818
set -eu
1919

20-
auto_release=true
20+
manual_release=false
2121

2222
ASSETS=(
2323
"_sass/jekyll-theme-chirpy.scss"
@@ -58,9 +58,8 @@ check() {
5858
}
5959

6060
_bump_assets() {
61-
_version="$1"
6261
for i in "${!ASSETS[@]}"; do
63-
sed -i "s/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/v$_version/" "${ASSETS[$i]}"
62+
sed -i "s/v[[:digit:]]\+\.[[:digit:]]\+\.[[:digit:]]\+/v$1/" "${ASSETS[$i]}"
6463
done
6564

6665
gulp
@@ -118,21 +117,33 @@ release() {
118117

119118
_release_branch="$_major-$_minor-stable"
120119

120+
if $manual_release; then
121+
echo -e "Bump version to $_version (manual release)\n"
122+
bump "$_version"
123+
exit 0
124+
fi
125+
121126
if [[ -z $(git branch -v | grep "$_release_branch") ]]; then
122127
git checkout -b "$_release_branch"
123128
else
124129
git checkout "$_release_branch"
125-
# cherry-pick the latest 2 commit from master to release branch
126-
git cherry-pick "$(git rev-parse master~1)" "$(git rev-parse master)"
130+
# cherry-pick the latest commit from master branch to release branch
131+
git cherry-pick "$(git rev-parse master)"
127132
fi
128133

134+
echo -e "Bump version to $_version\n"
135+
bump "$_version"
136+
129137
echo -e "Create tag v$_version\n"
130138
git tag "v$_version"
131139

140+
echo -e "Build the gem pakcage for v$_version\n"
132141
build_gem
133142

134143
# head back to master branch
135144
git checkout master
145+
# cherry-pick the latest commit from release branch to master branch
146+
git cherry-pick "$_release_branch" -x
136147

137148
}
138149

@@ -152,16 +163,10 @@ main() {
152163
exit -1
153164
fi
154165

155-
echo -e "Bump version to $_version\n"
156-
bump "$_version"
157-
158-
echo -e "Release to v$_version\n"
159-
160-
if $auto_release; then
161-
release "$_version"
162-
fi
166+
release "$_version"
163167

164168
else
169+
165170
echo "Error: Illegal version number: '$_version'"
166171
fi
167172

@@ -171,7 +176,7 @@ while (($#)); do
171176
opt="$1"
172177
case $opt in
173178
-m | --manual)
174-
auto_release=false
179+
manual_release=true
175180
shift
176181
;;
177182
*)

0 commit comments

Comments
 (0)