-
Notifications
You must be signed in to change notification settings - Fork 0
/
release
executable file
·149 lines (134 loc) · 3.16 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
echo
echo
echo
echo " ******************************** TOD RELEASER ***************************************"
PUBLISH_SITE=true
function usage(){
echo "
Usage:
Do complete release: release [-nosite] ^<mytag-x.y.z^> ^<branch^>
Regular maven rollback: release -mrb
Forced cleaning (only if maven rollback fails): release -frb ^<mytag-x.y.z>^
"
exit 1
}
function website(){
echo
echo "******* TOD RELEASER: Generating site with Josman..."
echo on
mvn josman:site
if [ $? -ne 0 ]; then echo "command failed"; exit 1; fi
echo off
echo
echo
echo "Sending website to Github pages... (this may take some time)"
echo on
mvn com.github.github:site-maven-plugin:site
if [ $? -ne 0 ]; then echo "command failed"; exit 1; fi
echo off
echo
echo
echo Done.
exit
}
# first parameter is something like TAGNAME-X.Y.Z
function forcedRollback(){
if [ -z $1 ]; then usage; fi
echo
echo
echo "******* TOD RELEASER: FORCING ROLLING BACK OF MESSED UP RELEASE $2...."
echo
echo
echo
echo Removing pom.xml.releaseBackup ...
rm pom.xml.releaseBackup
echo Removing release.properties
rm release.properties
echo
echo
echo Removing local tag $1 ...
echo on
git tag -d $1
echo off
echo Removing github tag $1 ...
echo on
echo
git push origin :refs/tags/$1
echo off
echo Now you may need to do:
echo
echo " git reset --hard X "
echo
echo Followed by
echo
echo " git push -f origin BRANCH"
echo
echo "Where X is the commit SHA of the commit you want to rollback to. "
echo "Where BRANCH is the branch name (i.e. master or jackan-0.4 )"
echo
echo "******* TOD RELEASER: CAREFUL: USING GIT RESET HARD WITH WRONG COMMIT WILL MAKE YOU LOSE ALL SUBSEQUENT COMMITS!!!!! *****"
echo
exit
}
function mavenRollback(){
if [[ -n $2 ]]; then usage; fi
echo
echo
echo "******* TOD RELEASER: REGULAR MAVEN ROLLABACK...."
echo
echo
echo on
mvn release:rollback
if [ $? -ne 0 ]; then echo "command failed"; exit 1; fi
echo on
mvn release:clean
echo off
if [ $? -ne 0 ]; then echo "command failed"; exit 1; fi
echo
exit
}
function wrongTag(){
echo "******* TOD RELEASER: PROVIDED TAG IS WRONG!"
exit 1
}
echo
if [[ -z $1 ]]; then usage; fi
if [ $1 = "-frb" ]; then forcedRollback $2; fi
if [ $1 = "-mrb" ]; then mavenRollback; fi
if [ $1 = "-nosite" ]; then
PUBLISH_SITE=false
shift
fi
firstArg=$1
if [ ${firstArg:0:1} = "-" ]; then wrongTag; fi
if [[ -z $2 ]]; then usage; fi
if [[ -n $3 ]]; then usage; fi
echo
echo
echo "****** TOD RELEASER: GOING TO RELEASE WITH TAG $1 "
echo
echo
echo "****** TOD RELEASER: PREPARING RELEASE..."
echo
echo on
mvn release:clean release:prepare
if [ $? -ne 0 ]; then echo "command failed"; exit 1; fi
echo off
echo
echo
echo
echo "****** TOD RELEASER: PERFORMING RELEASE..."
echo
echo on
mvn -Dhttps.protocols=SSLv3 -Dforce.http.jre.executor=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true release:perform
if [ $? -ne 0 ]; then echo "command failed"; exit 1; fi
echo off
echo
echo
echo "****** TOD RELEASER: DONE ."
echo
echo
echo
if [ $PUBLISH_SITE = "true" ]; then website; fi
exit