#1882 - Switching to Github actions for CI and releases.

This commit is contained in:
Oliver Drotbohm
2022-11-16 17:32:37 +01:00
parent 2e0b835d80
commit ec7b1b288e
13 changed files with 227 additions and 506 deletions

33
.github/workflows/build.yaml vendored Normal file
View File

@@ -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

33
.github/workflows/docs.yaml vendored Normal file
View File

@@ -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

40
.github/workflows/milestone.yaml vendored Normal file
View File

@@ -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

45
.github/workflows/release.yaml vendored Normal file
View File

@@ -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

149
Jenkinsfile vendored
View File

@@ -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: "<a href=\"${env.BUILD_URL}\">${currentBuild.fullDisplayName} is reported as ${currentBuild.currentResult}</a>")
}
}
}
}

View File

@@ -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/*

View File

@@ -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

View File

@@ -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

View File

@@ -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."

View File

@@ -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

View File

@@ -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]}

347
pom.xml
View File

@@ -151,26 +151,35 @@
</profile>
<profile>
<!-- Profile for SonarQube -->
<id>sonarqube</id>
<id>artifactory</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco}</version>
<configuration>
<destFile>${jacoco.destfile}</destFile>
</configuration>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>${artifactory-maven-plugin.version}</version>
<inherited>false</inherited>
<executions>
<execution>
<id>jacoco-initialize</id>
<id>deploy-to-artifactory</id>
<goals>
<goal>prepare-agent</goal>
<goal>publish</goal>
</goals>
<configuration>
<publisher>
<contextUrl>https://repo.spring.io</contextUrl>
<username>${env.ARTIFACTORY_USERNAME}</username>
<password>${env.ARTIFACTORY_PASSWORD}</password>
<repoKey>libs-milestone-local</repoKey>
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
<buildInfo>
<buildName>CI build for Spring Modulith ${project.version}</buildName>
</buildInfo>
</configuration>
</execution>
</executions>
</plugin>
@@ -178,22 +187,54 @@
</build>
</profile>
<profile>
<id>sonatype</id>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
<configuration>
<passphrase>${env.GPG_PASSPHRASE}</passphrase>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>sonatype-new</id>
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>
</profile>
<profile>
<!--
Profile to be activated when building the docs artifacts.
-->
<id>distribute</id>
<id>documentation</id>
<properties>
<generated-docs.directory>${project.build.directory}/generated-docs</generated-docs.directory>
<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>
<maven.deploy.skip>true</maven.deploy.skip>
<skipTests>true</skipTests>
</properties>
<build>
@@ -221,47 +262,6 @@
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>rename-reference-docs</id>
<phase>package</phase>
<configuration>
<target>
<!-- Copy files for the single-file HTML version -->
<copy failonerror="false"
todir="target/site/reference/html/images">
<fileset dir="${generated-docs.directory}/images"/>
</copy>
<copy failonerror="false" todir="target/site/reference/html/">
<fileset dir="${generated-docs.directory}">
<include name="css/**"/>
<include name="img/**"/>
<include name="js/**"/>
</fileset>
</copy>
<copy failonerror="false" todir="target/site/reference/html/">
<fileset dir="${generated-docs.directory}" includes="*.html"/>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!--
Asciidoctor
-->
@@ -297,16 +297,16 @@
<goal>process-asciidoc</goal>
</goals>
<configuration>
<sourceDocumentName>index.adoc</sourceDocumentName>
<backend>spring-html</backend>
<outputDirectory>${generated-docs.directory}</outputDirectory>
<sourceHighlighter>highlight.js</sourceHighlighter>
<attributes>
<highlightjsdir>js/highlight</highlightjsdir>
<highlightjs-theme>github</highlightjs-theme>
<toc>left</toc>
</attributes>
</configuration>
<backend>spring-html</backend>
<sourceDirectory>src/main/asciidoc</sourceDirectory>
<sourceDocumentName>index.adoc</sourceDocumentName>
<outputDirectory>${generated-docs.directory}/html</outputDirectory>
<attributes>
<source-highlighter>highlight.js</source-highlighter>
<highlightjsdir>js/highlight</highlightjsdir>
<highlightjs-theme>github</highlightjs-theme>
</attributes>
</configuration>
</execution>
</executions>
@@ -337,6 +337,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.4.2</version>
<executions>
<execution>
<id>docs</id>
@@ -369,9 +370,6 @@
</goals>
<phase>deploy</phase>
<configuration>
<artifactory>
<includeEnvVars>false</includeEnvVars>
</artifactory>
<deployProperties>
<zip.name>spring-hateoas-docs</zip.name>
<zip.displayname>spring-hateoas-docs</zip.displayname>
@@ -384,12 +382,12 @@
<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>
<contextUrl>https://repo.spring.io</contextUrl>
<includePatterns>*-docs.zip</includePatterns>
<username>${env.ARTIFACTORY_USERNAME}</username>
<password>${env.ARTIFACTORY_PASSWORD}</password>
<repoKey>temp-private-local</repoKey>
<snapshotRepoKey>temp-private-local</snapshotRepoKey>
</publisher>
</configuration>
</execution>
@@ -399,203 +397,6 @@
</build>
</profile>
<profile>
<id>snapshot</id>
<build>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>${artifactory-maven-plugin.version}</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-hateoas</zip.name>
<zip.displayname>spring-hateoas</zip.displayname>
<zip.deployed>false</zip.deployed>
<archives>*:*:*:*@zip</archives>
</deployProperties>
<publisher>
<contextUrl>https://repo.spring.io</contextUrl>
<username>{{ARTIFACTORY_USR}}</username>
<password>{{ARTIFACTORY_PSW}}</password>
<repoKey>libs-snapshot-local</repoKey>
<snapshotRepoKey>libs-snapshot-local</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>milestone</id>
<build>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>${artifactory-maven-plugin.version}</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-hateoas</zip.name>
<zip.displayname>spring-hateoas</zip.displayname>
<zip.deployed>false</zip.deployed>
<archives>*:*:*:*@zip</archives>
</deployProperties>
<publisher>
<contextUrl>https://repo.spring.io</contextUrl>
<username>{{ARTIFACTORY_USR}}</username>
<password>{{ARTIFACTORY_PSW}}</password>
<repoKey>libs-milestone-local</repoKey>
<snapshotRepoKey>libs-milestone-local</snapshotRepoKey>
</publisher>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>release</id>
<build>
<plugins>
<plugin>
<groupId>org.jfrog.buildinfo</groupId>
<artifactId>artifactory-maven-plugin</artifactId>
<version>${artifactory-maven-plugin.version}</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-hateoas</zip.name>
<zip.displayname>spring-hateoas</zip.displayname>
<zip.deployed>false</zip.deployed>
<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>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>central</id>
<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.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>
</profiles>
<dependencyManagement>
@@ -875,6 +676,8 @@
<build>
<defaultGoal>verify</defaultGoal>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>

View File

@@ -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.
-->
<directory>target/site/reference</directory>
<directory>target/generated-docs</directory>
<outputDirectory>reference</outputDirectory>
</fileSet>
<fileSet>