9
9
#
10
10
# This script will:
11
11
#
12
- # Install the necessary tools ( jq , gh , semver )
12
+ # Install the necessary tools (npm and system dependencies[git, curl, jq])
13
13
# Get the commit type
14
14
# Get the equivalent version increment
15
15
# Get the latest version
@@ -89,13 +89,12 @@ install_tools() {
89
89
get_version_increment () {
90
90
local feature_name=$( basename $feature )
91
91
local last_tag=$( git describe --tags --abbrev=0)
92
- local previous_tag=$( git describe --tags --abbrev=0 $last_tag ^)
93
- local commit_types=$( git log --pretty=%B $previous_tag ..$last_tag -- src/$feature_name | grep -oE ' ^(feat|fix|BREAKING CHANGE)' )
94
- if echo $commit_types | grep -q ' BREAKING CHANGE' ; then
92
+ local commit_messages=$( git log --pretty=format:" %s%n%n%b" $last_tag ..HEAD -- src/$feature_name )
93
+ if echo " $commit_messages " | grep -qE ' BREAKING CHANGE' ; then
95
94
echo ' major'
96
- elif echo $commit_types | grep -q ' feat' ; then
95
+ elif echo " $commit_messages " | grep -qE ' ^ feat(\(.+\))?: ' ; then
97
96
echo ' minor'
98
- elif echo $commit_types | grep -q ' fix' ; then
97
+ elif echo " $commit_messages " | grep -qE ' ^ fix(\(.+\))?: ' ; then
99
98
echo ' patch'
100
99
else
101
100
echo ' '
@@ -111,7 +110,8 @@ get_latest_version() {
111
110
if [ -z " $tags " ]; then
112
111
echo $DEFAULT_VERSION
113
112
else
114
- echo $tags | tr ' ' ' \n' | sort -V | tail -n 1
113
+ # Filter out non-numeric tags, sort the remaining tags, and select the last one
114
+ echo $tags | tr ' ' ' \n' | grep -E ' ^[0-9]+\.[0-9]+\.[0-9]+$' | sort -V | tail -n 1
115
115
fi
116
116
}
117
117
@@ -240,14 +240,13 @@ main() {
240
240
for feature in src/* ; do
241
241
feature_name=$( basename $feature )
242
242
echo
243
- log_info " ℹ️ Checking if files in $feature_name were changed in the last tag..."
244
243
last_tag=$( git describe --tags --abbrev=0)
245
- previous_tag= $( git describe --tags --abbrev=0 $last_tag ^ )
246
- if ! git diff --name-only $previous_tag $last_tag | grep -q " $feature_name " ; then
247
- log_info " No changes for $feature_name in the last tag . Skipping version bump."
244
+ log_info " ℹ️ [\033[1;36m $feature_name \033[0m] \033[1;32m[ $last_tag ]\033[0m Checking for diffs... "
245
+ if ! git diff --name-only $last_tag ..HEAD -- $feature_name | grep -q " $feature_name " ; then
246
+ log_info " No changes detected . Skipping version bump."
248
247
continue
249
248
fi
250
- log_warn " OK. Changes found for $feature in the last tag."
249
+ log_warn " OK. Changes found for $feature in the current tag."
251
250
252
251
log_info " ℹ️ Getting version increment..."
253
252
version_increment=$( get_version_increment)
0 commit comments