From 992c8d52994d378912afa358dff2e9c38842603b Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Mon, 20 Nov 2023 21:19:36 +0100 Subject: [PATCH 1/3] Release workflow based on JReleaser and Maven Central compliance --- .github/workflows/release.yaml | 53 +++++++++++++++ pom.xml | 119 +++++++++++++++++++++++++++++++++ release.sh | 11 +++ 3 files changed, 183 insertions(+) create mode 100644 .github/workflows/release.yaml create mode 100755 release.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..34c9418 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,53 @@ +# Inspired from https://foojay.io/today/how-to-release-a-java-module-with-jreleaser-to-maven-central-with-github-actions/ +name: Publish a new release + +on: + workflow_dispatch: + inputs: + version: + description: 'Release version' + required: true + nextVersion: + description: 'Next version after release (-SNAPSHOT will be added automatically)' + required: true + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Java setup + uses: actions/setup-java@v3 + with: + java-version: '8' + distribution: 'temurin' + cache: maven + - name: Run a build of the code base before release + run: mvn --batch-mode --no-transfer-progress clean install + - name: Set release version + run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }} + - name: Commit & Push changes + uses: actions-js/push@v1.4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + message: "Releasing version ${{ github.event.inputs.version }}" + - name: Release with JReleaser + env: + JRELEASER_TAG_NAME: ${{ github.event.inputs.version }} + JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.JRELEASER_GPG_PUBLIC_KEY }} + JRELEASER_GPG_SECRET_KEY: ${{ secrets.JRELEASER_GPG_SECRET_KEY }} + JRELEASER_GPG_PASSPHRASE: ${{ secrets.JRELEASER_GPG_PASSPHRASE }} + JRELEASER_NEXUS2_USERNAME: ${{ secrets.JRELEASER_NEXUS2_USERNAME }} + JRELEASER_NEXUS2_PASSWORD: ${{ secrets.JRELEASER_NEXUS2_PASSWORD }} + JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: ./release.sh + - name: Set the next release version + run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT + - name: Commit & Push changes + uses: actions-js/push@v1.4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + message: "Setting version ${{ github.event.inputs.nextVersion }}-SNAPSHOT" diff --git a/pom.xml b/pom.xml index 5d0ce36..d265baa 100644 --- a/pom.xml +++ b/pom.xml @@ -7,6 +7,40 @@ runtimes-agent 1.0.0-SNAPSHOT + Red Hat Insights Java Agent + Red Hat Insights Java Agent + https://github.com/RedHatInsights/insights-java-agent + 2023 + + + + The Apache License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + + + + + + Benjamin Evans + beevans@redhat.com + Red Hat + https://www.redhat.com/ + + + ebaron + Elliott Baron + ebaron@redhat.com + Red Hat + https://www.redhat.com/ + + + + + scm:git:git://github.com/RedHatInsights/insights-java-agent.git + scm:git:ssh://github.com:RedHatInsights/insights-java-agent.git + http://github.com/RedHatInsights/insights-java-agent/tree/main + + 8 @@ -38,6 +72,9 @@ 3.1.0 3.2.0 3.3.0 + 3.3.0 + 3.6.2 + 1.9.0 @@ -350,6 +387,7 @@ jar-with-dependencies + true @@ -425,5 +463,86 @@ + + + release + + + + org.jreleaser + jreleaser-maven-plugin + ${jreleaser-maven-plugin.version} + false + + + + ALWAYS + true + + + + + + ALWAYS + https://oss.sonatype.org/service/local + https://oss.sonatype.org/content/repositories/snapshots/ + true + true + target/staging-deploy + + + + + + + + + + + + + publication + + local::file:./target/staging-deploy + + + deploy + + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + attach-javadocs + + jar + + + true + + + + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + + + attach-sources + + jar-no-fork + + + true + + + + + + + + diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..8fdaf2c --- /dev/null +++ b/release.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +echo "📦 Staging artifacts..." +mvn --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true + +echo "🚀 Releasing..." +mvn --batch-mode --no-transfer-progress -Prelease jreleaser:full-release + +echo "🎉 Done!" From 7c159b1677832b60c6ecd5966f92f526aff91c1b Mon Sep 17 00:00:00 2001 From: Elliott Baron Date: Tue, 21 Nov 2023 16:16:58 -0500 Subject: [PATCH 2/3] Use Maven Wrapper in workflow --- .github/workflows/release.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 34c9418..fa6ca31 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -26,9 +26,9 @@ jobs: distribution: 'temurin' cache: maven - name: Run a build of the code base before release - run: mvn --batch-mode --no-transfer-progress clean install + run: ./mvnw --batch-mode --no-transfer-progress clean install - name: Set release version - run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }} + run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.version }} - name: Commit & Push changes uses: actions-js/push@v1.4 with: @@ -45,7 +45,7 @@ jobs: JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: ./release.sh - name: Set the next release version - run: mvn --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT + run: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT - name: Commit & Push changes uses: actions-js/push@v1.4 with: From 11b6d6ac9600a0945da7486a7dcbe089af3c700d Mon Sep 17 00:00:00 2001 From: Elliott Baron Date: Tue, 21 Nov 2023 16:17:53 -0500 Subject: [PATCH 3/3] Use Maven Wrapper in release.sh --- release.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/release.sh b/release.sh index 8fdaf2c..dfe4caf 100755 --- a/release.sh +++ b/release.sh @@ -3,9 +3,9 @@ set -euo pipefail IFS=$'\n\t' echo "📦 Staging artifacts..." -mvn --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true +./mvnw --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true echo "🚀 Releasing..." -mvn --batch-mode --no-transfer-progress -Prelease jreleaser:full-release +./mvnw --batch-mode --no-transfer-progress -Prelease jreleaser:full-release echo "🎉 Done!"