-
Notifications
You must be signed in to change notification settings - Fork 10
fix(android): fail the release when a central deployment does not validate #651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| #!/usr/bin/env bash | ||
| # Waits for a central portal deployment to validate, and fails if it does not. | ||
| # | ||
| # `publishToMavenCentral` uploads and exits 0 whatever the portal makes of the | ||
| # bundle - the vanniktech plugin only validates when `automaticRelease` is on, | ||
| # which would also release it, and releasing is deliberately a human's job here. | ||
| # So the release path polls the portal itself. The maven jar gets this for free: | ||
| # the sonatype maven plugin blocks and reports. | ||
| # | ||
| # await-central-validation.sh <gradle-log> | ||
| # | ||
| # Takes the gradle output to read the deployment id out of, and the portal token | ||
| # as MAVEN_CENTRAL_USERNAME / MAVEN_CENTRAL_PASSWORD. | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| log="${1:?usage: await-central-validation.sh <gradle-log>}" | ||
| : "${MAVEN_CENTRAL_USERNAME:?}" "${MAVEN_CENTRAL_PASSWORD:?}" | ||
|
|
||
| deployment=$(grep -oE 'deployment id: [0-9a-fA-F-]{36}' "$log" | tail -1 | awk '{print $3}') | ||
| if [ -z "$deployment" ]; then | ||
| echo "no deployment id in $log - did the upload actually run?" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| token=$(printf '%s:%s' "$MAVEN_CENTRAL_USERNAME" "$MAVEN_CENTRAL_PASSWORD" | base64 | tr -d '\n') | ||
| echo "waiting on deployment ${deployment}" | ||
|
|
||
| # Validation is usually seconds; the ceiling is only here so a portal that never | ||
| # answers fails the release instead of hanging until github's own timeout. | ||
| for _ in $(seq 60); do | ||
| response=$(curl -sS -X POST -H "Authorization: Bearer ${token}" \ | ||
| "https://central.sonatype.com/api/v1/publisher/status?id=${deployment}") | ||
| state=$(printf '%s' "$response" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("deploymentState",""))') | ||
|
|
||
| case "$state" in | ||
| VALIDATED|PUBLISHING|PUBLISHED) | ||
| echo "deployment ${deployment} is ${state}" | ||
| exit 0 | ||
| ;; | ||
| FAILED) | ||
| echo "deployment ${deployment} failed validation:" >&2 | ||
| printf '%s\n' "$response" >&2 | ||
| exit 1 | ||
| ;; | ||
| PENDING|VALIDATING|"") | ||
| sleep 10 | ||
| ;; | ||
| *) | ||
| echo "unexpected deployment state '${state}':" >&2 | ||
| printf '%s\n' "$response" >&2 | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| echo "deployment ${deployment} still not validated after 10 minutes" >&2 | ||
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.