-
Notifications
You must be signed in to change notification settings - Fork 394
/
release.sh
executable file
·633 lines (460 loc) · 20.6 KB
/
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
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# set -e
# set -x
function fail {
>&2 echo "\033[31m
FATAL ERROR
-----------
$1
\033[0m"
exit 1
}
function getJavaVersionFromPom {
cat << EOF | xmllint --noent --shell pom.xml | grep content | cut -f2 -d=
setns pom=http://maven.apache.org/POM/4.0.0
xpath /pom:project/pom:properties/pom:maven.compiler.source/text()
EOF
}
function getProjectVersionFromPom {
cat << EOF | xmllint --noent --shell pom.xml | grep content | cut -f2 -d=
setns pom=http://maven.apache.org/POM/4.0.0
xpath /pom:project/pom:version/text()
EOF
}
function getJdkToolchain {
xmllint ~/.m2/toolchains.xml --xpath "/toolchains/toolchain[provides/version/text() = '$JAVA_VERSION']/configuration/jdkHome/text()"
}
function generate_promotion_script {
echo "Generating release promotion script 'promote-$version.sh'"
read -d '' script <<- EOF
#!/bin/bash
echo "Promoting release $version
Actions about to be performed:
------------------------------
\$(cat \$0 | tail -n +14)
------------------------------------------"
read -p "Press enter to continue or CTRL-C to abort"
# push the release tag to ASF git repo
git push origin $tag
# promote the source distribution by moving it from the staging area to the release area
svn mv https://dist.apache.org/repos/dist/dev/wicket/$version https://dist.apache.org/repos/dist/release/wicket -m "Upload release to the mirrors"
mvn org.sonatype.plugins:nexus-staging-maven-plugin:1.6.7:rc-release -DstagingRepositoryId=$stagingrepoid -DnexusUrl=https://repository.apache.org -DserverId=apache.releases.https -Ddescription="Release vote has passed"
# Renumber the next development iteration $next_version:
git checkout $GIT_BRANCH
mvn release:update-versions --batch-mode
mvn versions:set versions:commit -DnewVersion=$next_version
git add --all
echo "
Check the new versions and commit and push them to origin:
git commit -m \"Start next development version\"
git push
Remove the previous version of Wicket using this command:
svn rm https://dist.apache.org/repos/dist/release/wicket/$previous_version -m \\\"Remove previous version from mirrors\\\"
"
EOF
echo "$script" > promote-$version.sh
chmod +x promote-$version.sh
git add promote-$version.sh
}
function generate_rollback_script {
echo "Generating release rollback script 'revert-$version.sh'"
read -d '' script <<- EOF
#!/bin/bash
echo -n "Reverting release $version
Actions about to be performed:
------------------------------
\$(cat \$0 | tail -n +14)
------------------------------------------
Press enter to continue or CTRL-C to abort"
read
# clean up local repository
git checkout $GIT_BRANCH
git branch -D $branch
git tag -d $tag
# clean up staging repository
git push staging --delete refs/heads/$branch
git push staging --delete $tag
# clean up staging dist area
svn rm https://dist.apache.org/repos/dist/dev/wicket/$version -m "Release vote has failed"
# clean up staging maven repository
mvn org.sonatype.plugins:nexus-staging-maven-plugin:LATEST:rc-drop -DstagingRepositoryId=$stagingrepoid -DnexusUrl=https://repository.apache.org -DserverId=apache.releases.https -Ddescription="Release vote has failed"
# clean up remaining release files
find . -name "*.releaseBackup" -exec rm {} \\;
[ -f release.properties ] && rm release.properties
EOF
echo "$script" > revert-$version.sh
chmod +x revert-$version.sh
git add revert-$version.sh
}
function generate_signatures_from_release {
echo "========================================================================
CHANGELOG for $version:
" >> /tmp/release-$version-sigs.txt
if [ -f "/tmp/release-notes-$version.txt" ] ; then
tail -n +4 /tmp/release-notes-$version.txt >> /tmp/release-$version-sigs.txt
else
awk "/Release Notes - Wicket - Version $version/{flag=1;next} /==================/{flag=0} flag { print }" CHANGELOG-$major_version.x >> /tmp/release-$version-sigs.txt
fi
}
function generate_release_vote_email {
echo "Generating Vote email"
echo "
This is a vote to release Apache Wicket $version
Please download the source distributions found in our staging area
linked below.
I have included the signatures for both the source archives. This vote
lasts for 72 hours minimum.
[ ] Yes, release Apache Wicket $version
[ ] No, don't release Apache Wicket $version, because ...
Distributions, changelog, keys and signatures can be found at:
https://dist.apache.org/repos/dist/dev/wicket/$version
Staging repository:
https://repository.apache.org/content/repositories/$stagingrepoid/
The binaries are available in the above link, as are a staging
repository for Maven. Typically the vote is on the source, but should
you find a problem with one of the binaries, please let me know, I can
re-roll them some way or the other.
Staging git repository data:
Repository: $(git config --get remote.staging.url)
Branch: $branch
Release tag: $tag
" | tail -n+2 > release-vote.txt
cat /tmp/release-$version-sigs.txt >> release-vote.txt
git add release-vote.txt
}
function generate_announce_email {
echo "
The Apache Wicket PMC is proud to announce Apache Wicket $version!
Apache Wicket is an open source Java component oriented web application
framework that powers thousands of web applications and web sites for
governments, stores, universities, cities, banks, email providers, and
more. You can find more about Apache Wicket at https://wicket.apache.org
This release marks another minor release of Wicket $major_version. We
use semantic versioning for the development of Wicket, and as such no
API breaks are present in this release compared to $major_version.0.0.
<OPTIONAL> New and noteworthy
<OPTIONAL> ------------------
<OPTIONAL>
Using this release
------------------
With Apache Maven update your dependency to (and don't forget to
update any other dependencies on Wicket projects to the same version):
<dependency>
<groupId>org.apache.wicket</groupId>
<artifactId>wicket-core</artifactId>
<version>$version</version>
</dependency>
Or download and build the distribution yourself, or use our
convenience binary package you can find here:
* Download: http://wicket.apache.org/start/wicket-$major_version.x.html#manually
Upgrading from earlier versions
-------------------------------
If you upgrade from $major_version.y.z this release is a drop in replacement. If
you come from a version prior to $major_version.0.0, please read our Wicket $major_version
migration guide found at
* http://s.apache.org/wicket${major_version}migrate
Have fun!
— The Wicket team
" | tail -n+2 > release-announce.txt
cat /tmp/release-$version-sigs.txt >> release-announce.txt
git add release-announce.txt
}
function generate_announce_md {
echo $'---\nlayout: post\ntitle: Apache Wicket' $version $'released\n---' > wicket-$version-released.md
sed -e "s/$optionOpenTag/\{\% highlight xml\%\}\n$optionOpenTag/g" release-announce.txt |
sed -e "s/$optionCloseTag/$optionCloseTag\n\{\% endhighlight\%\}/g" |
sed -e s/' \*'/' \*'/g |
sed -e "s/ CHANGELOG for $version/### This Release\n\n#### CHANGELOG for $version/g" |
sed -e s/'\*\*'/'#####'/g |
sed -e "s/ $beginPgp/<div class='highlight'><pre>\n$beginPgp/g" |
sed -e "s/$endPgp/$endPgp\n<\/pre><\/div>\n/g" |
sed -e "s/Source: http:\/\/www.apache.org\/dyn\/closer.cgi\/wicket\/$version/Source: [$version source download]\(http:\/\/www.apache.org\/dyn\/closer.cgi\/wicket\/$version\)/g" |
sed -e "s/Binary: http:\/\/www.apache.org\/dyn\/closer.cgi\/wicket\/$version\/binaries/Binary: [$version binary download]\(http:\/\/www.apache.org\/dyn\/closer.cgi\/wicket\/$version\/binaries\)/g" |
sed -e "s/Upgrading from earlier versions/<!--more-->\n\nUpgrading from earlier versions/g" >> wicket-$version-released.md
git add wicket-$version-released.md
}
# the branch on which the code base lives for this version (master is
# always current development version)
GIT_BRANCH=master
JAVA_VERSION=$(getJavaVersionFromPom)
echo "
Apache Wicket Release script
----------------------------
Building a release for Apache Wicket.
This script assumes you are running on OS X, it hasn't been tested on any other
operating systems, and you can bet it won't work on Windows...
REQUIREMENTS:
- A Java version $JAVA_VERSION configured through the Maven toolchain
- Maven 3.3.0 (older releases are b0rked, just don't bother)
- gpg, gpg-agent and pinentry for signing
"
if [ ! $( git config --get remote.staging.url ) ] ; then
fail "
No staging remote git repository found. The staging repository is used to temporarily
publish the build artifacts during the voting process. Since no staging repository is
available at Apache, it is best to use a git mirror on your personal github account.
First fork the github Apache Wicket mirror (https://github.com/apache/wicket) and then
add the remote staging repository with the following command:
$ git remote add staging [email protected]:<your github username>/wicket.git
$ git fetch staging
$ git push staging
This will bring the staging area in sync with the origin and the release script can
push the build branch and the tag to the staging area.
"
fi
if [ ! -f ~/.m2/toolchains.xml ] ; then
fail "
Maven will load the Java $JAVA_VERSION environment from the toolchain specified in
~/.m2/toolchains.xml
You don't have a toolchains.xml file in your .m2 folder. Please specify your
JDK's in the toolchains.xml file.
"
fi
grep -q "<version>$JAVA_VERSION</version>" ~/.m2/toolchains.xml
if [ $? -ne 0 ] ; then
fail "
Your ~/.m2/toolchains.xml file doesn't provide a Java $JAVA_VERSION toolchain.
"
fi
echo "Java version for running Maven is: $(java -version 2>&1 | tail -n 2 | head -n 1)
Java used to compile (from toolchain) is: $(getJdkToolchain)
"
agentcount=`ps aux|grep gpg-agent|wc -l`
current_version=$(getProjectVersionFromPom)
major_version=$(expr $current_version : '\(.*\)\..*\..*\-.*')
minor_version=$(expr $current_version : '.*\.\(.*\)\..*\-.*')
bugfix_version=$(expr $current_version : '.*\..*\.\(.*\)-.*')
version="$major_version.$minor_version.0"
optionOpenTag='<dependency>'
optionCloseTag='<\/dependency>'
beginPgp='-----BEGIN PGP SIGNATURE-----'
endPgp='-----END PGP SIGNATURE-----'
default_version="$version"
version=
while [[ ! $version =~ ^[0-9]+\.[0-9]+\.[0-9]+(-M[0-9]+)?$ ]]
do
read -p "Version to release (default is $default_version): " -e t1
if [ -n "$t1" ]
then
version="$t1"
else
version="$default_version"
fi
done
# recalculate the version coordinates for the current release
major_version=$(expr $version : '\(.*\)\..*\..*')
minor_version=$(expr $version : '.*\.\(.*\)\..*')
bugfix_version=$(expr $version : '.*\..*\.\(.*\)')
if [[ $version =~ .+-M[0-9]+ ]]
then
milestone_version=$(expr $version : '.*\..*-M\(.*\)')
fi
if [ ! -z "$milestone_version" ] ; then
next_version="$major_version.0.0-M$(expr $milestone_version + 1)-SNAPSHOT"
previous_version="$major_version.0.0-M$milestone_version-SNAPSHOT"
else
next_version="$major_version.$(expr $minor_version + 1).0-SNAPSHOT"
previous_minor_version=$(expr $minor_version - 1)
if [ $previous_minor_version -lt 0 ] ; then
previous_version="$major_version.0.0-SNAPSHOT"
else
previous_version="$major_version.$(expr $minor_version - 1).0"
fi
fi
# work around for versions upgrade (TODO maybe no longer necessary?)
mvn_version_to_replace="$major_version.$minor_version.1-SNAPSHOT"
mvn_version_to_replace2="$major_version.$minor_version.0-SNAPSHOT"
# Check if the changelog has the issues this release
grep -q "$version\$" CHANGELOG-$major_version.x
if [ $? -ne 0 ] ; then
fail "You have forgotten to add the closed tickets for Wicket $version to the CHANGELOG-$major_version.x file
Use build-changelog.sh to add the release notes to the changelog.
"
fi
git status --porcelain CHANGELOG-$major_version.x | grep -q "M"
if [ $? -eq 0 ] ; then
fail "You have changes in your workspace that have not been committed.
$(git status)
"
fi
echo "Cleaning up any release artifacts that might linger"
mvn -q release:clean
log=$(pwd)/release.out
if [ -f $log ] ; then
rm $log
fi
branch="build/wicket-$version"
tag="rel/wicket-$version"
echo "# Release configuration for Wicket-$version
scm.tag=${tag}
" > release.properties
./build-versions.py $version $next_version >> release.properties
echo "Contents of the release properties generated for Maven:
-------------------------------------------------------------------------------
$(cat ./release.properties)
-------------------------------------------------------------------------------
Writing detailed log to $log
This script will release version: Apache Wicket $version and continue
development with $next_version
Press enter to continue or CTRL-C to abort \c"
read
echo "Ensuring we are starting from wicket-$major_version.x"
# otherwise we can't remove a previous release branch that failed
git checkout $GIT_BRANCH
echo "Removing previous release tag $tag (if exists)"
oldtag=`git tag -l |grep -e "$tag"|wc -l` >> release.out
[ "$oldtag" -ne 0 ] && git tag -d $tag >> release.out
echo "Removing previous build branch $branch (if exists)"
oldbranch=`git branch |grep -e "$branch"|wc -l` >> release.out
[ "$oldbranch" -ne 0 ] && git branch -D $branch >> release.out
echo "Removing previous staging branch (if exists)"
git push staging --delete refs/heads/$branch >> release.out
git push staging --delete $tag >> release.out
echo "Creating release branch"
git checkout -b $branch >> release.out
# Clear the current NOTICE.txt file
echo "Creating notice file."
NOTICE=NOTICE
echo "Apache Wicket
Copyright 2006-$(date +%Y) The Apache Software Foundation
This product includes software developed at
The Apache Software Foundation (http://www.apache.org/).
This is an aggregated NOTICE file for the Apache Wicket projects included
in this distribution.
NB: DO NOT ADD LICENSES/NOTICES/ATTRIBUTIONS TO THIS FILE, BUT IN THE
NOTICE FILE OF THE CORRESPONDING PROJECT. THE RELEASE PROCEDURE WILL
AUTOMATICALLY INCLUDE THE NOTICE IN THIS FILE.
" > $NOTICE
# next concatenate all NOTICE files from sub projects to the root file
for i in `find . -name "NOTICE" -not -regex ".*/target/.*" -not -regex "./NOTICE"`
do
echo "---------------------------------------------------------------------------" >> $NOTICE
echo "src/"$i | sed -e "s/\/src.*//g" >> $NOTICE
echo "---------------------------------------------------------------------------" >> $NOTICE
cat $i >> $NOTICE
echo >> $NOTICE
done
echo "Committing changes"
git commit -am "Changes to notice files"
# clean all projects
echo "Clean all projects"
mvn -q clean -Pall
# package and assemble the release
echo "Prepare the release"
mvn --batch-mode release:prepare -X -l $log -DpreparationGoals="clean" -Dtag=$tag -Papache-release,release
if [ $? -ne 0 ] ; then
fail "ERROR: mvn release:prepare was not successful"
fi
echo "Performing the release using Maven"
mvn -Dgpg.passphrase="$passphrase" -ff -l $log release:perform -DlocalCheckout=true -Dtag=$tag -Papache-release,release
if [ $? -ne 0 ] ; then
fail "ERROR: mvn release:perform was not successful"
fi
# Determine the staging repository and close it after deploying the release to the staging area
stagingrepoid=$(mvn org.sonatype.plugins:nexus-staging-maven-plugin:LATEST:rc-list -DnexusUrl=https://repository.apache.org -DserverId=apache.releases.https | grep -v "CLOSED" | grep -Eo "(orgapachewicket-\d+)";)
echo "Closing staging repository with id $stagingrepoid"
mvn org.sonatype.plugins:nexus-staging-maven-plugin:LATEST:rc-close -DstagingRepositoryId=$stagingrepoid -DnexusUrl=https://repository.apache.org -DserverId=apache.releases.https -Ddescription="Release has been built, awaiting vote"
generate_promotion_script
generate_rollback_script
echo "Create and sign the source tarballs"
mkdir -p target/dist/binaries
git archive --format=tar.gz --prefix=apache-wicket-$version/ -o target/dist/apache-wicket-$version.tar.gz $tag
git archive --format=zip --prefix=apache-wicket-$version/ -o target/dist/apache-wicket-$version.zip $tag
gpg --armor --detach-sign --use-agent --sign target/dist/apache-wicket-$version.tar.gz
gpg --armor --detach-sign --use-agent --sign target/dist/apache-wicket-$version.zip
pushd target/dist
sha256sum apache-wicket-$version.tar.gz > apache-wicket-$version.tar.gz.sha256
sha256sum apache-wicket-$version.zip > apache-wicket-$version.zip.sha256
popd
echo "Create and sign the binaries"
mkdir target/apache-wicket-$version-bin
pushd target/apache-wicket-$version-bin
find ../checkout ! \( -type d -name "WEB-INF" -prune \) -regex ".*wicket-[^/]*.[j]ar" ! -name "*-sources*" ! -name "*-javadoc*" ! -name "*wicket-archetype-quickstart*" ! -name "wicket-common-tests*" -type f -exec cp {} . \;
find ../checkout ! \( -type d -name "WEB-INF" -prune \) -regex ".*wicket-[^/]*.[j]ar\.asc" ! -name "*-sources*" ! -name "*-javadoc*" ! -name "*wicket-archetype-quickstart*" ! -name "wicket-common-tests*" -type f -exec cp {} . \;
cp ../../LICENSE .
cp ../../README .
cp ../../NOTICE .
cp ../../CHANGELOG* .
popd
pushd target
tar cfz dist/binaries/apache-wicket-$version-bin.tar.gz apache-wicket-$version-bin
zip -r dist/binaries/apache-wicket-$version-bin.zip apache-wicket-$version-bin
gpg --armor --detach-sign --use-agent --sign dist/binaries/apache-wicket-$version-bin.tar.gz
gpg --armor --detach-sign --use-agent --sign dist/binaries/apache-wicket-$version-bin.zip
pushd dist/binaries
sha256sum apache-wicket-$version-bin.tar.gz > apache-wicket-$version-bin.tar.gz.sha256
sha256sum apache-wicket-$version-bin.zip > apache-wicket-$version-bin.zip.sha256
popd
popd
echo "Uploading release to dist.apache.org"
pushd target/dist
svn mkdir https://dist.apache.org/repos/dist/dev/wicket/$version -m "Create $version release staging area"
svn co --force --depth=empty https://dist.apache.org/repos/dist/dev/wicket/$version .
cp ../../CHANGELOG* .
svn add *
svn commit -m "Upload wicket-$version to staging area"
popd
generate_signatures_from_release
generate_release_vote_email
generate_announce_email
generate_announce_md
# Done with the tasks, now print out the next things the release manager
# needs to do
pushd target/dist
find . -name "*.asc" -exec gpg --verify {} \;
popd
echo "
The release has been created. It is up to you to check if the release is up
to par, and perform the following commands yourself when you start the vote
to enable future development during the vote and after.
A vote email has been generated in release-vote.txt, you can copy/paste it using:
cat release-vote.txt | pbcopy
You can find the distribution in target/dist.
Failed release
--------------
To rollback a release due to a failed vote or some other complication use:
$ ./revert-$version.sh
This will clean up the artfifacts from the staging areas, including Nexus,
dist.apache.org and the release branch and tag.
Successful release
------------------
Congratulations on the successful release vote!
Use the release-announce.txt as a starter for the release announcement:
cat release-announce.txt | pbcopy
A Markdown file called wicket-$version-released.md has been also generated.
You can use it to update the site with the release announcement.
To promote the release after a successful vote, run:
$ ./promote-$version.sh
This will promote the Nexus staging repository to Maven Central, and move
the release artifacts from the staging area to dist.apache.org. It will
also sign the release tag and push the release branch to git.apache.org
You can read this message at a later time using:
$ cat release.txt
Happy voting!
" > release.txt
git add release.txt
echo "Adding post-release scripts and vote/release email templates to build branch"
git commit -m "Added post-release scripts and vote/release email templates"
echo "Signing the release tag"
git checkout $tag
git tag --sign --force --message \"Signed release tag for Apache Wicket $version\" $tag >> $log
git checkout $branch
echo "Pushing build artifacts to the staging repository"
git push staging $branch:refs/heads/$branch
echo "Pushing release tag to the staging repository"
git push staging $tag
cat release.txt