Skip to content

Commit 137dc30

Browse files
committed
#299 publishing artifacts by using the portal OSSRH staging API
1 parent 12825fb commit 137dc30

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

.github/workflows/release.yml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,24 @@ jobs:
4848
-Prelease.useAutomaticVersion=true \
4949
-Prelease.releaseVersion=$RELEASE_VERSION \
5050
-Possrh.username=$MAVEN_USER \
51-
-Possrh.password=$MAVEN_PASS
51+
-Possrh.password=$MAVEN_PASS
52+
- name: Upload staged artifacts to Central Sonatype
53+
env:
54+
SONATYPE_USERNAME: ${{ secrets.MAVEN_USER }}
55+
SONATYPE_PASSWORD: ${{ secrets.MAVEN_PASS }}
56+
run: |
57+
SONATYPE_TOKEN=$(printf "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64)
58+
PUBLISH_NAMESPACE="io.zonky"
59+
echo "Uploading artifacts from OSSRH-Staging to Central Sonatype..."
60+
RESPONSE=$(curl -s -w "%{http_code}" -o response_body.txt -X POST \
61+
-H "Authorization: Bearer $SONATYPE_TOKEN" \
62+
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$PUBLISH_NAMESPACE?publishing_type=user_managed")
63+
if [ "$RESPONSE" -ne 200 ]; then
64+
echo "Failed to upload artifacts to Central Sonatype. Response code: $RESPONSE. Response body: "
65+
cat response_body.txt
66+
echo "Visit https://central.sonatype.com/publishing/deployments for more information."
67+
exit 1
68+
else
69+
echo "Artifacts were uploaded successfully to Central Sonatype."
70+
echo "Visit https://central.sonatype.com/publishing/deployments to view your artifacts."
71+
fi

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ subprojects {
208208

209209
repositories {
210210
maven {
211-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
212-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
211+
def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
212+
def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
213213
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
214214
credentials {
215215
username ossrhUsername

0 commit comments

Comments
 (0)