From fc7904c29d2eb0f624698a618472aa0d84f19790 Mon Sep 17 00:00:00 2001 From: Fernando Alonso Date: Thu, 19 Nov 2026 18:25:48 +0000 Subject: [PATCH] ci: migrate Maven Central publishing to OSS Exit Gate --- .github/workflows/release.yml | 58 ++++++++++++++++++++++++++++++----- pom.xml | 44 ++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 8 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 340edda74..a9f0bbf58 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,11 +21,14 @@ on: description: "version number for this release." required: true +permissions: {} + jobs: build-maven-jars: runs-on: ubuntu-latest permissions: contents: write + id-token: write steps: - name: Checkout uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 @@ -33,7 +36,7 @@ jobs: persist-credentials: false - name: Set up JDK - uses: actions/setup-java@b843ebf9b913146b38da2eaa7aeddf76074ae1ad # v6.1.0 + uses: actions/setup-java@b6effb05e454b25005698d916606bdc6ffcbf961 # v5.7.0 with: java-version: 21 distribution: "zulu" @@ -59,15 +62,54 @@ jobs: env: GITHUB_EVENT_INPUTS_VERSION: ${{ github.event.inputs.version }} - - name: Deploy to Sonatype staging + - name: Authenticate to Google Cloud + uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0 + with: + workload_identity_provider: "projects/305452601764/locations/global/workloadIdentityPools/builders/providers/github" + + - name: Set up Cloud SDK + uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1 + + - name: Clean up previous staging attempt for this version (if any) + env: + VERSION: ${{ github.event.inputs.version }} + run: | + set -euo pipefail + while IFS= read -r pkg; do + pkg_name="${pkg##*/}" + [ -n "${pkg_name}" ] || continue + if gcloud artifacts versions describe "${VERSION}" \ + --package="${pkg_name}" \ + --project="oss-exit-gate-prod" \ + --location="us" \ + --repository="google-java-fmt--mavencentral" >/dev/null 2>&1; then + gcloud artifacts versions delete "${VERSION}" \ + --package="${pkg_name}" \ + --project="oss-exit-gate-prod" \ + --location="us" \ + --repository="google-java-fmt--mavencentral" \ + --quiet + fi + done < <(gcloud artifacts packages list \ + --project="oss-exit-gate-prod" \ + --location="us" \ + --repository="google-java-fmt--mavencentral" \ + --format="value(name)" 2>/dev/null || true) + + - name: Deploy to OSS Exit Gate staging and trigger release env: - CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} - CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} - run: mvn --no-transfer-progress -pl '!eclipse_plugin' -P sonatype-oss-release clean deploy -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" + RUN_ID: ${{ github.run_id }} + RUN_ATTEMPT: ${{ github.run_attempt }} + run: | + mvn --no-transfer-progress -pl '!eclipse_plugin' -P sonatype-oss-release,oss-exit-gate clean deploy -Dgpg.passphrase="${GPG_PASSPHRASE}" + echo '{"publish_all": true}' > manifest.json + gcloud storage cp manifest.json "gs://oss-exit-gate-prod-projects-bucket/google-java-fmt/mavencentral/manifests/manifest-${RUN_ID}-${RUN_ATTEMPT}.json" - name: Build Eclipse plugin - run: mvn --no-transfer-progress -pl 'eclipse_plugin' verify gpg:sign -DskipTests=true -Dgpg.passphrase="${{ secrets.GPG_PASSPHRASE }}" + env: + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} + run: mvn --no-transfer-progress -pl 'eclipse_plugin' verify gpg:sign -DskipTests=true -Dgpg.passphrase="${GPG_PASSPHRASE}" - name: Push tag run: | @@ -76,7 +118,7 @@ jobs: GITHUB_EVENT_INPUTS_VERSION: ${{ github.event.inputs.version }} - name: Add Artifacts to Release Entry - uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 # v3.0.3 + uses: softprops/action-gh-release@3d0d9888cb7fd7b750713d6e236d1fcb99157228 # v3.0.2 with: draft: true name: ${{ github.event.input.version }} @@ -111,7 +153,7 @@ jobs: with: persist-credentials: false - name: "Set up GraalVM" - uses: graalvm/setup-graalvm@27b360dbb857524eaf0b4c4cef364d38e5b4f173 # v1.6.7 + uses: graalvm/setup-graalvm@5298d94fb55a4f185c602eeac5de1b553882abe2 # v1.6.4 with: java-version: "25" distribution: "graalvm-community" diff --git a/pom.xml b/pom.xml index 7186ddc46..92206a66f 100644 --- a/pom.xml +++ b/pom.xml @@ -157,6 +157,13 @@ + + + com.google.cloud.artifactregistry + artifactregistry-maven-wagon + 2.2.5 + + @@ -373,5 +380,42 @@ eclipse_plugin + + + oss-exit-gate + + + + org.sonatype.central + central-publishing-maven-plugin + + true + + + + + org.apache.maven.plugins + maven-deploy-plugin + 3.1.3 + + + oss-exit-gate-deploy + deploy + + deploy + + + + + + + + + oss-exit-gate + artifactregistry://us-maven.pkg.dev/oss-exit-gate-prod/google-java-fmt--mavencentral + + +