Skip to content

Commit 1a751bd

Browse files
authored
Merge pull request #300 from zonkyio/ossrh-staging-api
Publishing Artifacts By Using the Portal OSSRH Staging API
2 parents 8d24e14 + 137dc30 commit 1a751bd

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

.github/workflows/release.yml

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ jobs:
88
runs-on: ubuntu-latest
99
steps:
1010
- name: Checkout code
11-
uses: actions/checkout@v3
11+
uses: actions/checkout@v4
1212
with:
1313
ref: master
1414
fetch-depth: 0
@@ -17,7 +17,7 @@ jobs:
1717
git config user.name "Zonky Bot"
1818
git config user.email "[email protected]"
1919
- name: Set up JDK
20-
uses: actions/setup-java@v3
20+
uses: actions/setup-java@v4
2121
with:
2222
distribution: 'zulu'
2323
java-version: 8
@@ -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

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
java: [8, 11, 17]
1111
steps:
1212
- name: Checkout project
13-
uses: actions/checkout@v3
13+
uses: actions/checkout@v4
1414
- name: Set up JDK
15-
uses: actions/setup-java@v3
15+
uses: actions/setup-java@v4
1616
with:
1717
distribution: 'zulu'
1818
java-version: ${{ matrix.java }}

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)