From 47201ee7668f667275d739fa34a71c4bf922df3f Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Sat, 21 Nov 2026 23:12:51 +0100 Subject: [PATCH] release: publish the artifacts to Maven Central Move the public distribution of the library and the shaded artifact from GitHub Packages to Maven Central. GitHub Packages requires authentication even for public packages, so Jenkins CI cannot resolve the shaded artifact from it anonymously. Add the metadata Central requires to the shaded artifact, attach its sources and Javadoc, and sign both artifacts with the release profile. Replace the shaded GitHub Packages workflow with a manual Central publishing workflow that validates by default and publishes on request. The GitHub Packages deployment remains available through the github-packages profile as an internal mirror. Signed-off-by: Michael Trimarchi Co-Authored-By: Claude Code --- .github/workflows/publish-central.yml | 46 +++++++ .github/workflows/publish-shaded.yml | 27 ----- .github/workflows/publish.yml | 2 +- CHANGELOG | 3 +- INSTALL | 29 +---- README.md | 21 +++- pom.xml | 34 ++++-- shaded/pom.xml | 113 +++++++++++++++--- .../shaded/ShadedDependencies.java | 16 +++ .../org/openid4java/shaded/package-info.java | 4 + 10 files changed, 215 insertions(+), 80 deletions(-) create mode 100644 .github/workflows/publish-central.yml delete mode 100644 .github/workflows/publish-shaded.yml create mode 100644 shaded/src/main/java/org/openid4java/shaded/ShadedDependencies.java create mode 100644 shaded/src/main/java/org/openid4java/shaded/package-info.java diff --git a/.github/workflows/publish-central.yml b/.github/workflows/publish-central.yml new file mode 100644 index 0000000..2c01a32 --- /dev/null +++ b/.github/workflows/publish-central.yml @@ -0,0 +1,46 @@ +name: Publish to Maven Central + +on: + workflow_dispatch: + inputs: + auto_publish: + description: Publish automatically after validation + type: boolean + default: false + +permissions: + contents: read + +concurrency: + group: maven-central + cancel-in-progress: false + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v5 + + - name: Set up JDK 17 + uses: actions/setup-java@v5 + with: + distribution: temurin + java-version: '17' + cache: maven + server-id: central + server-username: CENTRAL_USERNAME + server-password: CENTRAL_TOKEN + + - name: Import GPG key + env: + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} + run: echo "$GPG_PRIVATE_KEY" | gpg --batch --import + + - name: Publish library and shaded artifact + env: + MAVEN_GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} + CENTRAL_TOKEN: ${{ secrets.CENTRAL_TOKEN }} + run: | + mvn -B -Prelease -Dcentral.autoPublish=${{ inputs.auto_publish }} deploy + mvn -B -Prelease -Dcentral.autoPublish=${{ inputs.auto_publish }} -f shaded/pom.xml deploy diff --git a/.github/workflows/publish-shaded.yml b/.github/workflows/publish-shaded.yml deleted file mode 100644 index 8f196f6..0000000 --- a/.github/workflows/publish-shaded.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Publish shaded artifact - -on: - workflow_dispatch: - -permissions: - contents: read - packages: write - -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v5 - - name: Set up JDK 17 - uses: actions/setup-java@v5 - with: - distribution: temurin - java-version: '17' - cache: maven - server-id: github - server-username: GITHUB_ACTOR - server-password: GITHUB_TOKEN - - name: Publish shaded artifact - run: mvn -B -f shaded/pom.xml deploy - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d853ed1..fe78ebf 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -24,6 +24,6 @@ jobs: server-username: GITHUB_ACTOR server-password: GITHUB_TOKEN - name: Publish - run: mvn -B deploy + run: mvn -B -Pgithub-packages deploy env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/CHANGELOG b/CHANGELOG index cab41cf..766741b 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -49,7 +49,8 @@ custom parser configurations must use the new classes. Added a shaded openid4java-shaded 2.0.0 artifact for Jenkins plugins, with Guice, Guava, HttpClient 5, jsoup and the injection APIs relocated -under org.openid4java.shaded.*. +under org.openid4java.shaded.*. The library and the shaded artifact are +published to Maven Central. Upgraded the test-only JDOM dependency from 1.0 to JDOM 2. diff --git a/INSTALL b/INSTALL index 41bd930..b99f1e9 100644 --- a/INSTALL +++ b/INSTALL @@ -43,29 +43,12 @@ Using the library: 2.0.0 - The Amarula Solutions fork is published to GitHub Packages. Add the - repository to your project: - - - - github - https://maven.pkg.github.com/amarula/openid4java - - - - GitHub Packages requires authentication. Add a server entry to - ~/.m2/settings.xml with your GitHub username and a personal access - token that has the read:packages scope: - - - - github - YOUR_GITHUB_USERNAME - YOUR_PAT - - - - The core dependencies are resolved transitively by Maven. + The Amarula Solutions fork is published to Maven Central. No + additional repository or authentication configuration is required; + the core dependencies are resolved transitively by Maven. + + Internal builds may instead publish the library to GitHub Packages + using the github-packages Maven profile. For Jenkins plugins, use the shaded artifact: diff --git a/README.md b/README.md index 42b8919..a642654 100644 --- a/README.md +++ b/README.md @@ -31,8 +31,8 @@ The following specifications are supported: ``` -Artifacts are published to GitHub Packages. See [INSTALL](INSTALL) for -the repository and authentication setup. +Artifacts are published to Maven Central and can be resolved without +additional repository or authentication configuration. # Jenkins shaded artifact # @@ -50,8 +50,21 @@ relocated third-party dependencies: Guice, Guava, HttpClient 5, jsoup and the injection APIs are relocated under `org.openid4java.shaded.*`. `commons-codec` remains an external dependency and `slf4j-api` is provided by the runtime (Jenkins provides -it). The shaded artifact is published to GitHub Packages; see -[INSTALL](INSTALL). +it). The shaded artifact is published to Maven Central alongside the +library; no repository configuration is required. + +# Publishing # + +The `Publish to Maven Central` workflow publishes the library and the +shaded artifact through the Sonatype Central Portal. It requires these +repository secrets: + + * `CENTRAL_USERNAME` and `CENTRAL_TOKEN`: a Central Portal user token + * `GPG_PRIVATE_KEY` and `GPG_PASSPHRASE`: the signing key + +The workflow defaults to `auto_publish=false`, which validates both +deployments and waits for a manual release in the Central Portal. Set +the `auto_publish` input to publish immediately. # What is OpenID? # diff --git a/pom.xml b/pom.xml index 409eee5..df6dad9 100644 --- a/pom.xml +++ b/pom.xml @@ -605,23 +605,28 @@ HEAD https://github.com/amarula/openid4java - - - github - GitHub Packages - https://maven.pkg.github.com/amarula/openid4java - - - + + github-packages + + + github + GitHub Packages + https://maven.pkg.github.com/amarula/openid4java + + + release + + false + org.apache.maven.plugins maven-gpg-plugin - 3.2.7 + 3.2.8 sign-artifacts @@ -632,6 +637,17 @@ + + org.sonatype.central + central-publishing-maven-plugin + 0.12.0 + true + + central + ${central.autoPublish} + validated + + diff --git a/shaded/pom.xml b/shaded/pom.xml index c7dc1cd..520c473 100644 --- a/shaded/pom.xml +++ b/shaded/pom.xml @@ -24,19 +24,31 @@ + + + mtrimarchi + Michael Trimarchi + michael@amarulasolutions.com + Amarula Solutions + + maintainer + + + + + + scm:git:https://github.com/amarula/openid4java.git + scm:git:ssh://git@github.com/amarula/openid4java.git + HEAD + https://github.com/amarula/openid4java + + UTF-8 2.0.0 + 17 - - - github - GitHub Packages - https://maven.pkg.github.com/amarula/openid4java - - - com.amarulasolutions @@ -64,6 +76,47 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + 17 + + + + org.apache.maven.plugins + maven-source-plugin + 3.3.1 + + + attach-sources + package + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 3.11.2 + + 17 + none + package + + + + attach-javadocs + package + + jar + + + + org.apache.maven.plugins maven-shade-plugin @@ -127,11 +180,41 @@ - - - github - GitHub Packages - https://maven.pkg.github.com/amarula/openid4java - - + + + release + + false + + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.2.8 + + + sign-artifacts + verify + + sign + + + + + + org.sonatype.central + central-publishing-maven-plugin + 0.12.0 + true + + central + ${central.autoPublish} + validated + + + + + + diff --git a/shaded/src/main/java/org/openid4java/shaded/ShadedDependencies.java b/shaded/src/main/java/org/openid4java/shaded/ShadedDependencies.java new file mode 100644 index 0000000..4a06218 --- /dev/null +++ b/shaded/src/main/java/org/openid4java/shaded/ShadedDependencies.java @@ -0,0 +1,16 @@ +package org.openid4java.shaded; + +/** + * Marker describing the relocated third-party dependencies of the shaded + * OpenID4Java artifact. + * + *

The shaded JAR relocates Guice, Guava, HttpClient 5, jsoup, + * {@code jakarta.inject} and {@code org.aopalliance} under + * {@code org.openid4java.shaded.*}, so they cannot conflict with the + * versions provided by the host application.

+ */ +final class ShadedDependencies { + + private ShadedDependencies() { + } +} diff --git a/shaded/src/main/java/org/openid4java/shaded/package-info.java b/shaded/src/main/java/org/openid4java/shaded/package-info.java new file mode 100644 index 0000000..c64e9eb --- /dev/null +++ b/shaded/src/main/java/org/openid4java/shaded/package-info.java @@ -0,0 +1,4 @@ +/** + * Relocated third-party dependencies used by the OpenID4Java shaded artifact. + */ +package org.openid4java.shaded;