-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.bat
136 lines (134 loc) · 2.84 KB
/
release.bat
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
@ECHO off
@ECHO.
SET PUBLISH_SITE=true
if [%1]==[] goto usage
if [%1]==[-frb] goto :forced-rollback
if [%1]==[-mrb] goto :maven-rollback
if [%1]==[-nosite] (
SET PUBLISH_SITE=false
shift
)
SET firstArg=%1
if [%firstArg:~,1%]==[-] goto :wrong-tag
if [%2]==[] goto usage
if NOT [%3]==[] goto usage
@ECHO.
@ECHO.
@ECHO **** GOING TO RELEASE WITH TAG %1
@ECHO.
@ECHO.
@ECHO Preparing release...
@ECHO.
@ECHO on
CALL mvn -DpushChanges=false release:clean release:prepare
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
@ECHO.
@ECHO.
@ECHO Pushing to %2...
@ECHO.
@ECHO on
git push origin %2
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
@ECHO.
@ECHO Pushing tag %1 to repository...
@ECHO on
git push origin %1
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
@ECHO.
@ECHO Performing release...
@ECHO.
@echo on
CALL mvn -Dhttps.protocols=SSLv3 -Dforce.http.jre.executor=true -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true release:perform
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
@ECHO.
@ECHO Done.
IF "%PUBLISH_SITE%" == "true" goto :website
GOTO :eof
:website
@ECHO.
@ECHO Generating site with Josman...
@echo on
CALL mvn josman:site
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
@ECHO.
@ECHO Sending website to Github pages... (this may take some time)
@echo on
CALL mvn com.github.github:site-maven-plugin:site
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
@ECHO.
@ECHO Done.
GOTO :eof
:forced-rollback
if [%2]==[] goto usage
if NOT [%3]==[] goto usage
@ECHO.
@ECHO.
@ECHO ******* FORCING ROLLING BACK OF MESSED UP RELEASE %2....
@ECHO.
@ECHO.
@ECHO.
@ECHO Removing pom.xml.releaseBackup ...
DEL pom.xml.releaseBackup
@ECHO Removing release.properties
DEL release.properties
@ECHO.
@ECHO.
@ECHO Removing local tag %2 ...
@echo on
git tag -d %2
@echo off
@ECHO Removing github tag %2 ...
@ECHO on
@ECHO.
git push origin :refs/tags/%2
@ECHO. off
@ECHO Now you may need to do a
@ECHO.
@ECHO git reset --hard X
@ECHO.
@ECHO Where X is the commit SHA of the commit you want to rollback to.
@ECHO.
@ECHO **** CAREFUL: USING GIT RESET HARD WITH WRONG COMMIT WILL MAKE YOU LOSE ALL SUBSEQUENT COMMITS!!!!! *****
@ECHO.
GOTO :eof
:maven-rollback
if NOT [%2]==[] goto usage
@ECHO.
@ECHO.
@ECHO ******* REGULAR MAVEN ROLLABACK....
@ECHO.
@ECHO.
@ECHO on
CALL mvn release:rollback
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO on
CALL mvn release:clean
@ECHO off
if %errorlevel% neq 0 exit /b %errorlevel%
@ECHO.
GOTO :eof
:usage
@ECHO Usage:
@ECHO.
@ECHO Do complete release: %0 [-nosite] ^<mytag-x.y.z^> ^<branch^>
@ECHO.
@ECHO Regular maven rollback: %0 -mrb
@ECHO.
@ECHO Forced cleaning (only if maven rollback fails): %0 -frb ^<mytag-x.y.z^>
@ECHO.
EXIT /B 1
:wrong-tag
@ECHO Provided tag is wrong!