Skip to content

Commit b323af0

Browse files
committed
CI: add build logic to deploy releases to Sonatype
1 parent 5789b91 commit b323af0

File tree

1 file changed

+37
-2
lines changed

1 file changed

+37
-2
lines changed

.github/build.sh

+37-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
11
#!/bin/sh
2-
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-build.sh
3-
sh ci-build.sh
2+
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-build.sh &&
3+
sh ci-build.sh && {
4+
die() { echo "[ERROR] $1"; exit 1; }
5+
6+
echo
7+
echo "== Extracting ImageJ version from source code =="
8+
version=$(grep -o ' VERSION *= *"[^"]*' ij/ImageJ.java) ||
9+
die "Failed to extract version from ij/ImageJ.java"
10+
build=$(grep -o ' BUILD *= *"[^"]*' ij/ImageJ.java) ||
11+
die "Failed to extract build number from ij/ImageJ.java"
12+
version=${version#*\"}
13+
build=${build#*\"}
14+
echo "VERSION = $version"
15+
echo "BUILD = $build"
16+
17+
if [ "$build" = "" ]
18+
then
19+
# Sanity checks.
20+
test "$version" || die "Empty version string!"
21+
echo "$version" | grep -q '^[0-9]\+\.[0-9]\+[a-z]$' ||
22+
die "Unexpected format for version string $version"
23+
24+
echo
25+
echo "== Releasing ImageJ v$version =="
26+
27+
# Tweak the Maven POM to reflect the release version.
28+
cat pom.xml | sed -e "s/1\.x-SNAPSHOT/$version/" -e "s/<tag>HEAD</<tag>v$version</" > pom.new &&
29+
mv -f pom.new pom.xml ||
30+
die "Failed to adjust pom.xml to match release version $version"
31+
32+
# Deploy the release.
33+
mvn -Psonatype-oss-release -B -Djdk.tls.client.protocols="TLSv1,TLSv1.1,TLSv1.2" deploy
34+
else
35+
echo
36+
echo "== Skipping release for daily build $version$build =="
37+
fi
38+
}

0 commit comments

Comments
 (0)