Skip to content

Commit 5cf6481

Browse files
committed
[Breaking Change] (config) Adjust the log message.
1 parent 3af7431 commit 5cf6481

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

scripts/ci/build_git-tag_or_create_github-release.sh

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@
55
# Check whether it has 'release-notes.md' or 'release-title.md' in the target directory '.github'.
66
has_auto_release_flag=$(ls .github | grep -E "release-auto-flag.txt")
77
if [ "$has_auto_release_flag" == "" ]; then
8-
echo "It should have *release-auto-flag.txt* in '.github' directory of your project in HitHub."
8+
echo "⚠️ It should have *release-auto-flag.txt* in '.github' directory of your project in HitHub."
99
exit 0
1010
else
1111
auto_release_flag=$(cat .github/release-auto-flag.txt)
1212
if [ "$auto_release_flag" == false ]; then
13-
echo "Auto-release flag is 'false' so it won't build git tag or create GitHub release."
13+
echo "💤 Auto-release flag is 'false' so it won't build git tag or create GitHub release."
1414
exit 0
1515
fi
1616
fi
1717

1818
has_release_notes=$(ls .github | grep -E "release-notes.md")
1919
has_release_title=$(ls .github | grep -E "release-title.md")
2020
if [ "$has_release_notes" == "" ]; then
21-
echo "It should have *release-notes.md* in '.github' directory of your project in HitHub."
21+
echo "It should have *release-notes.md* in '.github' directory of your project in HitHub."
2222
exit 1
2323
fi
2424
if [ "$has_release_title" == "" ]; then
25-
echo "It should have *release-title.md* in '.github' directory of your project in HitHub."
25+
echo "It should have *release-title.md* in '.github' directory of your project in HitHub."
2626
exit 1
2727
fi
2828

@@ -31,6 +31,11 @@ fi
3131
Input_Arg_Release_Type=$1
3232
Input_Arg_Debug_Mode=$2
3333

34+
if [ "$Input_Arg_Release_Type" == "" ]; then
35+
echo "❌ The argument 'Input_Arg_Release_Type' (first argument) cannot be empty."
36+
exit 1
37+
fi
38+
3439
if [ "$Input_Arg_Release_Type" == 'python-package' ]; then
3540
# # # # The name of Python package
3641
Input_Arg_Python_Pkg_Name=$3
@@ -42,18 +47,13 @@ elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then
4247
Input_Arg_Software_Version_Format=""
4348
# Input_Arg_Debug_Mode=$2
4449
else
45-
echo "Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'."
50+
echo "Currently, it only has 2 release type: 'python-package' or 'github-action-reusable-workflow'."
4651
exit 1
4752
fi
4853
if [ "$Input_Arg_Debug_Mode" == "" ]; then
4954
Input_Arg_Debug_Mode=true
5055
fi
5156

52-
if [ "$Input_Arg_Release_Type" == "" ]; then
53-
echo "The argument 'Input_Arg_Release_Type' (first argument) cannot be empty."
54-
exit 1
55-
fi
56-
5757

5858
# # # # From the PEP440: Software version style rule
5959
# # #
@@ -77,7 +77,7 @@ declare Python_Version_Reg
7777
if [ "$Input_Arg_Release_Type" == 'python-package' ]; then
7878

7979
if [ "$Input_Arg_Python_Pkg_Name" == "" ]; then
80-
echo "The argument 'Input_Arg_Python_Pkg_Name' (second argument) cannot be empty if option 'Input_Arg_Release_Type' (first argument) is 'python-package'."
80+
echo "The argument 'Input_Arg_Python_Pkg_Name' (second argument) cannot be empty if option 'Input_Arg_Release_Type' (first argument) is 'python-package'."
8181
exit 1
8282
fi
8383

@@ -122,7 +122,7 @@ fi
122122

123123
# This is the global value to provide after-handle to use
124124
Current_Branch=$(git branch --list | cat | grep -E '\* ([a-zA-Z0-9]{1,16})' | grep -E -o '([a-zA-Z0-9]{1,16})')
125-
echo "Current git branch: $Current_Branch"
125+
echo "🔎 🌳 Current git branch: $Current_Branch"
126126

127127

128128
declare Tag_Version # This is the return value of function 'get_latest_version_by_git_tag'
@@ -131,14 +131,14 @@ get_latest_version_by_git_tag() {
131131
get_version_type=$1
132132

133133
if [ "$get_version_type" == "git" ]; then
134-
echo ""
134+
echo "🔎 🌳 🏷 Get the version info from git tag."
135135
Tag_Version=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -E -o '[0-9]\.[0-9]\.[0-9]*')
136136
elif [ "$get_version_type" == "github" ]; then
137-
echo ""
137+
echo "🔎 🐙 🐈 🏷 Get the version info from GitHub release."
138138
github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name')
139139
Tag_Version=$(echo "$github_release" | grep -E -o '[0-9]\.[0-9]\.[0-9]*')
140140
else
141-
echo ""
141+
echo "❌ Currently, it only has 2 valid options could use: 'git' or 'github'."
142142
exit 1
143143
fi
144144
}
@@ -149,14 +149,14 @@ declare New_Release_Tag # This is the return value of function 'generate_new_
149149
generate_new_version_as_tag() {
150150
project_type=$1
151151
if [ "$project_type" == "python" ]; then
152-
echo ""
152+
echo "🔎 🐍 📦 Get the new version info from Python package."
153153
New_Release_Version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg")
154154
elif [ "$project_type" == "github-action_reusable-workflow" ]; then
155-
echo ""
155+
echo "🔎 🐙 🐈 🏷 Get the current version info from GitHub release."
156156
# Generate the new version from previous tag
157157
get_latest_version_by_git_tag 'github'
158158
current_ver=$(echo "$Tag_Version" | head -n1 | cut -d "." -f1)
159-
echo "current_ver: $current_ver"
159+
echo "🔎 📃 Current Version: $current_ver"
160160

161161
# current_ver=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]" | grep -E -o '[0-9]\.[0-9]\.[0-9]' | head -n1 | cut -d "." -f1)
162162
if [ "$current_ver" == "" ]; then
@@ -178,53 +178,53 @@ build_git_tag_or_github_release() {
178178
generate_new_version_as_tag "$project_type"
179179

180180
if [ "$Input_Arg_Debug_Mode" == true ]; then
181-
echo " 🔍👀[DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'."
181+
echo " 🔍👀 [DEBUG MODE] Build git tag $New_Release_Tag in git branch '$Current_Branch'."
182182
else
183183
git tag -a "$New_Release_Tag" -m "$New_Release_Tag"
184184
git push -u origin --tags
185185
fi
186+
echo "🎉 🍻 🌳 🏷 Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!"
186187

187-
echo "Build git tag which named '$New_Release_Tag' with current branch '$Current_Branch' successfully!"
188188
if [ "$Current_Branch" == "master" ]; then
189189
release_title=$(cat .github/release-title.md)
190190

191191
if [ "$Input_Arg_Debug_Mode" == true ]; then
192-
echo " 🔍👀[DEBUG MODE] Create GitHub release with tag '$New_Release_Tag' and title '$release_title' in git branch '$Current_Branch'."
192+
echo " 🔍👀 [DEBUG MODE] Create GitHub release with tag '$New_Release_Tag' and title '$release_title' in git branch '$Current_Branch'."
193193
else
194194
gh release create "$New_Release_Tag" --title "$release_title" --notes-file .github/release-notes.md
195195
fi
196-
197-
echo "Create GitHub release with title '$release_title' successfully!"
198196
fi
197+
echo "🎉 🍻 🐙 🐈 🏷 Create GitHub release with title '$release_title' successfully!"
199198
}
200199

201200

202201
# The truly running implementation of shell script
203202
if [ "$Input_Arg_Release_Type" == 'python-package' ]; then
204203

205204
# # # # For Python package release
206-
echo 'do python package release'
205+
echo "🏃‍♂ ️🐍 𝌚 Run python package releasing process"
207206

208207
git_tag=$(git describe --tag --abbrev=0 --match "v[0-9]\.[0-9]\.[0-9]*" | grep -o '[0-9]\.[0-9]\.[0-9]*')
209208
github_release=$(curl -s https://api.github.com/repos/Chisanan232/GitHub-Action_Workflow-Template-Python/releases/latest | jq -r '.tag_name')
210209
# shellcheck disable=SC2002
211-
pkg_version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg")
210+
generate_new_version_as_tag "python"
211+
# pkg_version=$(cat ./"$Input_Arg_Python_Pkg_Name"/__pkg_info__.py | grep -E "$Python_Version_Reg" | grep -E -o "$Software_Version_Reg")
212212

213213
build_git_tag=false
214214
create_github_release=false
215215

216216
# 1. Compare the Python source code version and git tag, GitHub release version.
217-
if [ "$pkg_version" == "$git_tag" ]; then
218-
echo "Version of git tag info are the same. So it verifies it has built and pushed before."
217+
if [ "$New_Release_Version" == "$git_tag" ]; then
218+
echo "Version of git tag info are the same. So it verifies it has built and pushed before."
219219
else
220-
echo "Version of git tag info are different. So it verifies it doesn't build and push before."
220+
echo "⚠️ Version of git tag info are different. So it verifies it doesn't build and push before."
221221
build_git_tag=true
222222
fi
223223

224-
if [ "$Current_Branch" == "master" ] && [ "$pkg_version" == "$github_release" ]; then
225-
echo "Version of GitHub release info are the same. So it verifies it has built and pushed before."
224+
if [ "$Current_Branch" == "master" ] && [ "$New_Release_Version" == "$github_release" ]; then
225+
echo "Version of GitHub release info are the same. So it verifies it has built and pushed before."
226226
else
227-
echo "Version of GitHub release info are different. So it verifies it doesn't build and push before."
227+
echo "⚠️ Version of GitHub release info are different. So it verifies it doesn't build and push before."
228228
create_github_release=true
229229
fi
230230

@@ -239,37 +239,37 @@ if [ "$Input_Arg_Release_Type" == 'python-package' ]; then
239239

240240
if [ "$build_git_tag" == true ] || [ "$create_github_release" == true ]; then
241241

242-
echo "pkg_version: $pkg_version"
242+
echo "🔎 🐍 📦 Python package new release version: $New_Release_Version"
243243
# is_pre_release_version=$(echo $pkg_version | sed -n 's/.*\([a-zA-Z][0-9]*\)/\1/p')
244-
is_pre_release_version=$(echo $pkg_version | grep -E -o '([\.-]*([a-zA-Z]{1,})+([0-9]{0,})*){1,}')
245-
echo "is_pre_release_version: $is_pre_release_version"
244+
is_pre_release_version=$(echo $New_Release_Version | grep -E -o '([\.-]*([a-zA-Z]{1,})+([0-9]{0,})*){1,}')
245+
echo "🔎 🤰 📦 is pre-release version: $is_pre_release_version"
246246
if [ "$is_pre_release_version" == "" ]; then
247-
echo "The version is not a pre-release."
247+
echo "🎓 🐍 📦 The version is a official-release."
248248
# do different things with different ranches
249249
# git event: push
250250
# all branch -> Build tag
251251
# master branch -> Build tag and create release
252-
echo "build tag and create GitHub release, also push code to PyPi"
252+
echo "👷🏽‍♂️ 📌 Build tag and create GitHub release, also push code to PyPi"
253253
build_git_tag_or_github_release "python"
254-
echo "Done! This is Official-Release so please push source code to PyPi."
254+
echo "✅ 🎊 🥂 Done! This is Official-Release so please push source code to PyPi."
255255
echo "[Python] [Final Running Result] Official-Release"
256256
else
257257
echo "The version is a pre-release."
258258
# do different things with different ranches
259259
# git event: push
260260
# all branch -> Build tag
261261
# master branch -> Build tag and create release
262-
echo "build tag and create GitHub release only"
262+
echo "👷🏽‍♂ ️📌 Build tag and create GitHub release only"
263263
build_git_tag_or_github_release "python"
264-
echo "Done! This is Pre-Release so please don't push this to PyPi."
264+
echo "✅ 🎊 🥂 Done! This is Pre-Release so please don't push this to PyPi."
265265
echo "[Python] [Final Running Result] Pre-Release"
266266
fi
267267

268268
fi
269269

270270
elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then
271271

272-
echo 'do github-action-reusable-workflow release'
272+
echo "🏃‍♂ 🐙 🐈 𝌚 Run github-action-reusable-workflow releasing process"
273273
# # # # For GitHub Action reusable workflow template release
274274
# 1. Compare whether the release-notes.md has different or not.
275275
# Note 1: Diff a specific file with currently latest tag and previous one commit
@@ -280,28 +280,28 @@ elif [ "$Input_Arg_Release_Type" == 'github-action-reusable-workflow' ]; then
280280
# Note 4: We should git fetch to provide git diff feature working
281281
# https://github.com/actions/checkout/issues/160
282282

283-
echo "Run git fetch to sync upstream with latest project in GitHub"
283+
echo "🌳 ⛓ 🌳 Run git fetch to sync upstream with latest project in GitHub"
284284
git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
285285

286-
echo "Verify all the git branch info again after git fetch."
286+
echo "🔎 🌳 🌳 Verify all the git branch info again after git fetch."
287287
git branch -a | cat
288288

289-
echo "Verify the git remote info again after git fetch."
289+
echo "🔎 🔗 🌳 Verify the git remote info again after git fetch."
290290
git remote -v
291291

292-
echo "Check the different between current git branch and master branch."
292+
echo "🔬 📄 🌳 ⛓ 🌳 Check the different of '.github/release-notes.md' between current git branch and master branch ..."
293293
release_notes_has_diff=$(git diff origin/master "$Current_Branch" -- .github/release-notes.md | cat)
294-
echo "release_notes_has_diff: $release_notes_has_diff"
294+
echo "🔎 🔬 📄 different of '.github/release-notes.md': $release_notes_has_diff"
295295

296296
if [ "$release_notes_has_diff" != "" ]; then
297297
# 1. Yes, it has different. -> Build git tag, GitHub release and version branch
298298
build_git_tag_or_github_release "github-action_reusable-workflow"
299-
echo "Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it."
299+
echo "✅ 🎊 🥂 Done! This is Official-Release of GitHub Action reusable workflow, please create a version branch of it."
300300
echo "[GitHub Action - Reusable workflow] [Final Running Result] Official-Release and version: $New_Release_Version"
301301
else
302302
# 1. No, do nothing.
303303
# Return nothing output
304-
echo "Release note file doesn't change. Don't do anything."
304+
echo "💤 Release note file doesn't change. Don't do anything."
305305
echo "[GitHub Action - Reusable workflow] [Final Running Result] Pre-Release"
306306
fi
307307

0 commit comments

Comments
 (0)