Skip to content

Commit c38d2de

Browse files
committed
[#3731] bump-lib-versions.sh: Automatically determine old version and assume new version
1 parent 5e33073 commit c38d2de

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

tools/bump-lib-versions.sh

+15-13
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# License, v. 2.0. If a copy of the MPL was not distributed with this
77
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
88

9-
# Usage:
10-
#
11-
# ./tools/bump-lib-versions.sh Kea-1.9.1 Kea-1.9.2
12-
139
set -eu
1410

1511
# Define some ANSI color codes.
@@ -26,12 +22,12 @@ fi
2622
# shellcheck disable=SC2016
2723
print_usage() {
2824
printf \
29-
'Usage: %s {{options}} $old_release_tag $new_release_tag
25+
'Usage: %s {{options}} [$new_release_tag]
3026
Options:
3127
[-d|--debug] enable debug mode, showing every executed command
3228
[-h|--help] print usage (this text)
3329
Example:
34-
./tools/bump_lib_versions.sh Kea-1.9.1 Kea-1.9.2
30+
./tools/bump_lib_versions.sh Kea-1.2.3
3531
' \
3632
"$(basename "${0}")"
3733
}
@@ -52,20 +48,13 @@ while test ${#} -gt 0; do
5248
'-h'|'--help') print_usage; exit 0 ;;
5349

5450
*)
55-
test -z "${old_release_tag+x}" && old_release_tag=${1} && shift && continue
5651
test -z "${new_release_tag+x}" && new_release_tag=${1} && shift && continue
5752

5853
# Unrecognized argument
5954
error "Unrecognized argument '${1}'" ;;
6055
esac; shift
6156
done
6257

63-
# Check for mandatory arguments.
64-
# Expressions don't expand in single quotes, use double quotes for that. [SC2016]
65-
# shellcheck disable=SC2016
66-
test -z "${old_release_tag+x}" && error '$old_release_tag is mandatory'
67-
# shellcheck disable=SC2016
68-
test -z "${new_release_tag+x}" && error '$new_release_tag is mandatory'
6958

7059
is_stable_release() {
7160
version_number=$(printf '%s' "${1}" | cut -d . -f2)
@@ -86,6 +75,19 @@ find_latest_stable_release_tag() {
8675
done
8776
}
8877

78+
old_release_tag=$(git describe --tags HEAD | grep -Eo 'Kea-[0-9]+\.[0-9]+\.[0-9]+')
79+
if test -z "${new_release_tag+x}"; then
80+
patch_version=$(echo "${old_release_tag}" | grep -Eo '[0-9]+$')
81+
patch_version=$((patch_version + 1))
82+
new_release_tag=$(echo "${old_release_tag}" | sed "s/.[0-9]*$/.${patch_version}/")
83+
printf 'No version provided. Assuming that the target version is "%s".' "${new_release_tag}"
84+
if test -t 1; then
85+
printf ' Press any key to continue... '
86+
read -r _
87+
fi
88+
printf '\n'
89+
fi
90+
8991
is_old_tag_stable_release=$(is_stable_release "${old_release_tag}" && printf true || printf false)
9092
is_new_tag_stable_release=$(is_stable_release "${new_release_tag}" && printf true || printf false)
9193

0 commit comments

Comments
 (0)