-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease
executable file
·60 lines (52 loc) · 1.65 KB
/
release
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
#!/bin/sh -e
run(){
echo "***************"
echo " Release v.$1"
echo "***************"
# create local branch
echo "> Creating $1 branch ..."
git checkout -b $1
# set branch release version
echo "> Building v.$1 ..."
mvn versions:set -DnewVersion="$1" > /dev/null 2>&1
mvn clean package -Pdeb -Prelease -DskipTests > /dev/null 2>&1
git commit -a -m "release v.$1"
echo "> Pushing $1 branch ..."
git push --set-upstream origin $1
# change to master branch
echo "> Creating v.$2 for development ..."
git checkout master
# set development version
mvn versions:set -DnewVersion="$2" > /dev/null 2>&1
git commit -a -m "prepare to develop v.$2"
echo "> Pushing origin/master ..."
git push origin master
git branch --set-upstream-to origin/master
# cleanup
find -name "*.versionsBackup"| xargs -I file rm file
}
release_version=$(grep -oP '(?<=<version>).*(?=</version>)' pom.xml|sed -n "1p"|grep -oE "[0-9\.]+")
mayor_version=$( echo $release_version | grep -Eo "(^[0-9]*)" )
mid_version=$( echo $release_version | grep -Eo "(\.)[0-9]*(\.)" | grep -Eo "[0-9]*" )
minor_version=$( echo $release_version | grep -Eo "([0-9]*$)" )
if [ $release_version = 1.0.0 ]; then
run "1.0.0" "1.0.1-SNAPSHOT"
exit 0
fi
case $1 in
mayor)
mayor_version=$(( mayor_version + 1 ))
mid_version=0
minor_version=0
;;
mid)
mid_version=$(( mid_version + 1 ))
minor_version=0
;;
minor)
;;
*)
mid_version=$(( mid_version + 1 ))
minor_version=0
esac
run "$mayor_version.$mid_version.$minor_version" "$mayor_version.$mid_version.$(( minor_version + 1 ))-SNAPSHOT"