-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnext_dev_version.sh
More file actions
executable file
·69 lines (59 loc) · 1.71 KB
/
next_dev_version.sh
File metadata and controls
executable file
·69 lines (59 loc) · 1.71 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/sh
set -euxo pipefail
# preflight checks
case "$1" in
"-p")
echo "Product Release Preparation"
;;
"-c")
echo "Community Release Preparation"
;;
*)
echo "Usage: next_dev_version.sh <-p|-c>"
exit 1
;;
esac
version=`../current_version.sh $1`
cleaned_version=`echo $version | sed -e 's/[^0-9][^0-9]*$//'`
function advance_version () {
local v=$1
# Get the last number. First remove any suffixes (such as '-SNAPSHOT').
local cleaned=`echo $v | sed -e 's/[^0-9][^0-9]*$//'`
local last_num=`echo $cleaned | sed -e 's/[0-9]*\.//g'`
local next_num=$(($last_num+1))
# Finally replace the last number in version string with the new one.
echo $v | sed -e "s/[0-9][0-9]*\([^0-9]*\)$/$next_num/"
}
function advance_version_rh () {
local v=$1
# Get the last number. First remove any suffixes (such as '-SNAPSHOT').
local cleaned=`echo $v | sed -e 's/[^0-9][^0-9]*$//'`
local last_num=`echo $cleaned | sed -e 's/[0-9]*\.[0-9]*\.[0-9]*-redhat-*//g'`
local next_num=$(($last_num+1))
# Finally replace the last number in version string with the new one.
echo $v | sed -e "s/[0-9][0-9]*\([^0-9]*\)$/$next_num/"
}
case "$1" in
"-p")
new_version=$(advance_version_rh $version)
;;
"-c")
new_version=$(advance_version $version)
;;
esac
echo "$cleaned_version -> $new_version"
# update version
case "$1" in
"-p")
# -i fails on mac os
sed "s/$cleaned_version/$new_version/g" pom-redhat.xml > pom.tmp && mv pom.tmp pom-redhat.xml
;;
"-c")
snapshot="$new_version-SNAPSHOT"
echo $snapshot
mvn versions:set -DnewVersion=$snapshot
;;
esac
# perform tests
mvn clean install
git commit -a -m "Next development version"