Repository navigation
Releases are published to Maven Central through the Central Portal from a GitHub release #37
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
Open
augustak
wants to merge
2
commits into
master
Choose a base branch
from
central-portal-publishing
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
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,38 @@ | ||
| name: Publish | ||
|
|
||
| on: | ||
| release: | ||
| types: [ published ] | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| environment: maven-central | ||
| timeout-minutes: 75 | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| distribution: temurin | ||
| java-version: 8 | ||
|
|
||
| - name: Check that the release tag is the version | ||
| run: | | ||
| version=$(sed -n 's/^version=//p' gradle.properties) | ||
| if [ "$GITHUB_REF_NAME" != "v$version" ]; then | ||
| echo "Release tag $GITHUB_REF_NAME should be v$version, the version in gradle.properties" | ||
| exit 1 | ||
| fi | ||
|
|
||
| - name: Publish to Maven Central | ||
| env: | ||
| ORG_GRADLE_PROJECT_signingKey: ${{ secrets.SIGNING_KEY }} | ||
| ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.SIGNING_PASSWORD }} | ||
| CENTRAL_USERNAME: ${{ secrets.CENTRAL_USERNAME }} | ||
| CENTRAL_PASSWORD: ${{ secrets.CENTRAL_PASSWORD }} | ||
| run: make publish | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| #!/usr/bin/env bash | ||
| # Uploads a bundle to Maven Central through the Central Portal and waits until it is published. | ||
| # CENTRAL_USERNAME and CENTRAL_PASSWORD are a user token from https://central.sonatype.com/account | ||
| # | ||
| # Usage: upload-to-central.sh <bundle.zip> <deployment name> | ||
| set -euo pipefail | ||
|
|
||
| bundle=$1 | ||
| name=$2 | ||
| api=https://central.sonatype.com/api/v1/publisher | ||
| auth="Authorization: Bearer $(printf '%s:%s' "$CENTRAL_USERNAME" "$CENTRAL_PASSWORD" | base64 | tr -d '\n')" | ||
|
augustak marked this conversation as resolved.
Resolved
|
||
|
|
||
| deployment=$(curl --fail-with-body -sS -H "$auth" -F "bundle=@$bundle" \ | ||
| "$api/upload?name=$name&publishingType=AUTOMATIC") | ||
| echo "Uploaded $bundle as deployment $deployment" | ||
|
|
||
| # Validation takes minutes, and publishing to Maven Central after it can take half an hour | ||
| for _ in $(seq 240); do | ||
| status=$(curl --fail-with-body -sS -X POST -H "$auth" "$api/status?id=$deployment") | ||
|
augustak marked this conversation as resolved.
Resolved
augustak marked this conversation as resolved.
Resolved
|
||
| state=$(printf '%s' "$status" | python3 -c 'import json, sys; print(json.load(sys.stdin)["deploymentState"])') | ||
| case $state in | ||
| PUBLISHED) | ||
| echo "Published" | ||
| exit 0 | ||
| ;; | ||
| FAILED) | ||
| echo "Deployment failed: $status" | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| echo "Deployment is $state" | ||
| sleep 15 | ||
| done | ||
|
|
||
| echo "Deployment $deployment was not published within an hour, see https://central.sonatype.com/publishing/deployments" | ||
| exit 1 | ||
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.