diff --git a/README.md b/README.md index 390a0da..071c0c7 100644 --- a/README.md +++ b/README.md @@ -50,9 +50,9 @@ signing.keyId= signing.password= signing.secretKeyRingFile= -sonatype.url=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -sonatype.username= -sonatype.password= +sonatypeUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ +sonatypeUsername= +sonatypePassword= ``` To deploy a new version to Maven Central, use `deploy.sh`: @@ -61,4 +61,4 @@ To deploy a new version to Maven Central, use `deploy.sh`: ./publish.sh [optional tag message] ``` -The publish script will automatically push a tag with the version name and change the version in the README. +The `publish.sh` script will automatically push a tag with the version name and change the version in the README. diff --git a/build.gradle.kts b/build.gradle.kts index e721682..5c6a945 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,3 +1,7 @@ +plugins { + id("io.github.gradle-nexus.publish-plugin") version "1.0.0" +} + buildscript { repositories { maven { url = uri("https://plugins.gradle.org/m2/") } @@ -12,3 +16,20 @@ allprojects { mavenCentral() } } + +group = "com.infinum" +version = "3.0.0" + +nexusPublishing { + repositories { + sonatype() + } +} + +//do not generate extra load on Nexus with new staging repository if signing fails +val initializeSonatypeStagingRepository by tasks.existing +subprojects { + initializeSonatypeStagingRepository { + shouldRunAfter(tasks.withType()) + } +} \ No newline at end of file diff --git a/publish.sh b/publish.sh index b51f80d..eda2d84 100755 --- a/publish.sh +++ b/publish.sh @@ -17,6 +17,7 @@ set -euo pipefail; readonly SCRIPT_NAME="$(basename "$0")" readonly green="\e[0;32m" +readonly red="\e[0;31m" readonly reset="\e[0m" if [ $# -lt 1 ]; then @@ -36,7 +37,10 @@ if [ -n "${2-}" ]; then fi echo -e "${green}Building and uploading release ...${reset}" -./gradlew clean build publishLibraryPublicationToSonatypeRepository +./gradlew clean build publishToSonatype + +echo -e "${green}Closing sonatype staging repository ...${reset}" +./gradlew closeSonatypeStagingRepository echo -e "${green}Pushing version tag ...${reset}" git tag -a "${version}" -m "${tag_message}" && \ @@ -48,4 +52,6 @@ sed -E "s/\"com.infinum:retrofit-converter-thrifty:[\.0-9]+\"/\"com.infinum:retr # show changes so we know to commit if needed echo -e "${green}\nHere's the output of git status:\n${reset}" -git status \ No newline at end of file +git status + +echo -e "${red}\n\nDON'T FORGET to release the artifact on https://oss.sonatype.org/#stagingRepositories !\n${reset}" \ No newline at end of file diff --git a/retrofit-converter-thrifty/build.gradle.kts b/retrofit-converter-thrifty/build.gradle.kts index 84fcc47..50b49a5 100644 --- a/retrofit-converter-thrifty/build.gradle.kts +++ b/retrofit-converter-thrifty/build.gradle.kts @@ -9,9 +9,6 @@ plugins { id("signing") } -group = "com.infinum" -version = "3.0.0" - java { withJavadocJar() withSourcesJar() @@ -62,19 +59,19 @@ tasks.withType().configureEach { publishing { repositories { maven { - name = "Sonatype" - url = URI.create(project.property("sonatype.url") as String) + name = "MavenCentral" + url = URI.create(project.property("sonatypeUrl") as String) credentials { - username = project.property("sonatype.username") as String - password = project.property("sonatype.password") as String + username = project.property("sonatypeUsername") as String + password = project.property("sonatypePassword") as String } } } publications { create("library") { - groupId = project.group as String? + groupId = rootProject.group as String? artifactId = project.name - version = project.version as String? + version = rootProject.version as String? from(components["java"])