diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6274e3787..2cba5f8f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,8 +54,11 @@ jobs: - name: Publish to maven run: | - ./gradlew publish + ./gradlew sonatypeCentralUpload env: MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} - MAVEN_PUBLISH_REGISTRY_URL: "https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/" + MAVEN_PUBLISH_REGISTRY_URL: "https://oss.sonatype.org/service/local/staging/deploy/maven2/" + MAVEN_SIGNATURE_KID: ${{ secrets.MAVEN_SIGNATURE_KID }} + MAVEN_SIGNATURE_SECRET_KEY: ${{ secrets.MAVEN_SIGNATURE_SECRET_KEY }} + MAVEN_SIGNATURE_PASSWORD: ${{ secrets.MAVEN_SIGNATURE_PASSWORD }} diff --git a/.publish/prepare.sh b/.publish/prepare.sh new file mode 100755 index 000000000..df3948e3d --- /dev/null +++ b/.publish/prepare.sh @@ -0,0 +1,8 @@ +# Write key ring file +echo "$MAVEN_SIGNATURE_SECRET_KEY" > armored_key.asc +gpg -o publish_key.gpg --dearmor armored_key.asc + +# Generate gradle.properties file +echo "signing.keyId=$MAVEN_SIGNATURE_KID" > gradle.properties +echo "signing.secretKeyRingFile=publish_key.gpg" >> gradle.properties +echo "signing.password=$MAVEN_SIGNATURE_PASSWORD" >> gradle.properties diff --git a/README.md b/README.md index a2f038f13..cc2144127 100644 --- a/README.md +++ b/README.md @@ -214,4 +214,4 @@ otherwise they would be overwritten upon the next generated release. Feel free t a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us! -On the other hand, contributions to the README are always very welcome! +On the other hand, contributions to the README are always very welcome! \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4ec4eb9a5..8c653b0ac 100644 --- a/build.gradle +++ b/build.gradle @@ -2,12 +2,14 @@ plugins { id 'java-library' id 'maven-publish' id 'com.diffplug.spotless' version '6.11.0' + id 'signing' + id 'cl.franciscosolis.sonatype-central-upload' version '1.0.3' } repositories { mavenCentral() maven { - url 'https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/' + url 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' } } @@ -59,6 +61,10 @@ javadocJar { archiveBaseName = "merge-java-client" } +signing { + sign(publishing.publications) +} + test { useJUnitPlatform() testLogging { @@ -74,11 +80,20 @@ publishing { version = '4.0.0' from components.java pom { + name = 'merge' + description = 'The official SDK of merge' + url = 'https://buildwithfern.com' licenses { license { name = 'CustomLicense{filename: LICENSE}' } } + developers { + developer { + name = 'merge' + email = 'developers@merge.com' + } + } scm { connection = 'scm:git:git://github.com/merge-api/merge-java-client.git' developerConnection = 'scm:git:git://github.com/merge-api/merge-java-client.git' @@ -87,14 +102,28 @@ publishing { } } } - repositories { - maven { - url "$System.env.MAVEN_PUBLISH_REGISTRY_URL" - credentials { - username "$System.env.MAVEN_USERNAME" - password "$System.env.MAVEN_PASSWORD" - } - } - } } +sonatypeCentralUpload { + username = "$System.env.MAVEN_USERNAME" + password = "$System.env.MAVEN_PASSWORD" + + archives = files( + "$buildDir/libs/merge-java-client-" + version + ".jar", + "$buildDir/libs/merge-java-client-" + version + "-sources.jar", + "$buildDir/libs/merge-java-client-" + version + "-javadoc.jar" + ) + + pom = file("$buildDir/publications/maven/pom-default.xml") + signingKey = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" + signingKeyPassphrase = "$System.env.MAVEN_SIGNATURE_PASSWORD" +} + +signing { + def signingKeyId = "$System.env.MAVEN_SIGNATURE_SECRET_KEY" + def signingPassword = "$System.env.MAVEN_SIGNATURE_PASSWORD" + useInMemoryPgpKeys(signingKeyId, signingPassword) + sign publishing.publications.maven +} + +sonatypeCentralUpload.dependsOn build diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..e69de29bb