Repository navigation
Expand file tree
/
Copy pathrelease-version.sh
More file actions
executable file
·592 lines (538 loc) · 22.8 KB
/
Copy pathrelease-version.sh
File metadata and controls
executable file
·592 lines (538 loc) · 22.8 KB
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
#!/bin/sh
# ============================================================================
# release-version.sh
# ============================================================================
# Releases a new version of a component extending the pom-scijava parent.
#
# Authors: Johannes Schindelin & Curtis Rueden
# ============================================================================
# -- Avoid localized output that might confuse the script --
export LC_ALL=C
# -- Functions --
debug() {
test "$DEBUG" || return 0
echo "[DEBUG] $@"
}
die() {
echo "$*" >&2
exit 1
}
no_changes_pending() {
git update-index -q --refresh &&
git diff-files --quiet --ignore-submodules &&
git diff-index --cached --quiet --ignore-submodules HEAD --
}
# -- Multi-module helper functions --
# Prints the module directories listed in the given aggregator POM.
pom_modules() {
sed -n 's;.*<module>\([^<]*\)</module>.*;\1;p' "$1"
}
# Prints the artifactId of the given POM, ignoring that of its parent.
pom_artifactId() {
awk '
/<parent>/ { inParent = 1 }
/<\/parent>/ { inParent = 0; next }
!inParent && /<artifactId>/ {
sub(/.*<artifactId>/, ""); sub(/<\/artifactId>.*/, ""); print; exit
}
' "$1"
}
# Prints the names of properties used as the version of the given artifactId
# in the given POM. E.g., <version>${scijava-meta.version}</version>.
# Note: This assumes the artifactId element precedes the version element.
pom_versionProperties() {
awk -v artifactId="$2" '
/<artifactId>/ {
a = $0; sub(/.*<artifactId>/, "", a); sub(/<\/artifactId>.*/, "", a)
}
a == artifactId && /<version>\$\{[^}]*\}<\/version>/ {
p = $0; sub(/.*<version>\$\{/, "", p); sub(/\}<\/version>.*/, "", p); print p
}
' "$1" | sort -u
}
# Prints the value of the given property in the given POM.
pom_property() {
sed -n "s;.*<$2>\([^<]*\)</$2>.*;\1;p" "$1" | head -n1
}
# Sets the value of the given property in the given POM.
set_pom_property() {
sed -i.bak "s;<$2>[^<]*</$2>;<$2>$3</$2>;" "$1" &&
rm -f "$1.bak"
}
# Prints the latest released version of the given artifactId, followed by
# the tag from which it was released, by scanning the release.properties
# files of all tags. This works both for components released individually
# and for those released together as part of an aggregator.
latest_release() {
git grep -F -e "\\:$1=" $(git tag -l) -- ':/*release.properties' 2>/dev/null |
sed -n 's;^\([^:]*\):[^:]*:project\.rel\.[^=]*=\(.*\);\2 \1;p' |
sort -V | tail -n1
}
# -- Constants and settings --
SCIJAVA_BASE_REPOSITORY=-DaltDeploymentRepository=scijava.releases::default::dav:https://maven.scijava.org/content/repositories
SCIJAVA_RELEASES_REPOSITORY=$SCIJAVA_BASE_REPOSITORY/releases
SCIJAVA_THIRDPARTY_REPOSITORY=$SCIJAVA_BASE_REPOSITORY/thirdparty
# Parse command line options.
BATCH_MODE=--batch-mode
SKIP_VERSION_CHECK=
SKIP_BRANCH_CHECK=
SKIP_LICENSE_UPDATE=
SKIP_PUSH=
SKIP_GPG=
TAG=
DEV_VERSION=
EXTRA_ARGS=
ALT_REPOSITORY=
PROFILE=-Pdeploy-to-scijava
DRY_RUN=
USAGE=
VERSION=
while test $# -gt 0
do
case "$1" in
--dry-run) DRY_RUN=echo;;
--no-batch-mode) BATCH_MODE=;;
--skip-version-check) SKIP_VERSION_CHECK=t;;
--skip-branch-check) SKIP_BRANCH_CHECK=t;;
--skip-license-update) SKIP_LICENSE_UPDATE=t;;
--skip-push) SKIP_PUSH=t;;
--tag=*)
! git rev-parse --quiet --verify refs/tags/"${1#--*=}" ||
die "Tag ${1#--*=} exists already!"
TAG="-Dtag=${1#--*=}";;
--dev-version=*|--development-version=*)
DEV_VERSION="-DdevelopmentVersion=${1#--*=}";;
--extra-arg=*|--extra-args=*)
EXTRA_ARGS="$EXTRA_ARGS ${1#--*=}";;
--alt-repository=scijava-releases)
ALT_REPOSITORY=$SCIJAVA_RELEASES_REPOSITORY;;
--alt-repository=scijava-thirdparty)
ALT_REPOSITORY=$SCIJAVA_THIRDPARTY_REPOSITORY;;
--alt-repository=*|--alt-deployment-repository=*)
ALT_REPOSITORY="${1#--*=}";;
--skip-gpg)
SKIP_GPG=t
EXTRA_ARGS="$EXTRA_ARGS -Dgpg.skip=true";;
--help)
USAGE=t
break;;
-*)
echo "Unknown option: $1" >&2
USAGE=t
break;;
*)
test -z "$VERSION" || {
echo "Extraneous argument: $1" >&2
USAGE=t
break
}
VERSION=$1;;
esac
shift
done
test "$USAGE" &&
die "Usage: $0 [options] [<version>]
Where <version> is the version to release. If omitted, it will prompt you.
To release a module of a multi-module repository, run this script from
the module's directory. Its SNAPSHOT dependencies on sibling modules are
pinned to their latest releases for the release, and afterward, sibling
modules depending on it are updated to its new development version.
Options include:
--dry-run - Simulate the release without actually doing it.
--skip-version-check - Skips the SemVer, parent pom and sibling module
version checks.
--skip-branch-check - Skips the default branch check.
--skip-license-update - Skips update of the copyright blurbs.
--skip-push - Do not push to the remote git repository.
--dev-version=<x.y.z> - Specify next development version explicitly;
e.g.: if you release 2.0.0-beta-1, by default
Maven will set the next development version at
2.0.0-beta-2-SNAPSHOT, but maybe you want to
set it to 2.0.0-SNAPSHOT instead.
--alt-repository=<repo> - Deploy release to a different remote repository.
--skip-gpg - Do not perform GPG signing of artifacts.
"
# -- Extract project details --
debug "Extracting project details"
echoArg='${project.version}:${license.licenseName}:${project.parent.groupId}:${project.parent.artifactId}:${project.parent.version}:${license.skipUpdateProjectLicense}'
projectDetails=$(mvn -B -N -Dexec.executable=echo -Dexec.args="$echoArg" exec:exec -q)
test $? -eq 0 || projectDetails=$(mvn -B -U -N -Dexec.executable=echo -Dexec.args="$echoArg" exec:exec -q)
test $? -eq 0 || die "Could not extract version from pom.xml. Error follows:\n$projectDetails"
printf '%s' "$projectDetails\n" | grep -Fqv '[ERROR]' ||
die "Error extracting version from pom.xml. Error follows:\n$projectDetails"
# HACK: Even with -B, some versions of mvn taint the output with the <ESC>[0m
# color reset sequence. So we forcibly remove such sequences, just to be safe.
projectDetails=$(printf '%s' "$projectDetails" | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g")
# And also remove extraneous newlines, particularly any trailing ones.
projectDetails=$(printf '%s' "$projectDetails" | tr -d '\n')
currentVersion=${projectDetails%%:*}
projectDetails=${projectDetails#*:}
licenseName=${projectDetails%%:*}
projectDetails=${projectDetails#*:}
parentGroup=${projectDetails%%:*}
projectDetails=${projectDetails#*:}
parentArtifact=${projectDetails%%:*}
projectDetails=${projectDetails#*:}
parentVersion=${projectDetails%%:*}
parentGAV="${parentGroup}:${parentArtifact}:${parentVersion}"
skipUpdateProjectLicense=${projectDetails#*:}
# -- Sanity checks --
debug "Performing sanity checks"
# Check that we have push rights to the repository.
if [ ! "$SKIP_PUSH" ]
then
debug "Checking repository push rights"
push=$(git remote -v | grep origin | grep '(push)')
test "$push" || die 'No push URL found for remote origin.
Please use "git remote -v" to double check your remote settings.'
echo "$push" | grep -q 'git:/' && die 'Remote origin is read-only.
Please use "git remote set-url origin ..." to change it.'
fi
# Discern the version to release.
debug "Gleaning release version"
pomVersion=${currentVersion%-SNAPSHOT}
test "$VERSION" -o ! -t 0 || {
printf 'Version? [%s]: ' "$pomVersion"
read VERSION
test "$VERSION" || VERSION=$pomVersion
}
# Check that the release version number starts with a digit.
test "$VERSION" || die 'Please specify the version to release!'
test "$SKIP_VERSION_CHECK" || {
case "$VERSION" in
[0-9]*)
;;
*)
die "Version '$VERSION' does not start with a digit!
If you are sure, try again with --skip-version-check flag."
esac
}
# Check that the release version number conforms to SemVer.
VALID_SEMVER_BUMP="$(cd "$(dirname "$0")" && pwd)/valid-semver-bump.sh"
test -f "$VALID_SEMVER_BUMP" ||
die "Missing helper script at '$VALID_SEMVER_BUMP'
Do you have a full clone of https://github.com/scijava/scijava-scripts?"
test "$SKIP_VERSION_CHECK" || {
debug "Checking conformance to SemVer"
sh -$- "$VALID_SEMVER_BUMP" "$pomVersion" "$VERSION" ||
die "If you are sure, try again with --skip-version-check flag."
}
# Check that the project extends the latest version of pom-scijava.
test "$SKIP_VERSION_CHECK" -o "$parentGroup" != "org.scijava" -o "$parentArtifact" != "pom-scijava" || {
debug "Checking pom-scijava parent version"
psjMavenMetadata=https://repo1.maven.org/maven2/org/scijava/pom-scijava/maven-metadata.xml
latestParentVersion=$(curl -fsL "$psjMavenMetadata" | grep '<release>' | sed 's;.*>\([^<]*\)<.*;\1;')
currentParentVersion=${parentGAV##*:}
test "$currentParentVersion" = "$latestParentVersion" ||
die "Newer version of parent '$parentGAV' is available: $latestParentVersion.
I recommend you update it before releasing.
Or if you know better, try again with --skip-version-check flag."
}
# Check that the working copy is clean.
debug "Checking if working copy is clean"
no_changes_pending || die 'There are uncommitted changes!'
test -z "$(git ls-files -o --exclude-standard)" ||
die 'There are untracked files! Please stash them before releasing.'
# Discern default branch.
debug "Discerning default branch"
currentBranch=$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)
upstreamBranch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
remote=${upstreamBranch%/*}
defaultBranch=$(git remote show "$remote" | grep "HEAD branch" | sed 's/.*: //')
# Check that we are on the main branch.
test "$SKIP_BRANCH_CHECK" || {
debug "Checking current branch"
test "$currentBranch" = "$defaultBranch" || die "Non-default branch: $currentBranch.
If you are certain you want to release from this branch,
try again with --skip-branch-check flag."
}
# Detect whether we are releasing a module of a multi-module repository.
# If so, the module is released on its own, from its own directory.
debug "Checking for multi-module repository"
moduleDir=
if test "$(git rev-parse --show-prefix)" -a -f ../pom.xml
then
pom_modules ../pom.xml | grep -qxF "$(basename "$PWD")" &&
moduleDir=$(basename "$PWD")
fi
if test "$moduleDir"
then
debug "Releasing module '$moduleDir' of multi-module repository"
artifactId=$(pom_artifactId pom.xml)
test "$artifactId" || die "Could not extract artifactId from pom.xml"
siblingDirs=$(pom_modules ../pom.xml | grep -vxF "$moduleDir")
# Plan which SNAPSHOT versions of sibling modules to pin to releases.
# Each line of siblingPins is: <property> <snapshot-version> <release-version>
debug "Checking versions of sibling module dependencies"
siblingPins=
for siblingDir in $siblingDirs
do
test -f "../$siblingDir/pom.xml" || continue
siblingArtifactId=$(pom_artifactId "../$siblingDir/pom.xml")
for property in $(pom_versionProperties pom.xml "$siblingArtifactId")
do
snapshotVersion=$(pom_property pom.xml "$property")
case "$snapshotVersion" in
*-SNAPSHOT) ;;
*) continue ;;
esac
release=$(latest_release "$siblingArtifactId")
test "$release" || die "No release of sibling module '$siblingArtifactId' found.
Please release it first, then try again."
releaseVersion=${release%% *}
releaseTag=${release#* }
debug "Pinning $property: $snapshotVersion -> $releaseVersion"
# Note: Changes to versions, SCM tags and copyright years do not count.
test "$SKIP_VERSION_CHECK" ||
git diff --quiet \
-I'<version>[^<]*</version>' \
-I'\.version>[^<]*</' \
-I'<tag>[^<]*</tag>' \
-I'Copyright (C)' \
"$releaseTag" HEAD -- "../$siblingDir" \
":(exclude)../$siblingDir/release.properties" ||
die "Sibling module '$siblingArtifactId' has changed since its $releaseVersion release.
Please release it first, so that $artifactId can depend on those changes.
Use \"git diff $releaseTag HEAD -- ../$siblingDir\" to see what changed.
Or if you are sure, try again with --skip-version-check flag."
siblingPins="$siblingPins$property $snapshotVersion $releaseVersion
"
done
done
fi
# If REMOTE is unset, use branch's upstream remote by default.
REMOTE="${REMOTE:-$remote}"
# Check that the main branch isn't behind the upstream branch.
debug "Ensuring local branch is up-to-date"
HEAD="$(git rev-parse HEAD)" &&
git fetch "$REMOTE" "$defaultBranch" &&
FETCH_HEAD="$(git rev-parse FETCH_HEAD)" &&
test "$FETCH_HEAD" = HEAD ||
test "$FETCH_HEAD" = "$(git merge-base $FETCH_HEAD $HEAD)" ||
die "'$defaultBranch' is not up-to-date"
# Check for release-only files committed to the main branch.
debug "Checking for spurious release-only files"
for release_file in release.properties pom.xml.releaseBackup
do
if [ -e "$release_file" ]
then
echo "=========================================================================="
echo "NOTE: $release_file was committed to source control. Removing now."
echo "=========================================================================="
git rm -rf "$release_file" &&
git commit "$release_file" \
-m 'Remove $release_file' \
-m 'It should only exist on release tags.'
fi
done
# Ensure that schema location URL uses HTTPS, not HTTP.
debug "Checking that schema location URL uses HTTPS"
if grep -q http://maven.apache.org/xsd/maven-4.0.0.xsd pom.xml >/dev/null 2>/dev/null
then
echo "====================================================================="
echo "NOTE: Your POM's schema location uses HTTP, not HTTPS. Fixing it now."
echo "====================================================================="
sed 's;http://maven.apache.org/xsd/maven-4.0.0.xsd;https://maven.apache.org/xsd/maven-4.0.0.xsd;' pom.xml > pom.new &&
mv -f pom.new pom.xml &&
git commit pom.xml -m 'POM: use HTTPS for schema location URL' \
-m 'Maven no longer supports plain HTTP for the schema location.' \
-m 'And using HTTP now generates errors in Eclipse (and probably other IDEs).'
fi
# Check project xmlns, xmlns:xsi, and xsi:schemaLocation attributes.
debug "Checking correctness of POM project XML attributes"
grep -qF 'xmlns="http://maven.apache.org/POM/4.0.0"' pom.xml >/dev/null 2>/dev/null &&
grep -qF 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' pom.xml >/dev/null 2>/dev/null &&
grep -qF 'xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 ' pom.xml >/dev/null 2>/dev/null ||
{
echo "====================================================================="
echo "NOTE: Your POM's project attributes are incorrect. Fixing it now."
echo "====================================================================="
sed 's;xmlns="[^"]*";xmlns="http://maven.apache.org/POM/4.0.0";' pom.xml > pom.new &&
mv -f pom.new pom.xml &&
sed 's;xmlns:xsi="[^"]*";xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";' pom.xml > pom.new &&
mv -f pom.new pom.xml &&
sed 's;xsi:schemaLocation="[^"]*";xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd";' pom.xml > pom.new &&
mv -f pom.new pom.xml &&
git commit pom.xml -m 'POM: fix project attributes' \
-m 'The XML schema for Maven POMs is located at:' \
-m ' https://maven.apache.org/xsd/maven-4.0.0.xsd' \
-m 'Its XML namespace is the string:' \
-m ' http://maven.apache.org/POM/4.0.0' \
-m 'So that exact string must be the value of xmlns. It must also
match the first half of xsi:schemaLocation, which maps that
namespace to an actual URL online where the schema resides.
Otherwise, the document is not a Maven POM.' \
-m 'Similarly, the xmlns:xsi attribute of an XML document declaring a
particular schema should always use the string identifier:' \
-m ' http://www.w3.org/2001/XMLSchema-instance' \
-m "because that's the namespace identifier for instances of an XML schema." \
-m "For details, see the specification at: https://www.w3.org/TR/xmlschema-1/"
}
# Change forum references from forum.image.net to forum.image.sc.
debug "Checking correctness of forum URL references"
if grep -q 'https*://forum.imagej.net' pom.xml >/dev/null 2>/dev/null
then
echo "================================================================"
echo "NOTE: Your POM still references forum.imagej.net. Fixing it now."
echo "================================================================"
sed 's;https*://forum.imagej.net;https://forum.image.sc;g' pom.xml > pom.new &&
mv -f pom.new pom.xml &&
git commit pom.xml \
-m 'POM: fix forum.image.sc tag link' \
-m 'The Discourse software updated the tags path from /tags/ to /tag/.'
fi
# Ensure that references to forum.image.sc use /tag/, not /tags/.
debug "Checking correctness of forum tag references"
if grep -q forum.image.sc/tags/ pom.xml >/dev/null 2>/dev/null
then
echo "=================================================================="
echo "NOTE: Your POM has an old-style forum.image.sc tag. Fixing it now."
echo "=================================================================="
sed 's;forum.image.sc/tags/;forum.image.sc/tag/;g' pom.xml > pom.new &&
mv -f pom.new pom.xml &&
git commit pom.xml \
-m 'POM: fix forum.image.sc tag link' \
-m 'The Discourse software updated the tags path from /tags/ to /tag/.'
fi
# Ensure license headers are up-to-date.
test "$SKIP_LICENSE_UPDATE" -o -z "$licenseName" -o "$licenseName" = "N/A" -o "$skipUpdateProjectLicense" = "true" || {
debug "Ensuring that license headers are up-to-date"
mvn license:update-project-license license:update-file-header &&
git add LICENSE.txt || die 'Failed to update copyright blurbs.
You can skip the license update using the --skip-license-update flag.'
no_changes_pending ||
die 'Copyright blurbs needed an update -- commit changes and try again.
Or if the license headers are being added erroneously to certain files,
exclude them by setting license.excludes in your POM; e.g.:
<license.excludes>**/script_templates/**</license.excludes>
Alternately, try again with the --skip-license-update flag.'
}
# Pin SNAPSHOT dependencies on sibling modules to their release versions.
# The release plugin refuses to release with SNAPSHOT dependencies. This pin
# commit is later squashed into the release commit, and is not on the branch.
preReleaseHead=$(git rev-parse HEAD)
if test "$siblingPins"
then
debug "Pinning sibling module dependencies to release versions"
printf '%s' "$siblingPins" | while read property snapshotVersion releaseVersion
do
$DRY_RUN set_pom_property pom.xml "$property" "$releaseVersion"
done &&
$DRY_RUN git commit -m "Use release versions of sibling modules" pom.xml ||
die 'Failed to pin sibling module dependencies to release versions.'
fi
# Prepare new release without pushing (requires the release plugin >= 2.1).
debug "Preparing new release"
$DRY_RUN mvn $BATCH_MODE release:prepare -DpushChanges=false -Dresume=false $TAG \
$PROFILE $DEV_VERSION -DreleaseVersion="$VERSION" \
"-Darguments=-Dgpg.skip=true ${EXTRA_ARGS# }" ||
die "The release preparation step failed -- look above for errors and fix them.
Use \"mvn javadoc:javadoc | grep error\" to check for javadoc syntax errors.
Use \"mvn release:clean && git reset --hard $preReleaseHead\" to start over."
# Squash the maven-release-plugin's two commits (and any pin commit) into one.
if test -z "$DRY_RUN"
then
debug "Squashing release commits"
test "[maven-release-plugin] prepare for next development iteration" = \
"$(git show -s --format=%s HEAD)" ||
die "maven-release-plugin's commits are unexpectedly missing!"
fi
$DRY_RUN git reset --soft "$preReleaseHead" &&
# For a module of a multi-module repository: restore its SNAPSHOT dependencies
# on sibling modules, and update sibling modules depending on it to use its new
# development version.
if test "$moduleDir"
then
debug "Updating sibling module dependency versions"
printf '%s' "$siblingPins" | while read property snapshotVersion releaseVersion
do
$DRY_RUN set_pom_property pom.xml "$property" "$snapshotVersion"
done &&
if test -z "$DRY_RUN"
then
devVersion=$(sed -n "s;^project\.dev\.[^=]*:$artifactId=;;p" release.properties)
test "$devVersion" || die "Could not extract development version from release.properties"
else
devVersion="<dev-version>"
fi &&
for siblingDir in $siblingDirs
do
siblingPom="../$siblingDir/pom.xml"
test -f "$siblingPom" || continue
for property in $(pom_versionProperties "$siblingPom" "$artifactId")
do
case "$(pom_property "$siblingPom" "$property")" in
*-SNAPSHOT)
debug "Updating $property in $siblingPom to $devVersion"
$DRY_RUN set_pom_property "$siblingPom" "$property" "$devVersion"
;;
esac
done
done &&
$DRY_RUN git add -u -- ..
fi &&
if ! git diff-index --cached --quiet --ignore-submodules HEAD --
then
if test "$moduleDir"
then
$DRY_RUN git commit -s -m "Bump $artifactId to next development cycle"
else
$DRY_RUN git commit -s -m "Bump to next development cycle"
fi
fi &&
# Check that release-only files were not erroneously committed.
if test -z "$DRY_RUN"
then
debug "Verifying release-only files were not committed"
for release_file in release.properties pom.xml.releaseBackup
do
if git diff --name-only HEAD~1 HEAD | grep -qF "$release_file"
then
die "FATAL: $release_file was committed to the branch!
This likely means your IDE automatically staged these files.
Please configure your IDE to NOT auto-stage files during the release process.
You can undo this failed release with:
git reset --hard HEAD~1
git tag -d \$(sed -n 's/^scm.tag=//p' < release.properties)
Then try the release again after disabling IDE auto-staging."
fi
done
fi &&
# Extract the name of the new tag.
debug "Extracting new tag name"
if test -z "$DRY_RUN"
then
tag=$(sed -n 's/^scm.tag=//p' < release.properties)
else
tag="<tag>"
fi &&
# Rewrite the tag to include release.properties, squashing any pin commit
# into the release commit, so that the tag shows all release changes at once.
debug "Rewriting tag to include release.properties"
test -n "$tag" &&
# HACK: SciJava projects use SSH ([email protected]:...) for developerConnection.
# The release:perform command wants to use the developerConnection URL when
# checking out the release tag. But reading from this URL requires credentials
# which the CI system typically does not have. So we replace the scm.url in
# the release.properties file to use the public (https://github.com/...) URL.
# This is OK, since release:perform does not need write access to the repo.
$DRY_RUN sed -i.bak -e 's|^scm.url=scm\\:git\\:[email protected]\\:|scm.url=scm\\:git\\:https\\://github.com/|' release.properties &&
$DRY_RUN rm release.properties.bak &&
$DRY_RUN git checkout "$tag" &&
$DRY_RUN git reset --soft "$preReleaseHead" &&
$DRY_RUN git add -f release.properties &&
$DRY_RUN git commit -C "$tag" &&
$DRY_RUN git tag -d "$tag" &&
$DRY_RUN git tag "$tag" HEAD &&
$DRY_RUN git checkout @{-1} &&
# Push the current branch and the tag.
if test -z "$SKIP_PUSH"
then
debug "Pushing changes"
$DRY_RUN git push "$REMOTE" HEAD $tag
fi
# Remove files generated by the release process. They can end up
# committed to the mainline branch and hosing up later releases.
debug "Cleaning up"
$DRY_RUN rm -f release.properties pom.xml.releaseBackup
debug "Release complete!"