From 9e336c8266673271b0c92b28a6c3d927a672ee92 Mon Sep 17 00:00:00 2001 From: Julien Ponge Date: Mon, 24 Jul 2023 14:51:56 +0200 Subject: [PATCH] build: Deploy Java artifacts to Maven Central --- .github/workflows/deploy-maven-release.yaml | 24 --- .github/workflows/release.yaml | 10 +- README.md | 5 +- api/pom.xml | 1 + jboss-cert-helper/pom.xml | 32 ++++ jreleaser.yml | 28 ---- pom.xml | 177 ++++++++++++++++++-- release.sh | 11 ++ runtime/pom.xml | 1 + 9 files changed, 214 insertions(+), 75 deletions(-) delete mode 100644 .github/workflows/deploy-maven-release.yaml delete mode 100644 jreleaser.yml create mode 100755 release.sh diff --git a/.github/workflows/deploy-maven-release.yaml b/.github/workflows/deploy-maven-release.yaml deleted file mode 100644 index f6de020..0000000 --- a/.github/workflows/deploy-maven-release.yaml +++ /dev/null @@ -1,24 +0,0 @@ -name: Deploy Maven artefacts on release -on: - push: - tags: - - '*' - workflow_dispatch: - -jobs: - publish: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-java@v3 - with: - java-version: '11' - distribution: 'temurin' - cache: maven - - name: Publish package - run: ./mvnw --no-transfer-progress --batch-mode -Dskip.spotless=true -DskipTests=true deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2765bd2..12e2efb 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -36,14 +36,16 @@ jobs: github_token: ${{ secrets.GITHUB_TOKEN }} message: "chore: releasing version ${{ github.event.inputs.version }}" - name: Release with JReleaser - uses: jreleaser/release-action@v2 - with: - setup-java: false env: - JRELEASER_PROJECT_VERSION: ${{ github.event.inputs.version }} JRELEASER_TAG_NAME: ${{ github.event.inputs.version }} JRELEASER_PREVIOUS_TAG_NAME: ${{ github.event.inputs.previousVersion }} + 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: ./mvnw --batch-mode --no-transfer-progress versions:set -DnewVersion=${{ github.event.inputs.nextVersion }}-SNAPSHOT - name: Commit & Push changes diff --git a/README.md b/README.md index 99f293f..a3278a8 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,7 @@ There are three modules within the project: Product artifacts are available from Red Hat internal repositories. -If you need to use these libraries while in development then you can consume the upstream artefacts from GitHub Packages: -- see https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-apache-maven-registry -- see https://github.com/orgs/RedHatInsights/packages?repo_name=insights-java-client -- use https://maven.pkg.github.com/RedHatInsights/insights-java-client as an additional Maven repository to your build +If you need to use these libraries while in development then you can consume the **Java** upstream artefacts from Maven Central. ## Building diff --git a/api/pom.xml b/api/pom.xml index 98fff3b..63b6f8d 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -8,6 +8,7 @@ runtimes-java 1.0.10-SNAPSHOT + runtimes-java-api diff --git a/jboss-cert-helper/pom.xml b/jboss-cert-helper/pom.xml index ec2cf57..94c87a3 100644 --- a/jboss-cert-helper/pom.xml +++ b/jboss-cert-helper/pom.xml @@ -8,6 +8,7 @@ runtimes-java 1.0.10-SNAPSHOT + jboss-cert-helper mvn-golang @@ -135,4 +136,35 @@ ${basedir}${file.separator}src + + + publication + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + release + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + + + + diff --git a/jreleaser.yml b/jreleaser.yml deleted file mode 100644 index d87fcbf..0000000 --- a/jreleaser.yml +++ /dev/null @@ -1,28 +0,0 @@ -project: - name: insights-java-client - version: 999 # To be overriden by the environment variable JRELEASER_PROJECT_VERSION - versionPattern: SEMVER - description: Red Hat Insights Java Client - longDescription: Red Hat Insights Java Client - authors: - - Red Hat - license: Apache-2.0 - links: - homepage: https://github.com/RedHatInsights/insights-java-client - java: - groupId: com.redhat.insights - version: 11 - -release: - github: - owner: RedHatInsights - changelog: - preset: conventional-commits - links: true - formatted: ALWAYS - hide: - contributors: - - "GitHub" - - "dependabot[bot]" - - "[bot]" - diff --git a/pom.xml b/pom.xml index 08fa185..3488716 100644 --- a/pom.xml +++ b/pom.xml @@ -8,12 +8,51 @@ 1.0.10-SNAPSHOT pom + Red Hat Insights Java Client + Red Hat Insights Java Client + https://github.com/RedHatInsights/insights-java-client + 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/ + + + Julien Ponge + jponge@redhat.com + Red Hat + https://www.redhat.com/ + + + Emmanuel Hugonnet + ehugonne@redhat.com + Red Hat + https://www.redhat.com/ + + + api runtime jboss-cert-helper + + scm:git:git://github.com/RedHatInsights/insights-java-client.git + scm:git:ssh://github.com:RedHatInsights/insights-java-client.git + http://github.com/RedHatInsights/insights-java-client/tree/main + + github @@ -57,6 +96,9 @@ 3.3.1 3.3.1 3.3.0 + 3.2.0 + 3.1.1 + 1.7.0 @@ -205,6 +247,21 @@ spotless-maven-plugin ${spotless-maven-plugin.version} + + org.apache.maven.plugins + maven-javadoc-plugin + ${maven-javadoc-plugin.version} + + + org.apache.maven.plugins + maven-deploy-plugin + ${maven-deploy-plugin.version} + + + org.apache.maven.plugins + maven-source-plugin + ${maven-source-plugin.version} + @@ -216,21 +273,6 @@ ${maven-compiler-plugin.version} - - org.apache.maven.plugins - maven-source-plugin - ${maven-source-plugin.version} - - - attach-sources - - jar-no-fork - test-jar-no-fork - - - - - org.apache.maven.plugins maven-surefire-plugin @@ -307,6 +349,7 @@ + coverage @@ -334,6 +377,7 @@ + integration @@ -348,5 +392,108 @@ + + + release + + + + org.jreleaser + jreleaser-maven-plugin + ${jreleaser-maven-plugin.version} + false + + SEMVER + + + ALWAYS + true + + + + RedHatInsights + + conventional-commits + true + ALWAYS + + + GitHub + dependabot[bot] + bot + + + + + + + + + false + false + + + + ALWAYS + https://oss.sonatype.org/service/local + https://oss.sonatype.org/content/repositories/snapshots/ + true + false + + target/staging-deploy + + + + + + + + + + + + + publication + + local::file:./target/staging-deploy + + + deploy + + + org.apache.maven.plugins + maven-javadoc-plugin + + + attach-javadocs + + jar + + + true + + + + + + org.apache.maven.plugins + maven-source-plugin + + + attach-sources + + jar-no-fork + test-jar-no-fork + + + true + + + + + + + + diff --git a/release.sh b/release.sh new file mode 100755 index 0000000..3697ddd --- /dev/null +++ b/release.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -euo pipefail +IFS=$'\n\t' + +echo "📦 Staging artifacts..." +./mvnw --batch-mode --no-transfer-progress -Ppublication -DskipTests=true -Dskip.spotless=true + +echo "🚀 Releasing..." +/mvnw --batch-mode --no-transfer-progress -Prelease -pl :runtimes-java jreleaser:full-release + +echo "🎉 Done!" diff --git a/runtime/pom.xml b/runtime/pom.xml index 07765ad..25ae2f9 100644 --- a/runtime/pom.xml +++ b/runtime/pom.xml @@ -8,6 +8,7 @@ runtimes-java 1.0.10-SNAPSHOT + runtimes-java-core-runtime