Skip to content

Commit 377ba2f

Browse files
committed
#158 publishing artifacts by using the portal OSSRH staging API
1 parent 4c7aad1 commit 377ba2f

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

.github/workflows/release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,23 @@ jobs:
3333
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
3434
SIGNING_PASS: ${{ secrets.SIGNING_PASS }}
3535
run: mvn -B release:prepare release:perform -DreleaseVersion=$RELEASE_VERSION
36+
- name: Upload staged artifacts to Central Sonatype
37+
env:
38+
SONATYPE_USERNAME: ${{ secrets.MAVEN_USER }}
39+
SONATYPE_PASSWORD: ${{ secrets.MAVEN_PASS }}
40+
run: |
41+
SONATYPE_TOKEN=$(printf "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64)
42+
PUBLISH_NAMESPACE="io.zonky"
43+
echo "Uploading artifacts from OSSRH-Staging to Central Sonatype..."
44+
RESPONSE=$(curl -s -w "%{http_code}" -o response_body.txt -X POST \
45+
-H "Authorization: Bearer $SONATYPE_TOKEN" \
46+
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$PUBLISH_NAMESPACE?publishing_type=user_managed")
47+
if [ "$RESPONSE" -ne 200 ]; then
48+
echo "Failed to upload artifacts to Central Sonatype. Response code: $RESPONSE. Response body: "
49+
cat response_body.txt
50+
echo "Visit https://central.sonatype.com/publishing/deployments for more information."
51+
exit 1
52+
else
53+
echo "Artifacts were uploaded successfully to Central Sonatype."
54+
echo "Visit https://central.sonatype.com/publishing/deployments to view your artifacts."
55+
fi

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@
8383
<distributionManagement>
8484
<repository>
8585
<id>ossrh</id>
86-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
86+
<url>https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/</url>
8787
</repository>
8888
<snapshotRepository>
8989
<id>ossrh</id>
90-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
90+
<url>https://central.sonatype.com/repository/maven-snapshots/</url>
9191
</snapshotRepository>
9292
</distributionManagement>
9393

0 commit comments

Comments
 (0)