From fc7904c29d2eb0f624698a618472aa0d84f19790 Mon Sep 17 00:00:00 2001 From: Fernando Alonso Date: Thu, 19 Nov 2026 18:25:48 +0000 Subject: [PATCH 1/2] 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 + + + From d02d037aa8ad21081cefb5ac577d96162115c4aa Mon Sep 17 00:00:00 2001 From: Fernando Alonso Date: Mon, 23 Nov 2026 17:42:28 +0000 Subject: [PATCH 2/2] ci(release): scope Exit Gate manifest to publish_all=false --- .github/workflows/release.yml | 39 ++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a9f0bbf58..0e0cf986e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -101,9 +101,46 @@ jobs: GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} RUN_ID: ${{ github.run_id }} RUN_ATTEMPT: ${{ github.run_attempt }} + VERSION: ${{ github.event.inputs.version }} 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 + python3 - "${VERSION}" <<'PY' + import collections, json, os, subprocess, sys + version = os.environ.get("VERSION") or (sys.argv[1] if len(sys.argv) > 1 else "") + if not version: + raise SystemExit("ERROR: missing release version for manifest generation") + repo = "google-java-fmt--mavencentral" + pkgs_out = subprocess.check_output([ + "gcloud", "artifacts", "packages", "list", + "--project=oss-exit-gate-prod", "--location=us", + f"--repository={repo}", "--format=value(name)", + ], text=True).splitlines() + groups = collections.defaultdict(list) + for pkg_path in sorted(pkgs_out): + pkg_id = pkg_path.strip().split("/")[-1] + if ":" not in pkg_id: + continue + rc = subprocess.run([ + "gcloud", "artifacts", "versions", "describe", version, + f"--package={pkg_id}", "--project=oss-exit-gate-prod", + "--location=us", f"--repository={repo}", + ], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode + if rc == 0: + ns, name = pkg_id.split(":", 1) + groups[ns].append({"name": name, "version": version}) + if not groups: + raise SystemExit(f"ERROR: No staged Maven packages found in {repo} for version {version}") + manifest = { + "publish_all": False, + "publishing_groups": [ + {"namespace": ns, "packages": pkgs} + for ns, pkgs in sorted(groups.items()) + ], + } + with open("manifest.json", "w", encoding="utf-8") as fh: + json.dump(manifest, fh, indent=2) + fh.write("\n") + PY 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