From a656089bb47b3a079f455b13de4b1047ca65842b Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Mon, 12 Sep 2022 17:45:59 +0200 Subject: [PATCH] #87 - Initial scripts and tweaks for build and release via GitHub Actions. --- .github/workflows/build.yaml | 33 +++++++++ .github/workflows/milestone.yaml | 34 +++++++++ .github/workflows/release.yaml | 39 +++++++++++ ci/build.sh | 5 -- ci/create-release.sh | 22 ------ ci/promote-to-bintray.sh | 42 ------------ ci/sync-to-maven-central.sh | 23 ------- ci/test.sh | 5 -- pom.xml | 114 +++++++++---------------------- settings.xml | 12 ++++ 10 files changed, 149 insertions(+), 180 deletions(-) create mode 100644 .github/workflows/build.yaml create mode 100644 .github/workflows/milestone.yaml create mode 100644 .github/workflows/release.yaml delete mode 100755 ci/build.sh delete mode 100755 ci/create-release.sh delete mode 100755 ci/promote-to-bintray.sh delete mode 100755 ci/sync-to-maven-central.sh delete mode 100755 ci/test.sh create mode 100644 settings.xml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml new file mode 100644 index 0000000..0e35797 --- /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/milestone.yaml b/.github/workflows/milestone.yaml new file mode 100644 index 0000000..75f8740 --- /dev/null +++ b/.github/workflows/milestone.yaml @@ -0,0 +1,34 @@ +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 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..4b37abc --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,39 @@ +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 -Psonatype -s settings.xml + + - name: Setup Graphviz + uses: ts-graphviz/setup-graphviz@v1 diff --git a/ci/build.sh b/ci/build.sh deleted file mode 100755 index 51a1241..0000000 --- a/ci/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/spring-plugin-maven-repository" ./mvnw -P${PROFILE} -Dmaven.test.skip=true clean deploy -B diff --git a/ci/create-release.sh b/ci/create-release.sh deleted file mode 100755 index 0fd9c43..0000000 --- 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 Plugin $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/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 7150ca7..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 "Syncing ${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 deleted file mode 100755 index d635abd..0000000 --- a/ci/test.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -euo pipefail - -MAVEN_OPTS="-Duser.name=jenkins -Duser.home=/tmp/spring-plugin-maven-repository" ./mvnw -P${PROFILE} clean dependency:list test -Dsort -B diff --git a/pom.xml b/pom.xml index b460886..b7a4a85 100644 --- a/pom.xml +++ b/pom.xml @@ -111,38 +111,34 @@ - snapshot - + artifactory + + true + org.jfrog.buildinfo artifactory-maven-plugin - 3.3.0 + ${artifactory-maven-plugin.version} false - build-info + deploy-to-artifactory publish - - {{BUILD_URL}} - - - spring-plugin - spring-plugin - false - *:*:*:*@zip - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-snapshot-local + ${env.ARTIFACTORY_USERNAME} + ${env.ARTIFACTORY_PASSWORD} + libs-milestone-local libs-snapshot-local + + CI build for Spring Plugin ${project.version} + @@ -152,85 +148,37 @@ - milestone - + sonatype + + true + - org.jfrog.buildinfo - artifactory-maven-plugin - 3.3.0 - false + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 - build-info + sign-artifacts + verify - publish + sign - - - {{BUILD_URL}} - - - spring-plugin - spring-plugin - false - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-milestone-local - libs-milestone-local - - - - - - - - - - - release - - - - - org.jfrog.buildinfo - artifactory-maven-plugin - 3.3.0 - false - - - build-info - - publish - - - - {{BUILD_URL}} - - - spring-plugin - spring-plugin - false - *:*:*:*@zip - - - https://repo.spring.io - {{ARTIFACTORY_USR}} - {{ARTIFACTORY_PSW}} - libs-release-local - libs-release-local - - + + ${env.GPG_PASSPHRASE} + + + + sonatype-new + https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 + + diff --git a/settings.xml b/settings.xml new file mode 100644 index 0000000..70379bd --- /dev/null +++ b/settings.xml @@ -0,0 +1,12 @@ + + + + + sonatype-new + ${env.SONATYPE_USER} + ${env.SONATYPE_PASSWORD} + + +