Deploy releases directly to maven central on the new Sonatype infrastructure..

To reduce risk of a release getting stuck in an intermediate state on bintray, make all official releases to maven central.

Resolves #1180.
This commit is contained in:
Greg L. Turnquist
2021-01-08 12:04:09 -06:00
parent 1c25bde277
commit 8ee2ada5ac
16 changed files with 375 additions and 241 deletions

View File

@@ -1,6 +1,6 @@
FROM adoptopenjdk/openjdk8:latest
RUN apt-get update && apt-get install -y jq
RUN apt-get update && apt-get install -y jq gpg
RUN apt-get clean \
&& rm -rf /var/lib/apt/lists/*

View File

@@ -0,0 +1,11 @@
#!/bin/bash -x
set -euo pipefail
#
# Deploy the artifactory
#
echo 'Deploying to Artifactory...'
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \
./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B

View File

@@ -0,0 +1,25 @@
#!/bin/bash -x
set -euo pipefail
PROJECT_VERSION=$1
#
# Stage on Maven Central
#
echo 'Staging on Maven Central...'
GNUPGHOME=/tmp/gpghome
export GNUPGHOME
mkdir $GNUPGHOME
cp $KEYRING $GNUPGHOME
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \
-s settings.xml \
-P${PROFILE} \
-Dmaven.test.skip=true \
-Dgpg.passphrase=${PASSPHRASE} \
-Dgpg.secretKeyring=${GNUPGHOME}/secring.gpg \
-DstagingDescription="Releasing ${PROJECT_VERSION}" \
clean deploy -B

View File

@@ -1,5 +0,0 @@
#!/bin/bash
set -euo pipefail
./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B

View File

@@ -1,42 +0,0 @@
#!/bin/bash
set -e -u
buildName=`jq -r '.name' build-info.json`
buildNumber=`jq -r '.number' build-info.json`
groupId=`jq -r '.modules[0].id' build-info.json | sed 's/\(.*\):.*:.*/\1/'`
version=`jq -r '.modules[0].id' build-info.json | sed 's/.*:.*:\(.*\)/\1/'`
echo "Promoting ${buildName}/${buildNumber}/${groupId}/${version} to libs-release-local"
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${ARTIFACTORY_USR}:${ARTIFACTORY_PSW} \
-H 'Content-type:application/json' \
-d '{"sourceRepos": ["libs-release-local"], "targetRepo" : "spring-distributions", "async":"true"}' \
-f \
-X \
POST "https://repo.spring.io/api/build/distribute/${buildName}/${buildNumber}" > /dev/null || { echo "Failed to distribute" >&2; exit 1; }
echo "Waiting for artifacts to be published"
ARTIFACTS_PUBLISHED=false
WAIT_TIME=10
COUNTER=0
while [ $ARTIFACTS_PUBLISHED == "false" ] && [ $COUNTER -lt 120 ]; do
result=$( curl -s https://api.bintray.com/packages/spring/jars/"${groupId}" )
versions=$( echo "$result" | jq -r '.versions' )
exists=$( echo "$versions" | grep "$version" -o || true )
if [ "$exists" = "$version" ]; then
ARTIFACTS_PUBLISHED=true
fi
COUNTER=$(( COUNTER + 1 ))
sleep $WAIT_TIME
done

View File

@@ -1,23 +0,0 @@
#!/bin/bash
set -e -u
buildName=`jq -r '.name' build-info.json`
buildNumber=`jq -r '.number' build-info.json`
groupId=`jq -r '.modules[0].id' build-info.json | sed 's/\(.*\):.*:.*/\1/'`
version=`jq -r '.modules[0].id' build-info.json | sed 's/.*:.*:\(.*\)/\1/'`
echo "Synching ${buildName}/${buildNumber}/${groupId}/${version} to Maven Central..."
curl \
-s \
--connect-timeout 240 \
--max-time 2700 \
-u ${BINTRAY_USR}:${BINTRAY_PSW} \
-H 'Content-Type: application/json' \
-d "{ \"username\": \"${SONATYPE_USR}\", \"password\": \"${SONATYPE_PSW}\"}" \
-f \
-X \
POST "https://api.bintray.com/maven_central_sync/spring/jars/${groupId}/versions/${version}" > /dev/null || { echo "Failed to sync" >&2; exit 1; }
echo "Sync complete"

View File

@@ -2,4 +2,5 @@
set -euo pipefail
./mvnw -P${PROFILE} clean dependency:list test -Dsort -B
MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \
./mvnw -P${PROFILE} clean dependency:list test -Dsort -B