Skip to content

Commit 224ea62

Browse files
committed
release-version: add debugging statements
Enable via: DEBUG=1 release-version.sh
1 parent 48b0aa7 commit 224ea62

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

release-version.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ export LC_ALL=C
1414

1515
# -- Functions --
1616

17-
die () {
17+
debug() {
18+
test "$DEBUG" || return
19+
echo "[DEBUG] $@"
20+
}
21+
22+
die() {
1823
echo "$*" >&2
1924
exit 1
2025
}
@@ -111,6 +116,7 @@ Options include:
111116
"
112117

113118
# -- Extract project details --
119+
debug "Extracting project details"
114120

115121
echoArg='${project.version}:${license.licenseName}:${project.parent.groupId}:${project.parent.artifactId}:${project.parent.version}'
116122
projectDetails=$(mvn -N -Dexec.executable=echo -Dexec.args="$echoArg" exec:exec -q)
@@ -124,10 +130,12 @@ licenseName=${projectDetails%%:*}
124130
parentGAV=${projectDetails#*:}
125131

126132
# -- Sanity checks --
133+
debug "Performing sanity checks"
127134

128135
# Check that we have push rights to the repository.
129136
if [ ! "$SKIP_PUSH" ]
130137
then
138+
debug "Checking repository push rights"
131139
push=$(git remote -v | grep origin | grep '(push)')
132140
test "$push" || die 'No push URL found for remote origin.
133141
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.'
136144
fi
137145

138146
# Discern the version to release.
147+
debug "Gleaning release version"
139148
pomVersion=${currentVersion%-SNAPSHOT}
140149
test "$VERSION" -o ! -t 0 || {
141150
printf 'Version? [%s]: ' "$pomVersion"
@@ -161,6 +170,7 @@ test -f "$VALID_SEMVER_BUMP" ||
161170
die "Missing helper script at '$VALID_SEMVER_BUMP'
162171
Do you have a full clone of https://github.com/scijava/scijava-scripts?"
163172
test "$SKIP_VERSION_CHECK" || {
173+
debug "Checking conformance to SemVer"
164174
sh -$- "$VALID_SEMVER_BUMP" "$pomVersion" "$VERSION" ||
165175
die "If you are sure, try again with --skip-version-check flag."
166176
}
@@ -171,6 +181,7 @@ test -f "$MAVEN_HELPER" ||
171181
die "Missing helper script at '$MAVEN_HELPER'
172182
Do you have a full clone of https://github.com/scijava/scijava-scripts?"
173183
test "$SKIP_VERSION_CHECK" -o "$parentGAV" != "${parentGAV#$}" || {
184+
debug "Checking pom-scijava parent version"
174185
latestParentVersion=$(sh -$- "$MAVEN_HELPER" latest-version "$parentGAV")
175186
currentParentVersion=${parentGAV##*:}
176187
test "$currentParentVersion" = "$latestParentVersion" ||
@@ -180,18 +191,21 @@ Or if you know better, try again with --skip-version-check flag."
180191
}
181192

182193
# Check that the working copy is clean.
194+
debug "Checking if working copy is clean"
183195
no_changes_pending || die 'There are uncommitted changes!'
184196
test -z "$(git ls-files -o --exclude-standard)" ||
185197
die 'There are untracked files! Please stash them before releasing.'
186198

187199
# Discern default branch.
200+
debug "Discerning default branch"
188201
currentBranch=$(git rev-parse --abbrev-ref --symbolic-full-name HEAD)
189202
upstreamBranch=$(git rev-parse --abbrev-ref --symbolic-full-name @{u})
190203
remote=${upstreamBranch%/*}
191204
defaultBranch=$(git remote show "$remote" | grep "HEAD branch" | sed 's/.*: //')
192205

193206
# Check that we are on the main branch.
194207
test "$SKIP_BRANCH_CHECK" || {
208+
debug "Checking current branch"
195209
test "$currentBranch" = "$defaultBranch" || die "Non-default branch: $currentBranch.
196210
If you are certain you want to release from this branch,
197211
try again with --skip-branch-check flag."
@@ -201,6 +215,7 @@ try again with --skip-branch-check flag."
201215
REMOTE="${REMOTE:-$remote}"
202216

203217
# Check that the main branch isn't behind the upstream branch.
218+
debug "Ensuring local branch is up-to-date"
204219
HEAD="$(git rev-parse HEAD)" &&
205220
git fetch "$REMOTE" "$defaultBranch" &&
206221
FETCH_HEAD="$(git rev-parse FETCH_HEAD)" &&
@@ -209,6 +224,7 @@ test "$FETCH_HEAD" = "$(git merge-base $FETCH_HEAD $HEAD)" ||
209224
die "'$defaultBranch' is not up-to-date"
210225

211226
# Check for release-only files committed to the main branch.
227+
debug "Checking for spurious release-only files"
212228
for release_file in release.properties pom.xml.releaseBackup
213229
do
214230
if [ -e "$release_file" ]
@@ -224,6 +240,7 @@ do
224240
done
225241

226242
# Ensure that schema location URL uses HTTPS, not HTTP.
243+
debug "Checking that schema location URL uses HTTPS"
227244
if grep -q http://maven.apache.org/xsd/maven-4.0.0.xsd pom.xml >/dev/null 2>/dev/null
228245
then
229246
echo "====================================================================="
@@ -237,6 +254,7 @@ then
237254
fi
238255

239256
# Check project xmlns, xmlns:xsi, and xsi:schemaLocation attributes.
257+
debug "Checking correctness of POM project XML attributes"
240258
grep -qF 'xmlns="http://maven.apache.org/POM/4.0.0"' pom.xml >/dev/null 2>/dev/null &&
241259
grep -qF 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"' pom.xml >/dev/null 2>/dev/null &&
242260
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:' \
267285
}
268286

269287
# Change forum references from forum.image.net to forum.image.sc.
288+
debug "Checking correctness of forum URL references"
270289
if grep -q 'https*://forum.imagej.net' pom.xml >/dev/null 2>/dev/null
271290
then
272291
echo "================================================================"
@@ -280,6 +299,7 @@ then
280299
fi
281300

282301
# Ensure that references to forum.image.sc use /tag/, not /tags/.
302+
debug "Checking correctness of forum tag references"
283303
if grep -q forum.image.sc/tags/ pom.xml >/dev/null 2>/dev/null
284304
then
285305
echo "=================================================================="
@@ -294,6 +314,7 @@ fi
294314

295315
# Ensure license headers are up-to-date.
296316
test "$SKIP_LICENSE_UPDATE" -o -z "$licenseName" -o "$licenseName" = "N/A" || {
317+
debug "Ensuring that license headers are up-to-date"
297318
mvn license:update-project-license license:update-file-header &&
298319
git add LICENSE.txt || die 'Failed to update copyright blurbs.
299320
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.'
308329
}
309330

310331
# Prepare new release without pushing (requires the release plugin >= 2.1).
332+
debug "Preparing new release"
311333
$DRY_RUN mvn $BATCH_MODE release:prepare -DpushChanges=false -Dresume=false $TAG \
312334
$PROFILE $DEV_VERSION -DreleaseVersion="$VERSION" \
313335
"-Darguments=-Dgpg.skip=true ${EXTRA_ARGS# }" ||
@@ -317,6 +339,7 @@ Use "mvn javadoc:javadoc | grep error" to check for javadoc syntax errors.'
317339
# Squash the maven-release-plugin's two commits into one.
318340
if test -z "$DRY_RUN"
319341
then
342+
debug "Squashing release commits"
320343
test "[maven-release-plugin] prepare for next development iteration" = \
321344
"$(git show -s --format=%s HEAD)" ||
322345
die "maven-release-plugin's commits are unexpectedly missing!"
@@ -328,6 +351,7 @@ then
328351
fi &&
329352

330353
# Extract the name of the new tag.
354+
debug "Extracting new tag name"
331355
if test -z "$DRY_RUN"
332356
then
333357
tag=$(sed -n 's/^scm.tag=//p' < release.properties)
@@ -336,6 +360,7 @@ else
336360
fi &&
337361

338362
# Rewrite the tag to include release.properties.
363+
debug "Rewriting tag to include release.properties"
339364
test -n "$tag" &&
340365
# HACK: SciJava projects use SSH (git@github.com:...) for developerConnection.
341366
# The release:perform command wants to use the developerConnection URL when
@@ -355,9 +380,13 @@ $DRY_RUN git checkout @{-1} &&
355380
# Push the current branch and the tag.
356381
if test -z "$SKIP_PUSH"
357382
then
383+
debug "Pushing changes"
358384
$DRY_RUN git push "$REMOTE" HEAD $tag
359385
fi
360386

361387
# Remove files generated by the release process. They can end up
362388
# committed to the mainline branch and hosing up later releases.
389+
debug "Cleaning up"
363390
$DRY_RUN rm -f release.properties pom.xml.releaseBackup
391+
392+
debug "Release complete!"

0 commit comments

Comments
 (0)