@@ -14,7 +14,12 @@ export LC_ALL=C
14
14
15
15
# -- Functions --
16
16
17
- die () {
17
+ debug () {
18
+ test " $DEBUG " || return
19
+ echo " [DEBUG] $@ "
20
+ }
21
+
22
+ die () {
18
23
echo " $* " >&2
19
24
exit 1
20
25
}
@@ -111,6 +116,7 @@ Options include:
111
116
"
112
117
113
118
# -- Extract project details --
119
+ debug " Extracting project details"
114
120
115
121
echoArg=' ${project.version}:${license.licenseName}:${project.parent.groupId}:${project.parent.artifactId}:${project.parent.version}'
116
122
projectDetails=$( mvn -N -Dexec.executable=echo -Dexec.args=" $echoArg " exec:exec -q)
@@ -124,10 +130,12 @@ licenseName=${projectDetails%%:*}
124
130
parentGAV=${projectDetails#*: }
125
131
126
132
# -- Sanity checks --
133
+ debug " Performing sanity checks"
127
134
128
135
# Check that we have push rights to the repository.
129
136
if [ ! " $SKIP_PUSH " ]
130
137
then
138
+ debug " Checking repository push rights"
131
139
push=$( git remote -v | grep origin | grep ' (push)' )
132
140
test " $push " || die ' No push URL found for remote origin.
133
141
Please use "git remote -v" to double check your remote settings.'
@@ -136,6 +144,7 @@ Please use "git remote set-url origin ..." to change it.'
136
144
fi
137
145
138
146
# Discern the version to release.
147
+ debug " Gleaning release version"
139
148
pomVersion=${currentVersion% -SNAPSHOT}
140
149
test " $VERSION " -o ! -t 0 || {
141
150
printf ' Version? [%s]: ' " $pomVersion "
@@ -161,6 +170,7 @@ test -f "$VALID_SEMVER_BUMP" ||
161
170
die " Missing helper script at '$VALID_SEMVER_BUMP '
162
171
Do you have a full clone of https://github.com/scijava/scijava-scripts?"
163
172
test " $SKIP_VERSION_CHECK " || {
173
+ debug " Checking conformance to SemVer"
164
174
sh -$- " $VALID_SEMVER_BUMP " " $pomVersion " " $VERSION " ||
165
175
die " If you are sure, try again with --skip-version-check flag."
166
176
}
@@ -171,6 +181,7 @@ test -f "$MAVEN_HELPER" ||
171
181
die " Missing helper script at '$MAVEN_HELPER '
172
182
Do you have a full clone of https://github.com/scijava/scijava-scripts?"
173
183
test " $SKIP_VERSION_CHECK " -o " $parentGAV " ! = " ${parentGAV# $} " || {
184
+ debug " Checking pom-scijava parent version"
174
185
latestParentVersion=$( sh -$- " $MAVEN_HELPER " latest-version " $parentGAV " )
175
186
currentParentVersion=${parentGAV##*: }
176
187
test " $currentParentVersion " = " $latestParentVersion " ||
@@ -180,18 +191,21 @@ Or if you know better, try again with --skip-version-check flag."
180
191
}
181
192
182
193
# Check that the working copy is clean.
194
+ debug " Checking if working copy is clean"
183
195
no_changes_pending || die ' There are uncommitted changes!'
184
196
test -z " $( git ls-files -o --exclude-standard) " ||
185
197
die ' There are untracked files! Please stash them before releasing.'
186
198
187
199
# Discern default branch.
200
+ debug " Discerning default branch"
188
201
currentBranch=$( git rev-parse --abbrev-ref --symbolic-full-name HEAD)
189
202
upstreamBranch=$( git rev-parse --abbrev-ref --symbolic-full-name @{u})
190
203
remote=${upstreamBranch%/* }
191
204
defaultBranch=$( git remote show " $remote " | grep " HEAD branch" | sed ' s/.*: //' )
192
205
193
206
# Check that we are on the main branch.
194
207
test " $SKIP_BRANCH_CHECK " || {
208
+ debug " Checking current branch"
195
209
test " $currentBranch " = " $defaultBranch " || die " Non-default branch: $currentBranch .
196
210
If you are certain you want to release from this branch,
197
211
try again with --skip-branch-check flag."
@@ -201,6 +215,7 @@ try again with --skip-branch-check flag."
201
215
REMOTE=" ${REMOTE:- $remote } "
202
216
203
217
# Check that the main branch isn't behind the upstream branch.
218
+ debug " Ensuring local branch is up-to-date"
204
219
HEAD=" $( git rev-parse HEAD) " &&
205
220
git fetch " $REMOTE " " $defaultBranch " &&
206
221
FETCH_HEAD=" $( git rev-parse FETCH_HEAD) " &&
@@ -209,6 +224,7 @@ test "$FETCH_HEAD" = "$(git merge-base $FETCH_HEAD $HEAD)" ||
209
224
die " '$defaultBranch ' is not up-to-date"
210
225
211
226
# Check for release-only files committed to the main branch.
227
+ debug " Checking for spurious release-only files"
212
228
for release_file in release.properties pom.xml.releaseBackup
213
229
do
214
230
if [ -e " $release_file " ]
224
240
done
225
241
226
242
# Ensure that schema location URL uses HTTPS, not HTTP.
243
+ debug " Checking that schema location URL uses HTTPS"
227
244
if grep -q http://maven.apache.org/xsd/maven-4.0.0.xsd pom.xml > /dev/null 2> /dev/null
228
245
then
229
246
echo " ====================================================================="
237
254
fi
238
255
239
256
# Check project xmlns, xmlns:xsi, and xsi:schemaLocation attributes.
257
+ debug " Checking correctness of POM project XML attributes"
240
258
grep -qF ' xmlns="http://maven.apache.org/POM/4.0.0"' pom.xml > /dev/null 2> /dev/null &&
241
259
grep -qF ' xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' pom.xml > /dev/null 2> /dev/null &&
242
260
grep -qF ' xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 ' pom.xml > /dev/null 2> /dev/null ||
@@ -267,6 +285,7 @@ particular schema should always use the string identifier:' \
267
285
}
268
286
269
287
# Change forum references from forum.image.net to forum.image.sc.
288
+ debug " Checking correctness of forum URL references"
270
289
if grep -q ' https*://forum.imagej.net' pom.xml > /dev/null 2> /dev/null
271
290
then
272
291
echo " ================================================================"
280
299
fi
281
300
282
301
# Ensure that references to forum.image.sc use /tag/, not /tags/.
302
+ debug " Checking correctness of forum tag references"
283
303
if grep -q forum.image.sc/tags/ pom.xml > /dev/null 2> /dev/null
284
304
then
285
305
echo " =================================================================="
294
314
295
315
# Ensure license headers are up-to-date.
296
316
test " $SKIP_LICENSE_UPDATE " -o -z " $licenseName " -o " $licenseName " = " N/A" || {
317
+ debug " Ensuring that license headers are up-to-date"
297
318
mvn license:update-project-license license:update-file-header &&
298
319
git add LICENSE.txt || die ' Failed to update copyright blurbs.
299
320
You can skip the license update using the --skip-license-update flag.'
@@ -308,6 +329,7 @@ Alternately, try again with the --skip-license-update flag.'
308
329
}
309
330
310
331
# Prepare new release without pushing (requires the release plugin >= 2.1).
332
+ debug " Preparing new release"
311
333
$DRY_RUN mvn $BATCH_MODE release:prepare -DpushChanges=false -Dresume=false $TAG \
312
334
$PROFILE $DEV_VERSION -DreleaseVersion=" $VERSION " \
313
335
" -Darguments=-Dgpg.skip=true ${EXTRA_ARGS# } " ||
@@ -317,6 +339,7 @@ Use "mvn javadoc:javadoc | grep error" to check for javadoc syntax errors.'
317
339
# Squash the maven-release-plugin's two commits into one.
318
340
if test -z " $DRY_RUN "
319
341
then
342
+ debug " Squashing release commits"
320
343
test " [maven-release-plugin] prepare for next development iteration" = \
321
344
" $( git show -s --format=%s HEAD) " ||
322
345
die " maven-release-plugin's commits are unexpectedly missing!"
328
351
fi &&
329
352
330
353
# Extract the name of the new tag.
354
+ debug " Extracting new tag name"
331
355
if test -z " $DRY_RUN "
332
356
then
333
357
tag=$( sed -n ' s/^scm.tag=//p' < release.properties)
336
360
fi &&
337
361
338
362
# Rewrite the tag to include release.properties.
363
+ debug " Rewriting tag to include release.properties"
339
364
test -n " $tag " &&
340
365
# HACK: SciJava projects use SSH (git@github.com:...) for developerConnection.
341
366
# The release:perform command wants to use the developerConnection URL when
@@ -355,9 +380,13 @@ $DRY_RUN git checkout @{-1} &&
355
380
# Push the current branch and the tag.
356
381
if test -z " $SKIP_PUSH "
357
382
then
383
+ debug " Pushing changes"
358
384
$DRY_RUN git push " $REMOTE " HEAD $tag
359
385
fi
360
386
361
387
# Remove files generated by the release process. They can end up
362
388
# committed to the mainline branch and hosing up later releases.
389
+ debug " Cleaning up"
363
390
$DRY_RUN rm -f release.properties pom.xml.releaseBackup
391
+
392
+ debug " Release complete!"
0 commit comments