-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnext_release.sh
More file actions
executable file
·43 lines (37 loc) · 926 Bytes
/
next_release.sh
File metadata and controls
executable file
·43 lines (37 loc) · 926 Bytes
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
#!/bin/bash
# This simple script gets the current release and increments the release number.
# Abort on an error
set -e
die () {
echo >&2 "$@"
exit 1
}
if [ "$1" != "Major" ] && [ "$1" != "Minor" ] && [ "$1" != "Patch" ]; then
die "Only accepts Major, Minor or Patch as argument."
fi
### Increments the part of the string
## $1: version itself
## $2: number of part: 0 – major, 1 – minor, 2 – patch
increment_version() {
major=`echo "$1" | cut -d "." -f 1`
minor=`echo "$1" | cut -d "." -f 2`
patch=`echo "$1" | cut -d "." -f 3`
case "$2" in
"Major")
major=$((major + 1))
minor=0
patch=1
;;
"Minor")
minor=$((minor + 1))
patch=1
;;
"Patch")
patch=$((patch + 2))
;;
esac
echo "$major.$minor.$patch-SNAPSHOT"
}
LATEST_RELEASE=`git describe --abbrev=0 --tags`
NEW_RELEASE=`increment_version $LATEST_RELEASE $1`
echo $NEW_RELEASE