From ec7b1b288e89783e97eadde69d9729e9291104f4 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Wed, 16 Nov 2022 17:32:37 +0100 Subject: [PATCH] #1882 - Switching to Github actions for CI and releases. --- .github/workflows/build.yaml | 33 +++ .github/workflows/docs.yaml | 33 +++ .github/workflows/milestone.yaml | 40 +++ .github/workflows/release.yaml | 45 +++ Jenkinsfile | 149 ---------- ci/Dockerfile | 8 - ci/build-and-deploy-to-artifactory.sh | 10 - ci/build-and-deploy-to-maven-central.sh | 25 -- ci/create-release.sh | 22 -- ci/test.sh | 5 - ci/version.sh | 14 - pom.xml | 347 +++++------------------- src/docs/resources/assemblies/docs.xml | 2 +- 13 files changed, 227 insertions(+), 506 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/docs.yaml create mode 100644 .github/workflows/milestone.yaml create mode 100644 .github/workflows/release.yaml delete mode 100644 Jenkinsfile delete mode 100644 ci/Dockerfile delete mode 100755 ci/build-and-deploy-to-artifactory.sh delete mode 100755 ci/build-and-deploy-to-maven-central.sh delete mode 100755 ci/create-release.sh delete mode 100755 ci/test.sh delete mode 100755 ci/version.sh diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 00000000..0e35797d --- /dev/null +++ b/.github/workflows/build.yaml @@ -0,0 +1,33 @@ +name: CI Build + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + name: Build project + runs-on: ubuntu-latest + + steps: + + - name: Check out sources + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 17 + cache: 'maven' + + - name: Build with Maven + run: ./mvnw -B + + - name: Deploy to Artifactory + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: ./mvnw -B clean deploy -Pci,artifactory diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml new file mode 100644 index 00000000..a2b96c10 --- /dev/null +++ b/.github/workflows/docs.yaml @@ -0,0 +1,33 @@ +name: Publish Documentation + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * *' + + +jobs: + build: + name: Publish documentation + runs-on: ubuntu-latest + + steps: + + - name: Check out sources + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 17 + cache: 'maven' + + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v1 + + - name: Deploy documentation + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: ./mvnw -B clean deploy -Pdocumentation diff --git a/.github/workflows/milestone.yaml b/.github/workflows/milestone.yaml new file mode 100644 index 00000000..19de1615 --- /dev/null +++ b/.github/workflows/milestone.yaml @@ -0,0 +1,40 @@ +name: Release Milestones + +on: + push: + branches: [ release/milestone ] + +jobs: + build: + name: Release project + runs-on: ubuntu-latest + + steps: + + - name: Check out sources + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 17 + cache: 'maven' + + - name: Build with Maven + run: ./mvnw -B + + - name: Deploy to Artifactory + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: ./mvnw -B clean deploy -Pci,artifactory + + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v1 + + - name: Deploy documentation + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: ./mvnw -B clean deploy -Pdocumentation diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 00000000..3b8fe547 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,45 @@ +name: Release to Maven Central + +on: + push: + branches: [ release/release ] + +jobs: + build: + name: Release project + runs-on: ubuntu-latest + + steps: + + - name: Check out sources + uses: actions/checkout@v2 + + - name: Set up JDK 17 + uses: actions/setup-java@v2 + with: + distribution: 'temurin' + java-version: 17 + cache: 'maven' + + - name: Install GPG key + run: | + echo "${{ secrets.GPG_PRIVATE_KEY }}" > gpg.asc + echo "${{ secrets.GPG_PASSPHRASE }}" | gpg --batch --yes --passphrase-fd 0 --import gpg.asc + + - name: Release to Sonatype OSSRH + env: + SONATYPE_USER: ${{ secrets.OSSRH_S01_TOKEN_USERNAME }} + SONATYPE_PASSWORD: ${{ secrets.OSSRH_S01_TOKEN_PASSWORD }} + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: | + ./mvnw -B clean install -DskipTests + ./mvnw -B clean deploy -Pci,sonatype -s settings.xml + + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v1 + + - name: Deploy documentation + env: + ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} + ARTIFACTORY_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} + run: ./mvnw -B clean deploy -Pdocumentation diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index ebf7220a..00000000 --- a/Jenkinsfile +++ /dev/null @@ -1,149 +0,0 @@ -pipeline { - agent none - - triggers { - pollSCM 'H/3 * * * *' - } - - options { - disableConcurrentBuilds() - buildDiscarder(logRotator(numToKeepStr: '14')) - } - - stages { - stage('Publish OpenJDK 17 + Graphviz + jq docker image') { - when { - changeset "ci/Dockerfile" - } - agent any - - steps { - script { - def image = docker.build("springci/spring-hateoas-openjdk17-with-graphviz-and-jq", "ci/") - docker.withRegistry('', 'hub.docker.com-springbuildmaster') { - image.push() - } - } - } - } - - stage("test: baseline (JDK 17)") { - agent { - docker { - image 'openjdk:17' - args '-v $HOME/.m2:/tmp/jenkins-home/.m2' - } - } - options { timeout(time: 30, unit: 'MINUTES') } - steps { - sh 'PROFILE=none ci/test.sh' - } - } - - stage("test: compatibility (JDK 17, Spring.next)") { - agent { - docker { - image 'openjdk:17' - args '-v $HOME/.m2:/tmp/jenkins-home/.m2' - } - } - options { timeout(time: 30, unit: 'MINUTES') } - steps { - sh 'PROFILE=spring-next ci/test.sh' - } - } - - stage('Deploy') { - agent { - docker { - image 'springci/spring-hateoas-openjdk17-with-graphviz-and-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 { - PROJECT_VERSION = sh( - script: "ci/version.sh", - returnStdout: true - ).trim() - - RELEASE_TYPE = 'snapshot' - - if (PROJECT_VERSION.matches(/.*-RC[0-9]+$/) || PROJECT_VERSION.matches(/.*-M[0-9]+$/)) { - RELEASE_TYPE = "milestone" - } else if (PROJECT_VERSION.endsWith('SNAPSHOT')) { - RELEASE_TYPE = 'snapshot' - } else if (PROJECT_VERSION.matches(/.*\.[0-9]+$/)) { - RELEASE_TYPE = 'release' - } - - if (RELEASE_TYPE == 'release') { - sh "PROFILE=ci,central ci/build-and-deploy-to-maven-central.sh ${PROJECT_VERSION}" - - slackSend( - color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger', - channel: '#spring-hateoas', - message: "@here Spring HATEOAS ${PROJECT_VERSION} is staged on Sonatype awaiting closure and release.") - } else { - sh "PROFILE=ci,${RELEASE_TYPE} ci/build-and-deploy-to-artifactory.sh" - } - } - } - } - stage('Release documentation') { - when { - anyOf { - branch 'main' - branch 'release' - } - } - agent { - docker { - image 'springci/spring-hateoas-openjdk17-with-graphviz-and-jq:latest' - args '-v $HOME/.m2:/tmp/jenkins-home/.m2' - } - } - options { timeout(time: 20, unit: 'MINUTES') } - - environment { - ARTIFACTORY = credentials('02bd1690-b54f-4c9f-819d-a77cb7a9822c') - } - - steps { - script { - sh 'MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -Pci,distribute ' + - '-Dartifactory.server=https://repo.spring.io ' + - "-Dartifactory.username=${ARTIFACTORY_USR} " + - "-Dartifactory.password=${ARTIFACTORY_PSW} " + - "-Dartifactory.distribution-repository=temp-private-local " + - '-Dmaven.test.skip=true deploy -B' - } - } - } - } - - post { - changed { - script { - slackSend( - color: (currentBuild.currentResult == 'SUCCESS') ? 'good' : 'danger', - channel: '#spring-hateoas', - message: "${currentBuild.fullDisplayName} - `${currentBuild.currentResult}`\n${env.BUILD_URL}") - emailext( - subject: "[${currentBuild.fullDisplayName}] ${currentBuild.currentResult}", - mimeType: 'text/html', - recipientProviders: [[$class: 'CulpritsRecipientProvider'], [$class: 'RequesterRecipientProvider']], - body: "${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}") - } - } - } -} diff --git a/ci/Dockerfile b/ci/Dockerfile deleted file mode 100644 index d91fe0e3..00000000 --- a/ci/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -FROM openjdk:17-bullseye - -RUN sed -i -e 's/http/https/g' /etc/apt/sources.list - -RUN apt-get update && apt-get install -y graphviz jq gpg - -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 deleted file mode 100755 index 1c6b6d1e..00000000 --- a/ci/build-and-deploy-to-artifactory.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -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 deleted file mode 100755 index 81ccbb4c..00000000 --- a/ci/build-and-deploy-to-maven-central.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/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 HATEOAS ${PROJECT_VERSION}" \ - clean deploy -B \ No newline at end of file diff --git a/ci/create-release.sh b/ci/create-release.sh deleted file mode 100755 index 948eace2..00000000 --- a/ci/create-release.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -ISSUE=$1 -RELEASE=$2 -SNAPSHOT=$3 - -# Bump up the version in pom.xml to the desired version and commit the change -./mvnw versions:set -DnewVersion=$RELEASE -DgenerateBackupPoms=false -git add . -git commit --message "#$ISSUE - Releasing Spring HATEOAS $RELEASE." - -# Tag the release -git tag -s $RELEASE -m "$RELEASE" - -# Bump up the version in pom.xml to the next snapshot -./mvnw versions:set -DnewVersion=$SNAPSHOT -DgenerateBackupPoms=false -git add . -git commit --message "#$ISSUE - Continue development on $SNAPSHOT." - - diff --git a/ci/test.sh b/ci/test.sh deleted file mode 100755 index 9effba2f..00000000 --- a/ci/test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/jenkins-home" ./mvnw -P${PROFILE} clean dependency:list test -Dsort -B diff --git a/ci/version.sh b/ci/version.sh deleted file mode 100755 index 3e9fb1ba..00000000 --- a/ci/version.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/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 04f636e5..316daab2 100644 --- a/pom.xml +++ b/pom.xml @@ -151,26 +151,35 @@ - - - - sonarqube - + artifactory + + true + - org.jacoco - jacoco-maven-plugin - ${jacoco} - - ${jacoco.destfile} - + org.jfrog.buildinfo + artifactory-maven-plugin + ${artifactory-maven-plugin.version} + false - jacoco-initialize + deploy-to-artifactory - prepare-agent + publish + + + https://repo.spring.io + ${env.ARTIFACTORY_USERNAME} + ${env.ARTIFACTORY_PASSWORD} + libs-milestone-local + libs-snapshot-local + + + CI build for Spring Modulith ${project.version} + + @@ -178,22 +187,54 @@ + + sonatype + + true + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + verify + + sign + + + + + ${env.GPG_PASSPHRASE} + + + + + + + sonatype-new + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 + + + + - distribute + documentation ${project.build.directory}/generated-docs true true - true true true - true @@ -221,47 +262,6 @@ - - org.apache.maven.plugins - maven-antrun-plugin - 1.8 - - - - rename-reference-docs - package - - - - - - - - - - - - - - - - - - - - - - - - run - - - - - - - @@ -297,16 +297,16 @@ process-asciidoc - index.adoc - spring-html - ${generated-docs.directory} - highlight.js - - js/highlight - github - left - - + spring-html + src/main/asciidoc + index.adoc + ${generated-docs.directory}/html + + highlight.js + js/highlight + github + + @@ -337,6 +337,7 @@ org.apache.maven.plugins maven-assembly-plugin + 3.4.2 docs @@ -369,9 +370,6 @@ deploy - - false - spring-hateoas-docs spring-hateoas-docs @@ -384,12 +382,12 @@ 1 - {{artifactory.server}} - {{artifactory.username}} - {{artifactory.password}} - {{artifactory.distribution-repository}} - {{artifactory.distribution-repository}} + https://repo.spring.io *-docs.zip + ${env.ARTIFACTORY_USERNAME} + ${env.ARTIFACTORY_PASSWORD} + temp-private-local + temp-private-local @@ -399,203 +397,6 @@ - - snapshot - - - - - org.jfrog.buildinfo - artifactory-maven-plugin - ${artifactory-maven-plugin.version} - false - - - build-info - - publish - - - - {{BUILD_URL}} - - - spring-hateoas - spring-hateoas - false - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-snapshot-local - libs-snapshot-local - - - - - - - - - - - milestone - - - - - org.jfrog.buildinfo - artifactory-maven-plugin - ${artifactory-maven-plugin.version} - false - - - build-info - - publish - - - - {{BUILD_URL}} - - - spring-hateoas - spring-hateoas - false - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-milestone-local - libs-milestone-local - - - - - - - - - - - release - - - - - org.jfrog.buildinfo - artifactory-maven-plugin - ${artifactory-maven-plugin.version} - false - - - build-info - - publish - - - - {{BUILD_URL}} - - - spring-hateoas - spring-hateoas - false - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-release-local - libs-release-local - - - - - - - - - - - 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.apache.maven.plugins - maven-gpg-plugin - - - - org.sonatype.plugins - nexus-staging-maven-plugin - - - - - - - - - sonatype - https://s01.oss.sonatype.org//service/local/staging/deploy/maven2/ - - - - - - @@ -875,6 +676,8 @@ + verify + org.apache.maven.wagon diff --git a/src/docs/resources/assemblies/docs.xml b/src/docs/resources/assemblies/docs.xml index cd32fb1b..eee3ef29 100644 --- a/src/docs/resources/assemblies/docs.xml +++ b/src/docs/resources/assemblies/docs.xml @@ -25,7 +25,7 @@ Adds reference manual (html and pdf) to the distribution archive under the 'docs/reference' directory see pom.xml 'maven-javadoc-plugin' declaration. --> - target/site/reference + target/generated-docs reference