with one click
deploy-to-maven-central
// Deploys the library to OSSRH staging and creates a pre-release, but publishing must be done manually via the Sonatype web UI.
// Deploys the library to OSSRH staging and creates a pre-release, but publishing must be done manually via the Sonatype web UI.
| name | deploy-to-maven-central |
| description | Deploys the library to OSSRH staging and creates a pre-release, but publishing must be done manually via the Sonatype web UI. |
| disable-model-invocation | true |
| allowed-tools | Bash(*) |
Deploy both auth and store flavours of the Android auth library to the OSSRH staging repository, then upload the staged deployment for publishing.
local.propertiesCheck that the file local.properties in the project root exists and contains all of the following keys:
signing.keyIdsigning.passwordsigning.secretKeyRingFileossrhUsernameossrhPasswordIf the file is missing or any key is absent, stop and tell the user:
local.propertiesmust contain the following properties:signing.keyId=<gpg signing key> signing.password=<gpg signing password> signing.secretKeyRingFile=<gpg keyring> ossrhUsername=<ossrhUsername> ossrhPassword=<ossrhPassword>
Extract the values of ossrhUsername and ossrhPassword from local.properties for use in later steps. Store them in shell variables OSSRH_USER and OSSRH_PASS.
auth flavourRun Gradle to assemble and publish the auth (regular) flavour:
./gradlew :auth-lib:assembleRelease :auth-lib:publishAuthReleasePublicationToOssrh-staging-apiRepository
Wait for this to succeed before continuing.
store flavourRun Gradle to assemble and publish the store flavour:
./gradlew :auth-lib:assembleRelease :auth-lib:publishStoreReleasePublicationToOssrh-staging-apiRepository
Wait for this to succeed before continuing.
Compute a base64-encoded token from the credentials for the OSSRH staging API:
TOKEN=$(printf "$OSSRH_USER:$OSSRH_PASS" | base64)
Call the OSSRH staging API to get the list of repositories:
curl -s --fail \
-H "Authorization: Bearer $TOKEN" \
https://ossrh-staging-api.central.sonatype.com/manual/search/repositories
Parse the JSON response to extract the repository key. It is the key field of the first (or only) entry in the repositories array. Save this as REPO_KEY.
POST to the upload endpoint to promote the staged repository:
curl -s --fail -X POST \
-H "Authorization: Bearer $TOKEN" \
"https://ossrh-staging-api.central.sonatype.com/manual/upload/repository/$REPO_KEY"
If all steps succeeded, tell the user:
Deployment uploaded successfully. To complete publishing, log in to the Sonatype OSSRH portal and manually release the staged repository.
If any step failed, report the error and stop.