Skip to content

Commit 7745199

Browse files
committed
✨ Also add tag during bump_version
1 parent aa3aea9 commit 7745199

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

bump_version.sh

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
# Simple utility to bump the version and commit the change (locally).
44
#
55
# @param $1 New version number to bump to.
6+
# @param $2 (optional) Extra string to add as a tag suffix.
67

78
# Validate input.
8-
if [[ ! "$1" =~ ^[0-9\.]+$ ]]; then
9+
if [[ "$#" -lt 1 || "$#" -gt 2 ]] || [[ ! "$1" =~ ^[0-9\.]+$ ]]; then
910
echo "Invalid params."
10-
echo "Usage: $(basename $0) <version>, e.g. $(basename $0) 1.0.2"
11+
echo "Usage: $(basename $0) <version> [<tag-suffix>], e.g. $(basename $0) 1.0.2 rc1"
1112
exit 1
1213
fi
1314

@@ -17,7 +18,19 @@ cd "$(dirname ${BASH_SOURCE[0]})"
1718
# Load common methods to call.
1819
source ./git_utils
1920

20-
init_safe "About to bump version to $1 and commit locally."
21+
init_safe "About to bump version to $1 and commit locally. Any existing tag will be overwritten."
2122

2223
echo;
2324
perform_version_bump "$1" "${PWD}"
25+
26+
tag_string=''
27+
if [ "$2" ]; then
28+
tag_string="v$1-$2"
29+
else
30+
tag_string="v$1"
31+
fi
32+
33+
git tag -f "${tag_string}"
34+
35+
echo;
36+
echo 'Done.'

git_utils

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ init_safe() {
2424
# @see init_safe()
2525
init_with_warning() {
2626
echo 'Note: Please stash before continuing. Any existing changes will be lost.'
27-
echo 'Note: This is a destructive action! It will delete the online branch.'
27+
echo 'Note: This is a destructive action! It will overwrite the online branch.'
2828
echo;
2929

3030
init_safe $1

git_utils.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ GIT_ALLOW_PUSH_TO_MASTER=false
1111
# @param $1 version name to update to.
1212
# @param $2 root directory of project.
1313
perform_version_bump() {
14+
# Save the version number in a config file called 'example'.
1415
echo "$1" > "$2/example.cfg"
1516

1617
# Commit the change.

0 commit comments

Comments
 (0)