-
Notifications
You must be signed in to change notification settings - Fork 19
/
bump-version.sh
executable file
·46 lines (40 loc) · 1.48 KB
/
bump-version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# credit goes to @pete-otaqui for initial gist:
# https://gist.github.com/pete-otaqui/4188238
# original version modified for pidrone_pkg releases
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3"
# this script will display the current version, automatically
# suggest a "minor" version update, and ask for input to use
# the suggestion, or a newly entered value.
# once the new version number is determined, the script will
# pull a list of changes from git history, prepend this to
# a file called CHANGES (under the title of the new version
# number) and create a GIT tag.
if [ -f VERSION ]; then
BASE_STRING=`cat VERSION`
BASE_LIST=(`echo $BASE_STRING | tr '.' ' '`)
V_MAJOR=${BASE_LIST[0]}
V_MINOR=${BASE_LIST[1]}
echo "Current version : $BASE_STRING"
if [ $V_MINOR -eq 5 ]; then
V_MINOR=0
fi
V_MAJOR=$((V_MAJOR + 1))
SUGGESTED_VERSION="$V_MAJOR.$V_MINOR"
read -p "Enter a version number [$SUGGESTED_VERSION]: " INPUT_STRING
if [ "$INPUT_STRING" = "" ]; then
INPUT_STRING=$SUGGESTED_VERSION
fi
echo "Will set new version to be $INPUT_STRING"
echo $INPUT_STRING > VERSION
git add VERSION
git commit -m "Version bump to $INPUT_STRING"
git tag -a -m "Tagging version $INPUT_STRING" "v$INPUT_STRING"
git push
git push origin master:develop
git push origin --tags
else
echo "Could not find a VERSION file"
fi