Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 22 additions & 9 deletions .github/scripts/check_central_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@ subprojects {
}
}
configure<MavenPublishBaseExtension> {
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()
}
}
Expand Down
Loading