Skip to content

Commit c65aebd

Browse files
SDK Update: maven central publishing
Co-authored-by: fern-api <115122769+fern-api[bot]@users.noreply.github.com>
1 parent 2e41f89 commit c65aebd

File tree

5 files changed

+53
-13
lines changed

5 files changed

+53
-13
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,11 @@ jobs:
5454

5555
- name: Publish to maven
5656
run: |
57-
./gradlew publish
57+
./gradlew sonatypeCentralUpload
5858
env:
5959
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
6060
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
61-
MAVEN_PUBLISH_REGISTRY_URL: "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/"
61+
MAVEN_PUBLISH_REGISTRY_URL: "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
62+
MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }}
63+
MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }}
64+
MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }}

.publish/prepare.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Write key ring file
2+
echo "$MAVEN_SIGNATURE_SECRET_KEY" > armored_key.asc
3+
gpg -o publish_key.gpg --dearmor armored_key.asc
4+
5+
# Generate gradle.properties file
6+
echo "signing.keyId=$MAVEN_SIGNATURE_KID" > gradle.properties
7+
echo "signing.secretKeyRingFile=publish_key.gpg" >> gradle.properties
8+
echo "signing.password=$MAVEN_SIGNATURE_PASSWORD" >> gradle.properties

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,4 +214,4 @@ otherwise they would be overwritten upon the next generated release. Feel free t
214214
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
215215
an issue first to discuss with us!
216216

217-
On the other hand, contributions to the README are always very welcome!
217+
On the other hand, contributions to the README are always very welcome!

build.gradle

Lines changed: 39 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ plugins {
22
id 'java-library'
33
id 'maven-publish'
44
id 'com.diffplug.spotless' version '6.11.0'
5+
id 'signing'
6+
id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3'
57
}
68

79
repositories {
810
mavenCentral()
911
maven {
10-
url 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/'
12+
url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
1113
}
1214
}
1315

@@ -59,6 +61,10 @@ javadocJar {
5961
archiveBaseName = "merge-java-client"
6062
}
6163

64+
signing {
65+
sign(publishing.publications)
66+
}
67+
6268
test {
6369
useJUnitPlatform()
6470
testLogging {
@@ -74,11 +80,20 @@ publishing {
7480
version = '4.0.0'
7581
from components.java
7682
pom {
83+
name = 'merge'
84+
description = 'The official SDK of merge'
85+
url = 'https://buildwithfern.com'
7786
licenses {
7887
license {
7988
name = 'CustomLicense{filename: LICENSE}'
8089
}
8190
}
91+
developers {
92+
developer {
93+
name = 'merge'
94+
95+
}
96+
}
8297
scm {
8398
connection = 'scm:git:git://github.com/merge-api/merge-java-client.git'
8499
developerConnection = 'scm:git:git://github.com/merge-api/merge-java-client.git'
@@ -87,14 +102,28 @@ publishing {
87102
}
88103
}
89104
}
90-
repositories {
91-
maven {
92-
url "$System.env.MAVEN_PUBLISH_REGISTRY_URL"
93-
credentials {
94-
username "$System.env.MAVEN_USERNAME"
95-
password "$System.env.MAVEN_PASSWORD"
96-
}
97-
}
98-
}
99105
}
100106

107+
sonatypeCentralUpload {
108+
username = "$System.env.MAVEN_USERNAME"
109+
password = "$System.env.MAVEN_PASSWORD"
110+
111+
archives = files(
112+
"$buildDir/libs/merge-java-client-" + version + ".jar",
113+
"$buildDir/libs/merge-java-client-" + version + "-sources.jar",
114+
"$buildDir/libs/merge-java-client-" + version + "-javadoc.jar"
115+
)
116+
117+
pom = file("$buildDir/publications/maven/pom-default.xml")
118+
signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY"
119+
signingKeyPassphrase = "$System.env.MAVEN_SIGNATURE_PASSWORD"
120+
}
121+
122+
signing {
123+
def signingKeyId = "$System.env.MAVEN_SIGNATURE_SECRET_KEY"
124+
def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD"
125+
useInMemoryPgpKeys(signingKeyId, signingPassword)
126+
sign publishing.publications.maven
127+
}
128+
129+
sonatypeCentralUpload.dependsOn build

gradle.properties

Whitespace-only changes.

0 commit comments

Comments
 (0)