Skip to content

Commit 5c09247

Browse files
committed
ci-build.sh: fail fast on bad version strings
It is incorrect to push a release version string to the main branch directly, such that the CI deploys it directly. Rather, the release-version.sh script should be used to cut releases. The build script now checks for this situation where the version string is a release version but release.properties is missing, and fails the build immediately.
1 parent 2e16216 commit 5c09247

1 file changed

Lines changed: 32 additions & 2 deletions

File tree

ci-build.sh

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,40 @@ EOL
100100
elif [ "$BUILD_REPOSITORY" -a "$BUILD_REPOSITORY" != "$scmURL" ]; then
101101
echo "No deploy -- repository fork: $BUILD_REPOSITORY != $scmURL"
102102
else
103-
echo "All checks passed for artifact deployment"
104-
deployOK=1
103+
# Are we building a snapshot version, or a release version?
104+
version=$(mvn -q -Denforcer.skip=true -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive validate exec:exec 2>&1)
105+
result=$?
106+
checkSuccess $result
107+
if [ $result -ne 0 ]; then
108+
echo "No deploy -- could not extract version string"
109+
echo "Output of failed attempt follows:"
110+
echo "$version"
111+
else
112+
case "$version" in
113+
*-SNAPSHOT)
114+
# Snapshot version -- ensure release.properties not present.
115+
if [ -f release.properties ]; then
116+
echo "[ERROR] Spurious release.properties file is present"
117+
echo "Remove the file from version control and try again."
118+
exit 1
119+
fi
120+
;;
121+
*)
122+
# Release version -- ensure release.properties is present.
123+
if [ ! -f release.properties ]; then
124+
echo "[ERROR] Release version, but release.properties not found"
125+
echo "You must use release-version.sh to release -- see https://imagej.net/develop/releasing"
126+
exit 1
127+
fi
128+
;;
129+
esac
130+
deployOK=1
131+
fi
105132
fi
106133
fi
134+
if [ "$deployOK" ]; then
135+
echo "All checks passed for artifact deployment"
136+
fi
107137

108138
# Install GPG on macOS
109139
if [ "$MACOS" ]; then

0 commit comments

Comments
 (0)