From c22135a879d6a76368755c40de46d86827e8f9f4 Mon Sep 17 00:00:00 2001 From: James Kebinger Date: Fri, 26 Sep 2025 13:44:39 -0500 Subject: [PATCH 1/3] Add modern Maven Central publishing workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Replace nexus-staging-maven-plugin with central-publishing-maven-plugin - Add basepom.nexus-staging.skip property to disable old nexus behavior - Add GitHub Actions workflows for CI and publishing - Update pom.xml with name and description for Maven Central - Configure modern publishing process with GPG signing and auto-publish Supports the new Maven Central publishing process for cloud.prefab namespace. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/maven.yml | 22 +++++++++ .github/workflows/publish.yml | 93 +++++++++++++++++++++++++++++++++++ pom.xml | 31 ++++++------ 3 files changed, 131 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/maven.yml create mode 100644 .github/workflows/publish.yml diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml new file mode 100644 index 0000000..68fb62c --- /dev/null +++ b/.github/workflows/maven.yml @@ -0,0 +1,22 @@ +name: Java CI with Maven + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + - name: Run tests with Maven + run: mvn clean verify \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..3313304 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,93 @@ +name: Publish to Maven Central + +on: + workflow_run: + workflows: ["Java CI with Maven"] + types: + - completed + branches: [ "main" ] + +jobs: + publish: + runs-on: ubuntu-latest + if: github.repository == 'prefab-cloud/java-simple-sse-client' && github.event.workflow_run.conclusion == 'success' + + steps: + - name: "Checkout" + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up JDK 11 + uses: actions/setup-java@v4 + with: + java-version: '11' + distribution: 'temurin' + cache: maven + + - name: Extract version from pom.xml + id: extract_version + run: | + VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) + echo "version=$VERSION" >> $GITHUB_OUTPUT + echo "Current version: $VERSION" + + - name: Check if version exists in Maven Central + id: version_check + run: | + VERSION=${{ steps.extract_version.outputs.version }} + echo "Checking if version $VERSION exists in Maven Central..." + + # Check if version exists (non-snapshot versions only) + if [[ "$VERSION" != *-SNAPSHOT ]]; then + HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://repo1.maven.org/maven2/cloud/prefab/sse-handler/$VERSION/sse-handler-$VERSION.pom") + if [ "$HTTP_STATUS" = "200" ]; then + echo "Version $VERSION already exists in Maven Central" + echo "should_publish=false" >> $GITHUB_OUTPUT + else + echo "Version $VERSION does not exist in Maven Central" + echo "should_publish=true" >> $GITHUB_OUTPUT + fi + else + echo "Snapshot version detected, skipping publication" + echo "should_publish=false" >> $GITHUB_OUTPUT + fi + + - name: Import GPG key + if: steps.version_check.outputs.should_publish == 'true' + uses: crazy-max/ghaction-import-gpg@v6 + with: + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.GPG_PASSPHRASE }} + + - name: Configure Maven settings + if: steps.version_check.outputs.should_publish == 'true' + uses: s4u/maven-settings-action@v3.0.0 + with: + servers: | + [ + { + "id": "central", + "username": "${{ secrets.MAVEN_CENTRAL_USERNAME }}", + "password": "${{ secrets.MAVEN_CENTRAL_TOKEN }}" + } + ] + + - name: Publish to Maven Central + if: steps.version_check.outputs.should_publish == 'true' + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: | + echo "Publishing version ${{ steps.extract_version.outputs.version }} to Maven Central..." + mvn clean deploy -P release --no-transfer-progress -Dgpg.passphrase=${{ secrets.GPG_PASSPHRASE }} + + - name: Create GitHub Release + if: steps.version_check.outputs.should_publish == 'true' + uses: softprops/action-gh-release@v2 + with: + tag_name: v${{ steps.extract_version.outputs.version }} + name: Release v${{ steps.extract_version.outputs.version }} + generate_release_notes: true + prerelease: ${{ contains(steps.extract_version.outputs.version, 'RC') || contains(steps.extract_version.outputs.version, 'beta') || contains(steps.extract_version.outputs.version, 'alpha') }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 53eed4e..f7d4228 100644 --- a/pom.xml +++ b/pom.xml @@ -13,9 +13,13 @@ 1.0.1 jar + Prefab SSE Handler + A simple Server-Sent Events (SSE) client handler for Java applications + true true + true 3.23.1 4.2.0 5.9.1 @@ -114,14 +118,21 @@ + + org.sonatype.central + central-publishing-maven-plugin + 0.8.0 + + central + true + + org.sonatype.plugins nexus-staging-maven-plugin 1.6.13 - sonatype-nexus-staging - https://oss.sonatype.org/ - false + true @@ -160,8 +171,8 @@ - org.sonatype.plugins - nexus-staging-maven-plugin + org.sonatype.central + central-publishing-maven-plugin true @@ -191,14 +202,4 @@ scm:git:git@github.com:prefab-cloud/java-simple-sse-client.git https://github.com/prefab-cloud/java-simple-sse-client - - - ossrh - https://oss.sonatype.org/service/local/staging/deploy/maven2/ - - - ossrh - https://oss.sonatype.org/content/repositories/snapshots - - From 6d706fed0eebb684f271897ce5f54e85f4a04f52 Mon Sep 17 00:00:00 2001 From: James Kebinger Date: Fri, 26 Sep 2025 16:40:41 -0500 Subject: [PATCH 2/3] Add --no-transfer-progress to Maven CI workflow Reduces log noise by suppressing Maven download progress bars during CI runs. --- .github/workflows/maven.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 68fb62c..13c1b26 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -19,4 +19,4 @@ jobs: distribution: 'temurin' cache: maven - name: Run tests with Maven - run: mvn clean verify \ No newline at end of file + run: mvn clean verify --no-transfer-progress \ No newline at end of file From af26122d5cc98e6829135afea383fc8e463b4cbb Mon Sep 17 00:00:00 2001 From: James Kebinger Date: Fri, 26 Sep 2025 16:41:45 -0500 Subject: [PATCH 3/3] Fix GPG signing to only run during release profile - Move maven-gpg-plugin from default build to 'release' profile - CI workflow now runs tests without attempting GPG signing - Publishing workflow uses -P release flag to enable signing during deploy --- pom.xml | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index f7d4228..94f9c19 100644 --- a/pom.xml +++ b/pom.xml @@ -156,20 +156,6 @@ - - org.apache.maven.plugins - maven-gpg-plugin - 3.0.1 - - - sign-artifacts - - sign - - verify - - - org.sonatype.central central-publishing-maven-plugin @@ -202,4 +188,28 @@ scm:git:git@github.com:prefab-cloud/java-simple-sse-client.git https://github.com/prefab-cloud/java-simple-sse-client + + + + release + + + + org.apache.maven.plugins + maven-gpg-plugin + 3.0.1 + + + sign-artifacts + + sign + + verify + + + + + + +