From be8ea5f49a6d04cfa4500ba0ea65033f521127a5 Mon Sep 17 00:00:00 2001 From: Bram Wijnands Date: Sat, 2 Mar 2024 14:37:53 +0000 Subject: [PATCH 1/4] Sign and published to MavenCentral. --- README.md | 2 +- build.gradle.kts | 29 ++++++++++++++++----------- examples/android/app/build.gradle.kts | 2 +- examples/java/build.gradle.kts | 2 +- examples/paginate/build.gradle.kts | 2 +- 5 files changed, 21 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 293d3dd..d1703cb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Build](https://github.com/Bram--/bggclient/actions/workflows/ci.yml/badge.svg)](https://github.com/Bram--/bggclient/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/Bram--/bggclient/graph/badge.svg?token=FJDN8I5FR1)](https://codecov.io/gh/Bram--/bggclient) +[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Build](https://github.com/Bram--/bggclient/actions/workflows/ci.yml/badge.svg)](https://github.com/Bram--/bggclient/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/Bram--/bggclient/graph/badge.svg?token=FJDN8I5FR1)](https://codecov.io/gh/Bram--/bggclient) [![Maven Central](https://img.shields.io/maven-central/v/org.audux.bgg/bggclient.svg)](https://search.maven.org/artifact/org.audux.bgg/bggclient) # Board Game Geek Client/BGGClient diff --git a/build.gradle.kts b/build.gradle.kts index 0bd8421..f048c95 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,8 +2,10 @@ plugins { jacoco `java-library` `maven-publish` + signing alias(libs.plugins.org.jetbrains.kotlin.jvm) alias(libs.plugins.ktfmt.gradle) + id("com.gradleup.nmcp").version("0.0.4") } java { @@ -13,14 +15,14 @@ java { publishing { publications { - create("maven") { + create("mavenJava") { groupId = "org.audux.bgg" artifactId = "bggclient" - version = "0.5.0" + version = "0.5.1" pom { name = "Unofficial JVM BGG client" - description = "Wrapper around the Board Game Geek's XML1 and XML2 APIs" + description = "Library to fetch data from the Board game geek (XML) APIs. Usable in Java and Kotlin on the JVM or Android." url = "https://github.com/Bram--/bggclient" licenses { license { @@ -45,19 +47,22 @@ publishing { from(components["java"]) } } +} - repositories { - maven { - name = "OSSRH" - url = uri("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - credentials { - username = System.getenv("MAVEN_USERNAME") - password = System.getenv("MAVEN_PASSWORD") - } - } +nmcp { + publish("mavenJava") { + username = System.getenv("MAVEN_USERNAME") + password = System.getenv("MAVEN_PASSWORD") + publicationType = "AUTOMATIC" } } + +signing { + useGpgCmd() + sign(publishing.publications["mavenJava"]) +} + ktfmt { kotlinLangStyle() diff --git a/examples/android/app/build.gradle.kts b/examples/android/app/build.gradle.kts index 6d86416..48b2404 100644 --- a/examples/android/app/build.gradle.kts +++ b/examples/android/app/build.gradle.kts @@ -68,7 +68,7 @@ dependencies { implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.7.0") implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.7.0") implementation("io.coil-kt:coil-compose:2.5.0") - implementation("org.audux.bgg:bggclient:0.5.0") + implementation("org.audux.bgg:bggclient:0.5.1") testImplementation("junit:junit:4.13.2") diff --git a/examples/java/build.gradle.kts b/examples/java/build.gradle.kts index 7ed9c32..a0b0b24 100644 --- a/examples/java/build.gradle.kts +++ b/examples/java/build.gradle.kts @@ -12,7 +12,7 @@ repositories { } dependencies { - implementation("org.audux.bgg:bggclient:0.5.0") + implementation("org.audux.bgg:bggclient:0.5.1") testImplementation(platform("org.junit:junit-bom:5.9.1")) testImplementation("org.junit.jupiter:junit-jupiter") diff --git a/examples/paginate/build.gradle.kts b/examples/paginate/build.gradle.kts index d297c23..62bfaad 100644 --- a/examples/paginate/build.gradle.kts +++ b/examples/paginate/build.gradle.kts @@ -20,7 +20,7 @@ application { } dependencies { - implementation("org.audux.bgg:bggclient:0.5.0") + implementation("org.audux.bgg:bggclient:0.5.1") testImplementation("org.jetbrains.kotlin:kotlin-test") } From a5cc1621173a7f3b9a397e70d8abc502d4c090aa Mon Sep 17 00:00:00 2001 From: Bram Wijnands Date: Sat, 2 Mar 2024 14:41:26 +0000 Subject: [PATCH 2/4] Add usage to README. --- README.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d1703cb..ad02760 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Build](https://github.com/Bram--/bggclient/actions/workflows/ci.yml/badge.svg)](https://github.com/Bram--/bggclient/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/Bram--/bggclient/graph/badge.svg?token=FJDN8I5FR1)](https://codecov.io/gh/Bram--/bggclient) [![Maven Central](https://img.shields.io/maven-central/v/org.audux.bgg/bggclient.svg)](https://search.maven.org/artifact/org.audux.bgg/bggclient) +[![GitHub License](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Build](https://github.com/Bram--/bggclient/actions/workflows/ci.yml/badge.svg)](https://github.com/Bram--/bggclient/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/Bram--/bggclient/graph/badge.svg?token=FJDN8I5FR1)](https://codecov.io/gh/Bram--/bggclient) [![Maven Central](https://img.shields.io/maven-central/v/org.audux.bgg/bggclient.svg)](https://central.sonatype.com/artifact/org.audux.bgg/bggclient) # Board Game Geek Client/BGGClient @@ -35,15 +35,24 @@ A short summary of all available APIs/Endpoints available. ## Usage -TODO: Publish +The library is published on [MavenCentral as bggclient](https://central.sonatype.com/artifact/org.audux.bgg/bggclient) so using it is as simple as adding a single line to Gradle. ##### Gradle -TODO: Publish +```kotlin +implementation("org.audux.bgg:bggclient:0.5.1") +``` ##### Maven -TODO: Publish +```xml + + org.audux.bgg + bggclient + 0.5.0 + +``` + ## Examples From 42f8f668f121ddb23f79568fb846457feb5a9e11 Mon Sep 17 00:00:00 2001 From: Bram Wijnands Date: Sat, 2 Mar 2024 14:56:23 +0000 Subject: [PATCH 3/4] Export env variable instead of using GpgCmd --- .github/workflows/gradle-publish.yml | 8 +++++--- build.gradle.kts | 3 ++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/gradle-publish.yml b/.github/workflows/gradle-publish.yml index b4fb59c..513a0eb 100644 --- a/.github/workflows/gradle-publish.yml +++ b/.github/workflows/gradle-publish.yml @@ -37,7 +37,9 @@ jobs: run: ./gradlew build - name: Publish package - run: ./gradlew publish + run: ./gradlew publishAllPublicationsToCentralPortal env: - MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }} - MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }} + MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }} + MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} + GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} + GPG_SIGNING_PASSWORD: ${{ secrets.GPG_SIGNING_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index f048c95..ac79023 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -59,7 +59,8 @@ nmcp { signing { - useGpgCmd() + useInMemoryPgpKeys(System.getenv("GPG_SIGNING_KEY"), System.getenv("GPG_SIGNING_PASSWORD")) + sign(publishing.publications["mavenJava"]) } From 070d423a9a996389c9368b2bd538c3af454ce985 Mon Sep 17 00:00:00 2001 From: Bram Wijnands Date: Sat, 2 Mar 2024 15:36:06 +0000 Subject: [PATCH 4/4] Only sign on "publishAllPublicationsToCentralPortal". --- build.gradle.kts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index ac79023..8f4a981 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -22,7 +22,8 @@ publishing { pom { name = "Unofficial JVM BGG client" - description = "Library to fetch data from the Board game geek (XML) APIs. Usable in Java and Kotlin on the JVM or Android." + description = + "Library to fetch data from the Board game geek (XML) APIs. Usable in Java and Kotlin on the JVM or Android." url = "https://github.com/Bram--/bggclient" licenses { license { @@ -57,11 +58,16 @@ nmcp { } } - signing { - useInMemoryPgpKeys(System.getenv("GPG_SIGNING_KEY"), System.getenv("GPG_SIGNING_PASSWORD")) - - sign(publishing.publications["mavenJava"]) + if (project.gradle.startParameter.taskNames.contains("publishAllPublicationsToCentralPortal")) { + afterEvaluate { + useInMemoryPgpKeys( + System.getenv("GPG_SIGNING_KEY"), + System.getenv("GPG_SIGNING_PASSWORD") + ) + sign(publishing.publications["mavenJava"]) + } + } } ktfmt {