forked from geoserver/geoserver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_release.sh
executable file
·378 lines (314 loc) · 8.66 KB
/
build_release.sh
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
#!/bin/bash
# error out if any statements fail
set -e
#set -x
function usage() {
echo "$0 [options] <tag> <user> <email>"
echo
echo " tag : Release tag (eg: 2.1.4, 2.2-beta1, ...)"
echo " user: Git username"
echo " email: Git email"
echo
echo "Options:"
echo " -h : Print usage"
echo " -b <branch> : Branch to release from (eg: trunk, 2.1.x, ...)"
echo " -r <rev> : Revision to release (eg: 12345)"
echo " -g <ver> : GeoTools version/revision (eg: 2.7.4, trunk:12345)"
echo " -w <ver> : GeoWebCache version/revision (eg: 1.3-RC1, stable:abcd)"
echo
echo "Environment variables:"
echo " SKIP_BUILD : Skips main release build"
echo " SKIP_INSTALLERS : Skips building of mac and windows installers"
echo " SKIP_GT : Skips the GeoTools build"
echo " SKIP_GWC : Skips the GeoWebCache build"
}
# parse options
while getopts "hb:r:g:w:" opt; do
case $opt in
h)
usage
exit
;;
b)
branch=$OPTARG
;;
r)
rev=$OPTARG
;;
g)
gt_ver=$OPTARG
;;
w)
gwc_ver=$OPTARG
;;
\?)
usage
exit 1
;;
:)
echo "Option -$OPTARG requires an argument"
exit 1
;;
esac
done
# clear options to parse main arguments
shift $(( OPTIND -1 ))
tag=$1
git_user=$2
git_email=$3
# sanity check
if [ -z $tag ] || [ -z $git_user ] || [ -z $git_email ] || [ ! -z $4 ]; then
usage
exit 1
fi
# load properties + functions
. "$( cd "$( dirname "$0" )" && pwd )"/properties
. "$( cd "$( dirname "$0" )" && pwd )"/functions
# more sanity checks
if [ `is_version_num $tag` == "0" ]; then
echo "$tag is a not a valid release tag"
exit 1
fi
if [ `is_primary_branch_num $tag` == "1" ]; then
echo "$tag is a not a valid release tag, can't be same as primary branch name"
exit 1
fi
echo "Building release with following parameters:"
echo " branch = $branch"
echo " revision = $rev"
echo " tag = $tag"
echo " geotools = $gt_ver"
echo " geowebcache = $gwc_ver"
echo "maven/java settings:"
mvn -version
# move to root of source tree
pushd .. > /dev/null
# clear out any changes
git reset --hard HEAD
# checkout and update primary branch
git checkout $branch
git pull origin $branch
# check to see if a release branch already exists
set +e && git checkout rel_$tag && set -e
if [ $? == 0 ]; then
# release branch already exists, kill it
git checkout $branch
echo "branch rel_$tag exists, deleting it"
git branch -D rel_$tag
fi
# checkout the branch to release from
git checkout $branch
# ensure the specified revision actually on this branch
if [ $rev != "HEAD" ]; then
set +e
git log | grep $rev
if [ $? != 0 ]; then
echo "Revision $rev not a revision on branch $branch"
exit -1
fi
set -e
fi
# create a release branch
git checkout -b rel_$tag $rev
# generate release notes
jira_id=`get_jira_id $tag`
if [ -z $jira_id ]; then
echo "Could not locate release $tag in JIRA"
exit -1
fi
echo "jira id = $jira_id"
# update README
#search?jql=project+%3D+%22GEOS%22+and+fixVersion+%3D+%222.2-beta2%22"
# setup geotools and geowebcache dependencies
if [ -z $SKIP_GT ]; then
if [ ! -z $gt_ver ]; then
# deterine if this is a revision or version number
if [ "`is_version_num $gt_ver`" == "1" ]; then
gt_tag=$gt_ver
fi
# if version specified as branch/revision check it out
if [ -z $gt_tag ]; then
arr=(${gt_ver//@/ })
if [ "${#arr[@]}" != "2" ]; then
echo "Bad version $gt_ver, must be specified as <branch>@<revision>"
exit 1
fi
gt_branch=${arr[0]}
gt_rev=${arr[1]}
gt_dir=build/geotools/$gt_branch/$gt_rev
if [ ! -e $gt_dir ]; then
echo "cloning geotools repo from $GT_GIT_URL"
git clone $GT_GIT_URL $gt_dir
fi
# checkout branch/rev
pushd $gt_dir > /dev/null
echo "checking out geotools ${gt_branch}@${gt_rev}"
git checkout $gt_rev
# build geotools
mvn clean install -DskipTests -Dall
popd > /dev/null
# derive the gt version
gt_tag=`get_pom_version $git_dir/pom.xml`
fi
fi
fi
if [ ! -z $gt_tag ]; then
echo "GeoTools version = $gt_tag"
fi
# setup geowebcache dependency
if [ -z $SKIP_GWC ]; then
if [ ! -z $gwc_ver ]; then
# deterine if this is a revision or version number
if [ "`is_version_num $gwc_ver`" == "1" ]; then
gwc_tag=$gwc_ver
fi
# if version specified as branch/revision check it out
if [ -z $gwc_tag ]; then
arr=(${gwc_ver//@/ })
if [ "${#arr[@]}" != "2" ]; then
echo "Bad version $gwc_ver, must be specified as <branch>:<revision>"
exit 1
fi
gwc_branch=${arr[0]}
gwc_rev=${arr[1]}
gwc_dir=build/geowebcache/$gwc_branch/$gwc_rev
if [ ! -e $gwc_dir ]; then
mkdir -p $gwc_dir
echo "checking out geowebache ${gwc_branch}@${gwc_rev}"
git clone $GWC_GIT_URL $gwc_dir
pushd $gwc_dir > /dev/null
git checkout $gwc_rev
popd > /dev/null
fi
# build geowebache
pushd $gwc_dir/geowebcache > /dev/null
mvn -o clean install -DskipTests
# derive the gwc version
gwc_tag=`get_pom_version pom.xml`
popd > /dev/null
fi
fi
fi
if [ ! -z $gwc_tag ]; then
echo "GeoWebCache version = $gwc_tag"
fi
# update geotools + geowebcache versions
if [ ! -z $gt_tag ]; then
sed -i "s/\(<gt.version>\).*\(<\/gt.version>\)/\1$gt_tag\2/g" src/pom.xml
else
# look up from pom instead
gt_tag=`cat src/pom.xml | grep "<gt.version>" | sed 's/ *<gt.version>\(.*\)<\/gt.version>/\1/g'`
fi
if [ ! -z $gwc_tag ]; then
sed -i "s/\(<gwc.version>\).*\(<\/gwc.version>\)/\1$gwc_tag\2/g" src/pom.xml
else
gwc_tag=`cat src/pom.xml | grep "<gwc.version>" | sed 's/ *<gwc.version>\(.*\)<\/gwc.version>/\1/g'`
fi
# update the release notes
notes=RELEASE_NOTES.txt
pushd src/release > /dev/null
sed -i "s/@VER@/$tag/g" $notes
sed -i "s/@DATE@/`date "+%b %d, %Y"`/g" $notes
sed -i "s/@JIRA_VER@/$jira_id/g" $notes
gt_ver_info=$gt_tag
if [ ! -z $gt_rev ]; then
gt_ver_info="$gt_ver_info, rev $gt_rev"
fi
gwc_ver_info=$gwc_tag
if [ ! -z $gwc_rev ]; then
gwc_ver_info="$gwc_ver_info, rev $gwc_rev"
fi
sed -i "s/@GT_VER@/$gt_ver_info/g" $notes
sed -i "s/@GWC_VER@/$gwc_ver_info/g" $notes
popd > /dev/null
# update version numbers
old_ver=`get_pom_version src/pom.xml`
echo "updating version numbers from $old_ver to $tag"
find src -name pom.xml -exec sed -i "s/$old_ver/$tag/g" {} \;
find doc -name conf.py -exec sed -i "s/$old_ver/$tag/g" {} \;
pushd src/release > /dev/null
sed -i "s/$old_ver/$tag/g" *.xml installer/win/*.nsi installer/win/*.conf installer/mac/GeoServer.app/Contents/Info.plist
popd > /dev/null
pushd src > /dev/null
# build the release
if [ -z $SKIP_BUILD ]; then
echo "building release"
mvn $MAVEN_FLAGS clean install -DskipTests -P release
# build the javadocs
mvn javadoc:aggregate
# build the user docs
pushd ../doc/en/user > /dev/null
make clean html
cd ../developer
make clean html
popd > /dev/null
fi
mvn $MAVEN_FLAGS assembly:attached
# copy over the artifacts
if [ ! -e $DIST_PATH ]; then
mkdir -p $DIST_PATH
fi
dist=$DIST_PATH/$tag
if [ -e $dist ]; then
rm -rf $dist
fi
mkdir $dist
mkdir $dist/plugins
artifacts=`pwd`/target/release
# bundle up mac and windows installer stuff
pushd release/installer/mac > /dev/null
zip -r $artifacts/geoserver-$tag-mac.zip *
popd > /dev/null
pushd release/installer/win > /dev/null
zip -r $artifacts/geoserver-$tag-win.zip *
popd > /dev/null
pushd $artifacts > /dev/null
# setup doc artifacts
if [ -e user ]; then
unlink user
fi
if [ -e developer ]; then
unlink developer
fi
ln -sf ../../../doc/en/user/build/html user
ln -sf ../../../doc/en/developer/build/html developer
htmldoc=geoserver-$tag-htmldoc.zip
if [ -e $htmldoc ]; then
rm -f $htmldoc
fi
zip -r $htmldoc user developer
unlink user
unlink developer
# clean up source artifact
if [ -e tmp ]; then
rm -rf tmp
fi
mkdir tmp
src=geoserver-$tag-src.zip
unzip -d tmp $src
pushd tmp > /dev/null
set +e && find . -type d -name target -exec rm -rf {} \; && set -e
rm ../$src
zip -r ../$src *
popd > /dev/null
popd > /dev/null
echo "copying artifacts to $dist"
cp $artifacts/*-plugin.zip $dist/plugins
for a in `ls $artifacts/*.zip | grep -v plugin`; do
cp $a $dist
done
# fire off mac and windows build machines
if [ -z $SKIP_INSTALLERS ]; then
echo "starting installer jobs"
start_installer_job $WIN_HUDSON $tag
start_installer_job $MAC_HUDSON $tag
fi
# git commit changes on the release branch
pushd .. > /dev/null
init_git $git_user $git_email
git add .
git commit -m "updating version numbers and release notes for $tag" .
popd > /dev/null
popd > /dev/null
echo "build complete, artifacts available at $DIST_URL/$tag"
exit 0