Skip to content

Commit 1baec87

Browse files
committed
#96 publishing artifacts by using the portal OSSRH staging API
1 parent 4e21e85 commit 1baec87

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
@@ -374,6 +374,26 @@ jobs:
374374
-PpgVersion=$POSTGRES_VERSION \
375375
-Possrh.username=$MAVEN_USER \
376376
-Possrh.password=$MAVEN_PASS
377+
- name: Upload staged artifacts to Central Sonatype
378+
env:
379+
SONATYPE_USERNAME: ${{ secrets.MAVEN_USER }}
380+
SONATYPE_PASSWORD: ${{ secrets.MAVEN_PASS }}
381+
run: |
382+
SONATYPE_TOKEN=$(printf "$SONATYPE_USERNAME:$SONATYPE_PASSWORD" | base64)
383+
PUBLISH_NAMESPACE="io.zonky"
384+
echo "Uploading artifacts from OSSRH-Staging to Central Sonatype..."
385+
RESPONSE=$(curl -s -w "%{http_code}" -o response_body.txt -X POST \
386+
-H "Authorization: Bearer $SONATYPE_TOKEN" \
387+
"https://ossrh-staging-api.central.sonatype.com/manual/upload/defaultRepository/$PUBLISH_NAMESPACE?publishing_type=user_managed")
388+
if [ "$RESPONSE" -ne 200 ]; then
389+
echo "Failed to upload artifacts to Central Sonatype. Response code: $RESPONSE. Response body: "
390+
cat response_body.txt
391+
echo "Visit https://central.sonatype.com/publishing/deployments for more information."
392+
exit 1
393+
else
394+
echo "Artifacts were uploaded successfully to Central Sonatype."
395+
echo "Visit https://central.sonatype.com/publishing/deployments to view your artifacts."
396+
fi
377397
- name: Create tag
378398
env:
379399
GIT_COMMITTER_DATE: ${{ github.event.milestone.created_at }}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,8 @@ allprojects {
492492
publishing {
493493
repositories {
494494
maven {
495-
def releasesRepoUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
496-
def snapshotsRepoUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
495+
def releasesRepoUrl = "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
496+
def snapshotsRepoUrl = "https://central.sonatype.com/repository/maven-snapshots/"
497497
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
498498
credentials {
499499
username ossrhUsername

0 commit comments

Comments
 (0)