diff --git a/.github/workflows/snapshot.yml b/.github/workflows/snapshot.yml index e7305d1e5..41a68d590 100644 --- a/.github/workflows/snapshot.yml +++ b/.github/workflows/snapshot.yml @@ -65,35 +65,71 @@ jobs: run: | set -euo pipefail - log="${RUNNER_TEMP}/snapshot-deploy.log" - deploy() { - ./mvnw -B -T 1 -DskipTests deploy \ + # Central Portal blocks the runner after a few dozen snapshot modules. Further requests + # during that block refresh it, so publish in small chunks and wait quietly between them. + chunk_size=20 + quiet_seconds=600 + max_attempts=3 + order_log="${RUNNER_TEMP}/snapshot-reactor-order.log" + deploy_log="${RUNNER_TEMP}/snapshot-deploy.log" + + ./mvnw -B -DskipTests validate | tee "${order_log}" + mapfile -t artifacts < <(sed -nE 's/.*< [^:>]+:([^ >]+) >.*/\1/p' "${order_log}" | awk '!seen[$0]++') + if (( ${#artifacts[@]} == 0 )); then + echo "Could not read the Maven reactor order." >&2 + exit 1 + fi + + ./mvnw -B -DskipTests install + + deploy_chunk() { + ./mvnw -B -T 1 -DskipTests -nsu deploy \ -DaltDeploymentRepository=jfoundry::https://central.sonatype.com/repository/maven-snapshots/ \ -Daether.connector.basic.parallelPut=false \ -Daether.connector.basic.upstreamThreads=1 \ -Daether.transport.http.maxConnectionsPerRoute=1 \ - -Daether.transport.http.retryHandler.count=6 \ - -Daether.transport.http.retryHandler.interval=15000 + -pl "$1" } - attempt=1 - max_attempts=4 - while true; do - set +e - deploy 2>&1 | tee "${log}" - status="${PIPESTATUS[0]}" - set -e - if [[ "${status}" -eq 0 ]]; then - exit 0 + index=0 + total="${#artifacts[@]}" + while (( index < total )); do + selector="" + chunk_end=$(( index + chunk_size )) + if (( chunk_end > total )); then + chunk_end="${total}" fi - if ! grep -Eq 'status=429|error-1015|Error 1015' "${log}"; then - exit "${status}" - fi - if (( attempt >= max_attempts )); then - exit "${status}" + for (( cursor = index; cursor < chunk_end; cursor++ )); do + if [[ -n "${selector}" ]]; then + selector+="," + fi + selector+=":${artifacts[cursor]}" + done + + echo "Publishing Central snapshot chunk $(( index / chunk_size + 1 )): ${selector}" + attempt=1 + while true; do + set +e + deploy_chunk "${selector}" 2>&1 | tee "${deploy_log}" + status="${PIPESTATUS[0]}" + set -e + if [[ "${status}" -eq 0 ]]; then + break + fi + if ! grep -Eq 'status=429|error-1015|Error 1015' "${deploy_log}"; then + exit "${status}" + fi + if (( attempt >= max_attempts )); then + exit "${status}" + fi + echo "Central Portal rate limited snapshot chunk $(( index / chunk_size + 1 )) (attempt ${attempt}/${max_attempts}). Waiting ${quiet_seconds}s before retrying the same chunk." + sleep "${quiet_seconds}" + attempt=$(( attempt + 1 )) + done + + index="${chunk_end}" + if (( index < total )); then + echo "Waiting ${quiet_seconds}s before the next Central snapshot deploy chunk." + sleep "${quiet_seconds}" fi - sleep_seconds=$(( attempt * 90 )) - echo "Central Portal rate limited the snapshot deploy (attempt ${attempt}/${max_attempts}). Waiting ${sleep_seconds}s before retrying." - sleep "${sleep_seconds}" - attempt=$(( attempt + 1 )) done diff --git a/docs/release/maven-central.md b/docs/release/maven-central.md index e496b7d75..5763ee3d1 100644 --- a/docs/release/maven-central.md +++ b/docs/release/maven-central.md @@ -158,7 +158,7 @@ including standalone BOM modules. Publish the current development version locally with: ```bash -./mvnw -T 1 -DskipTests deploy \ +./mvnw -T 1 -DskipTests -nsu deploy \ -DaltDeploymentRepository=jfoundry::https://central.sonatype.com/repository/maven-snapshots/ \ -Daether.connector.basic.parallelPut=false \ -Daether.connector.basic.upstreamThreads=1 \ @@ -168,29 +168,19 @@ Publish the current development version locally with: `.mvn/maven.config` otherwise selects `-T 1C`. `-T 1` only publishes one reactor module at a time. Resolver still uploads that module's JAR, POM, sources, Javadoc, and checksums together: the default is `aether.connector.basic.parallelPut=true` with five upstream threads. Central Portal -answers that burst with Cloudflare error 1015 (HTTP 429). +answers that burst with Cloudflare error 1015 (HTTP 429). `-nsu` avoids refreshing snapshot +metadata while publishing. Requests made during an active block refresh the block, so wait for it +to expire instead of retrying immediately. The current reactor version must end with `-SNAPSHOT`. Do not use the release workflow for SNAPSHOTs; it intentionally rejects SNAPSHOT versions. GitHub Actions publishes SNAPSHOTs through `.github/workflows/snapshot.yml`. It runs when `main` is pushed and can also be started manually from the Actions tab. The workflow verifies that the -current root version is a SNAPSHOT before deploying: - -```bash -./mvnw -B -T 1 -DskipTests deploy \ - -DaltDeploymentRepository=jfoundry::https://central.sonatype.com/repository/maven-snapshots/ \ - -Daether.connector.basic.parallelPut=false \ - -Daether.connector.basic.upstreamThreads=1 \ - -Daether.transport.http.maxConnectionsPerRoute=1 \ - -Daether.transport.http.retryHandler.count=6 \ - -Daether.transport.http.retryHandler.interval=15000 -``` - -Leave `aether.transport.http.retryHandler.intervalMax` at its 300000 ms default. Resolver cancels -the HTTP retry when a `Retry-After` value is above that cap, so a lower cap turns HTTP 429 into an -immediate failure. If error 1015 is still present after Maven exits, the workflow waits and retries -the deploy. +current root version is a SNAPSHOT before deploying. It installs the reactor locally, then publishes +20 modules at a time with the single-thread command above. It waits 10 minutes before the next +chunk. A chunk that still receives error 1015 is retried after the same quiet wait; earlier chunks +are not published again. Consumers must add the Central Portal snapshots repository to resolve these versions: diff --git a/scripts/verify-supply-chain-workflows-test.sh b/scripts/verify-supply-chain-workflows-test.sh index 8c968a493..86328ec73 100644 --- a/scripts/verify-supply-chain-workflows-test.sh +++ b/scripts/verify-supply-chain-workflows-test.sh @@ -301,8 +301,10 @@ jobs: esac - name: Publish SNAPSHOT if: steps.version.outputs.is_snapshot == 'true' - run: ./mvnw -B -T 1 -DskipTests deploy -Daether.connector.basic.parallelPut=false -Daether.connector.basic.upstreamThreads=1 -Daether.transport.http.maxConnectionsPerRoute=1 - - run: grep -Eq 'status=429|error-1015|Error 1015' deploy.log + run: | + ./mvnw -B -T 1 -DskipTests -nsu deploy -Daether.connector.basic.parallelPut=false -Daether.connector.basic.upstreamThreads=1 -Daether.transport.http.maxConnectionsPerRoute=1 + grep -Eq 'status=429|error-1015|Error 1015' deploy.log + echo "Waiting ${quiet_seconds}s before the next Central snapshot deploy chunk." YAML assert_rejects "${temp_dir}" write_compliant_auto_merge_workflow diff --git a/scripts/verify-supply-chain-workflows.py b/scripts/verify-supply-chain-workflows.py index 2fb033cf7..b02f05ca0 100755 --- a/scripts/verify-supply-chain-workflows.py +++ b/scripts/verify-supply-chain-workflows.py @@ -224,7 +224,7 @@ def main() -> None: "git merge-base --is-ancestor", 'gh workflow run release.yml --repo "${GITHUB_REPOSITORY}" --ref main -f "release_tag=${RELEASE_TAG}"', ], - ".github/workflows/snapshot.yml": ["bash scripts/maven-project-version.sh", "is_snapshot=true", "if: steps.version.outputs.is_snapshot == 'true'", "./mvnw -B -T 1 -DskipTests deploy", "-Daether.connector.basic.parallelPut=false", "-Daether.connector.basic.upstreamThreads=1", "-Daether.transport.http.maxConnectionsPerRoute=1", "status=429|error-1015|Error 1015"], + ".github/workflows/snapshot.yml": ["bash scripts/maven-project-version.sh", "is_snapshot=true", "if: steps.version.outputs.is_snapshot == 'true'", "./mvnw -B -T 1 -DskipTests -nsu deploy", "-Daether.connector.basic.parallelPut=false", "-Daether.connector.basic.upstreamThreads=1", "-Daether.transport.http.maxConnectionsPerRoute=1", "status=429|error-1015|Error 1015", "Waiting ${quiet_seconds}s before the next Central snapshot deploy chunk."], ".github/workflows/prepare-snapshot.yml": ["workflow_run:", "workflows:", "- Release", "git tag --points-at", "contents: write", "pull-requests: write", "scripts/set-maven-reactor-version.py", "git push --set-upstream origin", "gh pr create"], } verify_ci(root)