From e6a5caa503b7ce3cf406c14b5134dc0b88588fa6 Mon Sep 17 00:00:00 2001 From: Eric <60104846+ericlmao@users.noreply.github.com> Date: Thu, 19 Nov 2026 19:36:48 +0100 Subject: [PATCH] ci: stop the Central publish at validation and wait up to an hour for the release to appear Central validates a deployment (signatures, POMs, sources and javadoc) within seconds but then publishes it on its own schedule, which took 15.5 minutes for 1.10.1 and longer for 1.10.2. The publishing plugin waits a fixed 15 minutes for PUBLISHED, so the 1.10.2 release job failed although its deployment was valid. Publish now returns once the deployment is VALIDATED (a signing or POM problem still fails the job), and the verify step polls Maven Central every 30 seconds for up to 60 minutes, logging progress. --- .github/scripts/check_central_release.py | 31 +++++++++++++++++------- .github/workflows/maven-central.yml | 6 +++-- build.gradle.kts | 6 ++++- 3 files changed, 31 insertions(+), 12 deletions(-) diff --git a/.github/scripts/check_central_release.py b/.github/scripts/check_central_release.py index 98af9e5..7edaae8 100644 --- a/.github/scripts/check_central_release.py +++ b/.github/scripts/check_central_release.py @@ -31,9 +31,29 @@ def on_central(coordinate, suffix=".pom"): raise +def wait_for_publication(coordinates, version, wait_minutes): + # Central publishes a validated deployment on its own schedule, often 15 minutes or more. + files = (".pom", ".jar", "-sources.jar", "-javadoc.jar") + start = time.monotonic() + deadline = start + wait_minutes * 60 + while True: + missing = [(gav, suffix) for gav in coordinates for suffix in files if not on_central(gav, suffix)] + waited = int((time.monotonic() - start) / 60) + if not missing: + print(f"All Maven Central publications are visible for {version} after {waited} minute(s).", flush=True) + return + if time.monotonic() >= deadline: + raise SystemExit(f"Maven Central has yet to expose {missing} after {wait_minutes:g} minute(s); " + "the deployment may still be publishing (check the Central Portal deployments page)") + print(f"Waiting for Maven Central ({waited} minute(s)): {len(missing)} file(s) not visible yet", flush=True) + time.sleep(30) + + def main(): parser = argparse.ArgumentParser() parser.add_argument("--published", action="store_true") + parser.add_argument("--wait-minutes", type=float, default=60, + help="with --published: how long to wait for the release to appear on Maven Central") parser.add_argument("poms", nargs=4, type=Path) args = parser.parse_args() @@ -47,15 +67,8 @@ def main(): raise SystemExit(f"Release tag {tag} does not match publication version {version}") if args.published: - files = (".pom", ".jar", "-sources.jar", "-javadoc.jar") - for attempt in range(13): - missing = [(gav, suffix) for gav in coordinates for suffix in files if not on_central(gav, suffix)] - if not missing: - print(f"All Maven Central publications are visible for {version}.") - return - if attempt < 12: - time.sleep(10) - raise SystemExit(f"Maven Central has yet to expose {missing}") + wait_for_publication(coordinates, version, args.wait_minutes) + return existing = [gav for gav in coordinates if on_central(gav)] if existing and len(existing) != len(coordinates): diff --git a/.github/workflows/maven-central.yml b/.github/workflows/maven-central.yml index debef06..63c254f 100644 --- a/.github/workflows/maven-central.yml +++ b/.github/workflows/maven-central.yml @@ -32,7 +32,7 @@ jobs: if: ${{ (github.event_name == 'release' && !github.event.release.prerelease) || (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') }} needs: verify runs-on: ubuntu-latest - timeout-minutes: 70 + timeout-minutes: 80 concurrency: group: maven-central queue: max @@ -67,5 +67,7 @@ jobs: : "${ORG_GRADLE_PROJECT_mavenCentralPassword:?Missing MAVEN_CENTRAL_PASSWORD}" : "${ORG_GRADLE_PROJECT_signingInMemoryKey:?Missing MAVEN_CENTRAL_SIGNING_KEY}" bash ./gradlew -PcentralRelease publishToMavenCentral + # Publishing returns once Central has validated the deployment; Central then publishes it on its own + # schedule (often 15 minutes or more), so this step waits up to an hour for every file to appear. - name: Verify published artifacts - run: python3 .github/scripts/check_central_release.py --published ./*/build/publications/mavenJava/pom-default.xml + run: python3 .github/scripts/check_central_release.py --published --wait-minutes 60 ./*/build/publications/mavenJava/pom-default.xml diff --git a/build.gradle.kts b/build.gradle.kts index b0e6425..e3ef00a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -67,7 +67,11 @@ subprojects { } } configure { - publishToMavenCentral(automaticRelease = true, validateDeployment = DeploymentValidation.PUBLISHED) + // Wait only until Central has validated the deployment (signatures, POMs, sources and javadoc). + // Central's own publishing step afterwards often takes 15 minutes or more, longer than the + // plugin's fixed 15-minute wait for PUBLISHED; the workflow's "Verify published artifacts" step + // waits for the release to appear on Maven Central instead. + publishToMavenCentral(automaticRelease = true, validateDeployment = DeploymentValidation.VALIDATED) signAllPublications() } }