diff --git a/Jenkinsfile b/Jenkinsfile index 1a5daf3..5018fe6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,26 +10,11 @@ pipeline { } stages { - stage('Publish OpenJDK 8 + jq docker image') { - when { - changeset "ci/Dockerfile" - } - agent any - - steps { - script { - def image = docker.build("springci/spring-session-data-mongodb-openjdk8-with-jq", "ci/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - image.push() - } - } - } - } stage("Test: baseline (jdk8)") { agent { docker { image 'adoptopenjdk/openjdk8:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } steps { @@ -42,7 +27,7 @@ pipeline { agent { docker { image 'adoptopenjdk/openjdk8:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } steps { @@ -53,7 +38,7 @@ pipeline { agent { docker { image 'adoptopenjdk/openjdk11:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } steps { @@ -64,7 +49,7 @@ pipeline { agent { docker { image 'adoptopenjdk/openjdk11:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } steps { @@ -75,7 +60,7 @@ pipeline { agent { docker { image 'adoptopenjdk/openjdk13:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } steps { @@ -86,7 +71,7 @@ pipeline { agent { docker { image 'adoptopenjdk/openjdk13:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } steps { @@ -95,25 +80,26 @@ pipeline { } } } - stage('Deploy to Artifactory') { + stage('Deploy') { agent { docker { - image 'adoptopenjdk/openjdk8:latest' - args '-v $HOME/.m2:/root/.m2' + image 'springci/spring-session-data-mongodb-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 { 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", + script: "ci/version.sh", returnStdout: true ).trim() @@ -125,34 +111,30 @@ pipeline { RELEASE_TYPE = 'release' } - OUTPUT = sh( - script: "PROFILE=distribute,docs,${RELEASE_TYPE} ci/build.sh", - returnStdout: true - ).trim() + if (RELEASE_TYPE == 'release') { + sh "PROFILE=central USERNAME=${SONATYPE_USR} PASSWORD=${SONATYPE_PSW} ci/build-and-deploy-to-maven-central.sh ${PROJECT_VERSION}" - echo "$OUTPUT" - - 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-session-bot', + message: "@here Spring Session for MongoDB ${PROJECT_VERSION} is staged on Sonatype awaiting closure and release.") + } else { + sh "PROFILE=${RELEASE_TYPE} ci/build-and-deploy-to-artifactory.sh" } } } } - stage('Promote to Bintray') { + stage('Release documentation') { when { branch 'release-2.2' } agent { docker { image 'springci/spring-session-data-mongodb-openjdk8-with-jq:latest' - args '-v $HOME/.m2:/root/.m2' + args '-v $HOME/.m2:/tmp/jenkins-home/.m2' } } + options { timeout(time: 20, unit: 'MINUTES') } environment { ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') @@ -160,55 +142,12 @@ 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-2.2' - } - agent { - docker { - image 'springci/spring-session-data-mongodb-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 -Pdocs ' + + '-Dartifactory.server=https://repo.spring.io ' + + "-Dartifactory.username=${ARTIFACTORY_USR} " + + "-Dartifactory.password=${ARTIFACTORY_PSW} " + + "-Dartifactory.distribution-repository=temp-private-local " + + 'deploy -B' } } } diff --git a/ci/Dockerfile b/ci/Dockerfile deleted file mode 100644 index b05019d..0000000 --- a/ci/Dockerfile +++ /dev/null @@ -1,6 +0,0 @@ -FROM adoptopenjdk/openjdk8:latest - -RUN apt-get update && apt-get install -y jq - -RUN apt-get clean \ - && rm -rf /var/lib/apt/lists/* diff --git a/ci/build-and-deploy-to-artifactory.sh b/ci/build-and-deploy-to-artifactory.sh new file mode 100755 index 0000000..80e30e0 --- /dev/null +++ b/ci/build-and-deploy-to-artifactory.sh @@ -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 diff --git a/ci/build-and-deploy-to-maven-central.sh b/ci/build-and-deploy-to-maven-central.sh new file mode 100755 index 0000000..653901a --- /dev/null +++ b/ci/build-and-deploy-to-maven-central.sh @@ -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 Spring Session for MongoDB ${PROJECT_VERSION}" \ + clean deploy -B \ No newline at end of file diff --git a/ci/build.sh b/ci/build.sh deleted file mode 100755 index 6a202bb..0000000 --- a/ci/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B diff --git a/ci/promote-to-bintray.sh b/ci/promote-to-bintray.sh deleted file mode 100755 index a00bb8d..0000000 --- a/ci/promote-to-bintray.sh +++ /dev/null @@ -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 diff --git a/ci/sync-to-maven-central.sh b/ci/sync-to-maven-central.sh deleted file mode 100755 index a2d47e8..0000000 --- a/ci/sync-to-maven-central.sh +++ /dev/null @@ -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" diff --git a/ci/test.sh b/ci/test.sh index 68b6ea8..c2bb677 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -1,5 +1,6 @@ -#!/bin/bash +#!/bin/bash -x set -euo pipefail -./mvnw -P${PROFILE} clean dependency:list test -Dsort -U -B +MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" \ + ./mvnw -P${PROFILE} clean dependency:list test -Dsort -U -B diff --git a/ci/version.sh b/ci/version.sh new file mode 100755 index 0000000..3e9fb1b --- /dev/null +++ b/ci/version.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -euo pipefail + +RAW_VERSION=`MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw \ + org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate \ + -Dexpression=project.version -q -DforceStdout` + +# Split things up +VERSION_PARTS=($RAW_VERSION) + +# Grab the last part, which is the actual version number. +echo ${VERSION_PARTS[${#VERSION_PARTS[@]}-1]} + diff --git a/pom.xml b/pom.xml index ac18633..1b68794 100644 --- a/pom.xml +++ b/pom.xml @@ -139,10 +139,128 @@ - distribute + docs + + + true + true + true + 0.1.2.RELEASE + ${project.build.directory}/shared-resources + ${project.build.directory}/generated-asciidoc-sources/source/ + + ${project.build.directory}/generated-docs + + + + + io.spring.docresources + spring-doc-resources + ${docs.resources.version} + zip + true + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + unpack-doc-resources + + unpack-dependencies + + generate-resources + + io.spring.docresources + spring-doc-resources + zip + true + ${generated-asciidoc-sources.directory} + + + + + + + org.asciidoctor + asciidoctor-maven-plugin + 2.0.0-RC.1 + + + org.jruby + jruby + 9.2.6.0 + + + org.asciidoctor + asciidoctorj + 2.0.0-RC.1 + + + org.asciidoctor + asciidoctorj-pdf + 1.5.0-alpha.16 + + + org.asciidoctor + asciidoctorj-epub3 + 1.5.0-alpha.8.1 + + + + + output-html + compile + + process-asciidoc + + + ${generated-asciidoc-sources.directory} + ${generated-docs.directory} + html5 + book + highlight.js + + js/highlight + atom-one-dark-reasonable + true + true + ./css + spring.css + left + v${project.version} + ${basedir} + + https://raw.githubusercontent.com/spring-projects/spring-session-data-mongodb-examples/master + + ${spring-session.version} + + + + + + book + + book + shared + font + false + images + ${project.version} + ${project.name} + ${project.version} + true + 4 + true + + + + org.apache.maven.plugins maven-source-plugin @@ -163,56 +281,15 @@ - attach-javadocs + aggregate-javadoc - jar - - - - - - - - - - docs - - - - - org.asciidoctor - asciidoctor-maven-plugin - 1.5.3 - - - output-html - generate-resources - - process-asciidoc + aggregate + package - ${basedir}/src/main/asciidoc - ${project.build.directory}/content/reference/htmlsingle - html - book - - true - true - v${project.version} - ${basedir} - https://raw.githubusercontent.com/spring-projects/spring-session-data-mongodb-examples/master - ${spring-session.version} - + ${project.root}/target/site/apidocs - - - - maven-javadoc-plugin - - -Xdoclint:none - - attach-javadocs @@ -221,71 +298,174 @@ + org.apache.maven.plugins maven-antrun-plugin - - - ant-contrib - ant-contrib - 1.0b3 - - - ant - ant - - - - - org.apache.ant - ant-nodeps - 1.8.1 - - - org.tigris.antelope - antelopetasks - 3.2.10 - - + 1.8 + - package-and-attach-docs-zip - package + copy-documentation-resources + generate-resources + + + + + + + + + + + + run - - - - - - - - + + + create-generated-docs-resources + process-resources + + + + + + + + + + + + + + + + + + + run + + + + + rename-reference-docs + prepare-package + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + run + + + + + + + - org.codehaus.mojo - build-helper-maven-plugin - 1.10 + org.apache.maven.plugins + maven-assembly-plugin - attach-zip + docs - attach-artifact + single + package - - - ${project.build.directory}/${project.artifactId}-${project.version}.zip - zip;zip.type=docs;zip.deployed=false - - + + src/docs/resources/assemblies/docs.xml + + spring-session-data-mongodb-${project.version} + true + + + + org.jfrog.buildinfo + artifactory-maven-plugin + 2.6.1 + + + deploy-docs + + publish + + deploy + + + false + + + spring-session-data-mongodb-docs + spring-session-data-mongodb-docs + false + docs + + + + Spring Docs spring-session-data-mongodb ${project.version} + 1 + + + {{artifactory.server}} + {{artifactory.username}} + {{artifactory.password}} + {{artifactory.distribution-repository}} + {{artifactory.distribution-repository}} + *-docs.zip + + + + + + @@ -310,13 +490,6 @@ {{BUILD_URL}} - - spring-session-data-mongodb - spring-session-data-mongodb - false - docs - *:*:*:*@zip - https://repo.spring.io {{ARTIFACTORY_USR}} @@ -352,13 +525,6 @@ {{BUILD_URL}} - - spring-session-data-mongodb - spring-session-data-mongodb - false - docs - *:*:*:*@zip - https://repo.spring.io {{ARTIFACTORY_USR}} @@ -375,47 +541,94 @@ - release + central + + + + + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.6 + + + sign-artifacts + verify + + sign + + + + --pinentry-mode + loopback + + + + + + + + + + org.sonatype.plugins + nexus-staging-maven-plugin + 1.6.8 + true + + sonatype + https://s01.oss.sonatype.org/ + false + true + true + + + + + + + - org.jfrog.buildinfo - artifactory-maven-plugin - 2.6.1 - false + maven-javadoc-plugin + + -Xdoclint:none + - build-info + attach-javadocs - publish + jar - - - {{BUILD_URL}} - - - spring-session-data-mongodb - spring-session-data-mongodb - false - docs - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-release-local - libs-release-local - - - - - + + org.apache.maven.plugins + maven-gpg-plugin + + + + org.sonatype.plugins + nexus-staging-maven-plugin + + + + + + + + + sonatype + https://s01.oss.sonatype.org//service/local/staging/deploy/maven2/ + + + + @@ -686,16 +899,22 @@ org.apache.maven.plugins maven-jar-plugin - 2.6 + 3.0.2 - true + + + ${project.name} + ${project.version} + ${java-module-name} + + org.apache.maven.plugins maven-source-plugin - 2.4 + 3.0.1 attach-sources @@ -726,12 +945,18 @@ org.apache.maven.plugins maven-surefire-plugin - 2.22.1 + 3.0.0-M3 false + + org.apache.maven.plugins + maven-deploy-plugin + 2.8.2 + + @@ -756,9 +981,10 @@ - https://github.com/spring-projects/spring-session-mongodb - scm:git:git://github.com/spring-projects/spring-session-mongodb.git - scm:git:ssh://git@github.com:spring-projects/spring-session-mongodb.git + https://github.com/spring-projects/spring-session-data-mongodb + scm:git:git://github.com/spring-projects/spring-session-data-mongodb.git + scm:git:ssh://git@github.com:spring-projects/spring-session-data-mongodb.git + diff --git a/settings.xml b/settings.xml index 829f33c..7368837 100644 --- a/settings.xml +++ b/settings.xml @@ -1,16 +1,11 @@ - sonatype-nexus-snapshots - ${env.USERNAME} - ${env.PASSWORD} - - - sonatype-nexus-staging + sonatype ${env.USERNAME} ${env.PASSWORD} diff --git a/src/docs/resources/assemblies/docs.xml b/src/docs/resources/assemblies/docs.xml new file mode 100644 index 0000000..f8b41cb --- /dev/null +++ b/src/docs/resources/assemblies/docs.xml @@ -0,0 +1,27 @@ + + + docs + + dir + zip + + false + + + + target/site/reference + reference + + + + target/site/apidocs + api + + +