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() } }