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

97
Jenkinsfile vendored
View File

@@ -26,6 +26,7 @@ pipeline {
}
}
}
stage("Test: baseline (jdk8)") {
agent {
docker {
@@ -37,6 +38,7 @@ pipeline {
sh "PROFILE=distribute,convergence ci/test.sh"
}
}
stage("Test other configurations") {
parallel {
stage("Test: springnext (jdk8)") {
@@ -162,16 +164,21 @@ pipeline {
}
}
}
stage('Deploy to Artifactory') {
stage('Deploy') {
agent {
docker {
image 'adoptopenjdk/openjdk8:latest'
args '-v $HOME/.m2:/root/.m2'
image 'springci/spring-ws-openjdk8-with-jq:latest'
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
}
}
options { timeout(time: 20, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
SONATYPE = credentials('oss-login')
KEYRING = credentials('spring-signing-secring.gpg')
PASSPHRASE = credentials('spring-gpg-passphrase')
}
steps {
@@ -190,36 +197,36 @@ pipeline {
RELEASE_TYPE = 'snapshot'
} else if (PROJECT_VERSION.endsWith('RELEASE')) {
RELEASE_TYPE = 'release'
} else {
RELEASE_TYPE = 'snapshot'
}
OUTPUT = sh(
script: "PROFILE=distribute,docs,${RELEASE_TYPE} ci/build.sh",
returnStdout: true
).trim()
echo "$OUTPUT"
if (RELEASE_TYPE == 'release') {
sh "PROFILE=distribute,central USERNAME=${SONATYPE_USR} PASSWORD=${SONATYPE_PSW} ci/build-and-deploy-to-maven-central.sh ${PROJECT_VERSION}"
build_info_path = OUTPUT.split('\n')
.find { it.contains('Artifactory Build Info Recorder') }
.split('Saving Build Info to ')[1]
.trim()[1..-2]
dir(build_info_path + '/..') {
stash name: 'build_info', includes: "*.json"
slackSend(
color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger',
channel: '#spring-ws',
message: "@here Spring WS ${PROJECT_VERSION} is staged on Sonatype awaiting closure and release.")
} else {
sh "PROFILE=distribute,${RELEASE_TYPE} ci/build-and-deploy-to-artifactory.sh"
}
}
}
}
stage('Promote to Bintray') {
stage('Release documentation') {
when {
branch 'release-3.x'
}
agent {
docker {
image 'springci/spring-ws-openjdk8-with-jq:latest'
args '-v $HOME/.m2:/root/.m2'
image 'adoptopenjdk/openjdk8:latest'
args '-v $HOME/.m2:/tmp/jenkins-home/.m2'
}
}
options { timeout(time: 20, unit: 'MINUTES') }
environment {
ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c')
@@ -227,55 +234,13 @@ pipeline {
steps {
script {
// Warm up this plugin quietly before using it.
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
PROJECT_VERSION = sh(
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
returnStdout: true
).trim()
if (PROJECT_VERSION.endsWith('RELEASE')) {
unstash name: 'build_info'
sh "ci/promote-to-bintray.sh"
} else {
echo "${PROJECT_VERSION} is not a candidate for promotion to Bintray."
}
}
}
}
stage('Sync to Maven Central') {
when {
branch 'release-3.x'
}
agent {
docker {
image 'springci/spring-ws-openjdk8-with-jq:latest'
args '-v $HOME/.m2:/root/.m2'
}
}
environment {
BINTRAY = credentials('Bintray-spring-operator')
SONATYPE = credentials('oss-token')
}
steps {
script {
// Warm up this plugin quietly before using it.
sh "./mvnw -q org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version"
PROJECT_VERSION = sh(
script: "./mvnw org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version -o | grep -v INFO",
returnStdout: true
).trim()
if (PROJECT_VERSION.endsWith('RELEASE')) {
unstash name: 'build_info'
sh "ci/sync-to-maven-central.sh"
} else {
echo "${PROJECT_VERSION} is not a candidate for syncing to Maven Central."
}
sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pdistribute,docs ' +
'-Dartifactory.server=https://repo.spring.io ' +
"-Dartifactory.username=${ARTIFACTORY_USR} " +
"-Dartifactory.password=${ARTIFACTORY_PSW} " +
"-Dartifactory.distribution-repository=temp-private-local " +
'-Dmaven.test.skip=true -Dmaven.deploy.skip=true deploy -B'
}
}
}

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

27
docs.xml Normal file
View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 https://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>docs</id>
<formats>
<format>dir</format>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<!--
Adds reference manual (html and pdf) to the distribution archive
under the 'docs/reference' directory see pom.xml 'maven-javadoc-plugin' declaration.
-->
<directory>target/site/reference</directory>
<outputDirectory>reference</outputDirectory>
</fileSet>
<fileSet>
<!--
Adds javadoc html to the distribution archive under the 'docs/javadoc'
directory see pom.xml 'maven-javadoc-plugin' declaration.
-->
<directory>target/site/apidocs</directory>
<outputDirectory>api</outputDirectory>
</fileSet>
</fileSets>
</assembly>

226
pom.xml
View File

@@ -501,45 +501,85 @@
</profile>
<profile>
<id>release</id>
<id>central</id>
<properties>
<maven.main.skip>true</maven.main.skip>
<maven.test.skip>true</maven.test.skip>
<maven.kotlin.skip>true</maven.kotlin.skip>
<maven.install.skip>true</maven.install.skip>
<skipTests>true</skipTests>
</properties>
<build>
<pluginManagement>
<plugins>
<!-- Sign JARs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- Deploy to Sonatype OSS Nexus -->
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.8</version>
<extensions>true</extensions>
<configuration>
<serverId>sonatype</serverId>
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>false</autoReleaseAfterClose>
<keepStagingRepositoryOnFailure>true</keepStagingRepositoryOnFailure>
<skipStagingRepositoryClose>true</skipStagingRepositoryClose>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<inherited>false</inherited>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>publish</goal>
</goals>
<configuration>
<buildInfo>
<buildUrl>{{BUILD_URL}}</buildUrl>
</buildInfo>
<deployProperties>
<zip.name>spring-ws</zip.name>
<zip.displayname>spring-ws</zip.displayname>
<zip.deployed>false</zip.deployed>
<zip.type>docs</zip.type>
<archives>*:*:*:*@zip</archives>
</deployProperties>
<publisher>
<contextUrl>https://repo.spring.io</contextUrl>
<username>{{ARTIFACTORY_USR}}</username>
<password>{{ARTIFACTORY_PSW}}</password>
<repoKey>libs-release-local</repoKey>
<snapshotRepoKey>libs-release-local</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>sonatype</id>
<url>https://s01.oss.sonatype.org//service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
<profile>
@@ -671,83 +711,82 @@
<execution>
<id>aggregate</id>
<goals>
<goal>aggregate-jar</goal>
<goal>aggregate</goal>
</goals>
<phase>prepare-package</phase>
<inherited>false</inherited>
<configuration>
<outputDirectory>${project.root}/target/site/apidocs</outputDirectory>
</configuration>
</execution>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
Creates two zip files for download as well as API and reference documentation distribution.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>ant-contrib</groupId>
<artifactId>ant-contrib</artifactId>
<version>1.0b3</version>
<exclusions>
<exclusion>
<groupId>ant</groupId>
<artifactId>ant</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.8.1</version>
</dependency>
<dependency>
<groupId>org.tigris.antelope</groupId>
<artifactId>antelopetasks</artifactId>
<version>3.2.10</version>
</dependency>
</dependencies>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>package-and-attach-docs-zip</id>
<id>docs</id>
<goals>
<goal>run</goal>
<goal>single</goal>
</goals>
<phase>package</phase>
<inherited>false</inherited>
<configuration>
<tasks>
<zip destfile="${project.build.directory}/${project.artifactId}-${project.version}.zip">
<zipfileset
src="${project.build.directory}/${project.artifactId}-${project.version}-javadoc.jar"
prefix="api"/>
<zipfileset dir="${project.build.directory}/site/reference/html"
prefix="reference"/>
<zipfileset dir="${project.build.directory}/generated-docs"
includes="index.pdf"/>
</zip>
</tasks>
<descriptors>
<descriptor>docs.xml</descriptor>
</descriptors>
<finalName>spring-ws-${project.version}</finalName>
<appendAssemblyId>true</appendAssemblyId>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.10</version>
<inherited>false</inherited>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>2.6.1</version>
<executions>
<execution>
<id>attach-zip</id>
<id>deploy-docs</id>
<goals>
<goal>attach-artifact</goal>
<goal>publish</goal>
</goals>
<phase>deploy</phase>
<configuration>
<artifacts>
<artifact>
<file>
${project.build.directory}/${project.artifactId}-${project.version}.zip
</file>
<type>zip;zip.type=docs;zip.deployed=false</type>
</artifact>
</artifacts>
<artifactory>
<includeEnvVars>false</includeEnvVars>
</artifactory>
<deployProperties>
<zip.name>spring-ws-docs</zip.name>
<zip.displayname>spring-ws-docs</zip.displayname>
<zip.deployed>false</zip.deployed>
<zip.type>docs</zip.type>
</deployProperties>
<buildInfo>
<!-- Retain only a single build -->
<buildName>Spring Docs spring-ws ${project.version}</buildName>
<buildRetentionCount>1</buildRetentionCount>
</buildInfo>
<publisher>
<contextUrl>{{artifactory.server}}</contextUrl>
<username>{{artifactory.username}}</username>
<password>{{artifactory.password}}</password>
<repoKey>{{artifactory.distribution-repository}}</repoKey>
<snapshotRepoKey>{{artifactory.distribution-repository}}</snapshotRepoKey>
<includePatterns>*-docs.zip</includePatterns>
</publisher>
</configuration>
</execution>
</executions>
@@ -756,23 +795,6 @@
</build>
</profile>
<profile>
<id>central</id>
<distributionManagement>
<snapshotRepository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Nexus Release Repository</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
<profile>
<id>java11</id>

14
settings.xml Normal file
View File

@@ -0,0 +1,14 @@
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
https://maven.apache.org/xsd/settings-1.0.0.xsd">
<servers>
<server>
<id>sonatype</id>
<username>${env.USERNAME}</username>
<password>${env.PASSWORD}</password>
</server>
</servers>
</settings>

View File

@@ -202,4 +202,32 @@
</dependencies>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -208,7 +208,34 @@
</exclusions>
</dependency>
</dependencies>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -127,4 +127,32 @@
</dependencies>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -48,4 +48,32 @@
</dependencies>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View File

@@ -41,4 +41,32 @@
</dependencies>
<profiles>
<profile>
<id>docs</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>docs</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<skipAssembly>true</skipAssembly>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>