From dbf5acd0bc4b3a7cfac6b382e06a215eb1e23785 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 20 Dec 2024 15:52:44 -0300 Subject: [PATCH 1/3] publishing: adding nexus publishing plugin --- build.gradle.kts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle.kts b/build.gradle.kts index 44bd0f139..0fe28374c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,6 +34,13 @@ plugins { id("org.jetbrains.dokka") version "1.8.20" apply false id("com.adarshr.test-logger") version "3.2.0" apply false kotlin("plugin.serialization") version "1.9.0" apply false + id("io.github.gradle-nexus.publish-plugin") version "2.0.0" +} + +nexusPublishing { + repositories { + sonatype() + } } subprojects { From e20798f171bfe4474ce8dc1ca59d88ca5d4eed16 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 20 Dec 2024 17:08:27 -0300 Subject: [PATCH 2/3] publishing: adding workflow dispatch inputs to publication workflows --- .github/workflows/publish-android.yml | 21 +++++++++++++++++++-- .github/workflows/publish-jvm.yml | 22 +++++++++++++++++++--- 2 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml index d3effc7e9..ed8644b3e 100644 --- a/.github/workflows/publish-android.yml +++ b/.github/workflows/publish-android.yml @@ -12,7 +12,22 @@ on: description: Target branch type: string required: false + github_publish: + type: boolean + required: false + default: true + maven_publish: + type: boolean + required: false + default: true workflow_dispatch: + inputs: + github_publish: + description: 'Publish to github packages' + default: true + maven_publish: + description: 'Publish to Maven Central' + default: true env: CARGO_TERM_COLOR: always @@ -70,7 +85,8 @@ jobs: echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV fi - - name: Gradle Publish Android Package to GitHub packages repository + - if: ${{ github.event.inputs.github_publish == 'true' }} + name: Gradle Publish Android Package to GitHub packages repository run: ./gradlew publishAndroidReleasePublicationToGithubPackagesRepository -PremotePublication=true -Pandroid=true ${{ env.PUB_MODE }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -79,7 +95,8 @@ jobs: ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }} ORG_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }} - - name: Gradle Publish Android Package to Maven Central repository + - if: ${{ github.event.inputs.maven_publish == 'true' }} + name: Gradle Publish Android Package to Maven Central repository run: ./gradlew publishAndroidReleasePublicationToMavenCentralRepository -PremotePublication=true -Pandroid=true ${{ env.PUB_MODE }} env: ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }} diff --git a/.github/workflows/publish-jvm.yml b/.github/workflows/publish-jvm.yml index 974a027fc..1d1126982 100644 --- a/.github/workflows/publish-jvm.yml +++ b/.github/workflows/publish-jvm.yml @@ -12,7 +12,22 @@ on: description: Target branch type: string required: false + github_publish: + type: boolean + required: false + default: true + maven_publish: + type: boolean + required: false + default: true workflow_dispatch: + inputs: + github_publish: + description: 'Publish to github packages' + default: "true" + maven_publish: + description: 'Publish to Maven Central' + default: "true" env: CARGO_TERM_COLOR: always @@ -175,7 +190,8 @@ jobs: echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV fi - - name: Gradle Publish JVM Package to GitHub packages repository + - if: ${{ github.event.inputs.github_publish == 'true' }} + name: Gradle Publish JVM Package to GitHub packages repository run: ./gradlew publishJvmPublicationToGithubPackagesRepository -PremotePublication=true ${{ env.PUB_MODE }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -184,8 +200,8 @@ jobs: ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }} ORG_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }} - - - name: Gradle Publish JVM Package to Maven Central repository + - if: ${{ github.event.inputs.maven_publish == 'true' }} + name: Gradle Publish JVM Package to Maven Central repository run: ./gradlew publishJvmPublicationToMavenCentralRepository -PremotePublication=true ${{ env.PUB_MODE }} env: ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }} From fc3d08686f218c556f9009d94de3d3b4166e6e3e Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Thu, 26 Dec 2024 11:20:45 -0300 Subject: [PATCH 3/3] publishing: editing workflows - adding nexus tasks --- .github/workflows/publish-android.yml | 4 +++- .github/workflows/publish-jvm.yml | 4 +++- build.gradle.kts | 5 ++++- zenoh-kotlin/build.gradle.kts | 12 ------------ 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml index ed8644b3e..3581315bc 100644 --- a/.github/workflows/publish-android.yml +++ b/.github/workflows/publish-android.yml @@ -97,7 +97,9 @@ jobs: - if: ${{ github.event.inputs.maven_publish == 'true' }} name: Gradle Publish Android Package to Maven Central repository - run: ./gradlew publishAndroidReleasePublicationToMavenCentralRepository -PremotePublication=true -Pandroid=true ${{ env.PUB_MODE }} + run: | + ./gradlew publishAndroidReleasePublicationToSonatypeRepository -PremotePublication=true -Pandroid=true ${{ env.PUB_MODE }} + ./gradlew closeAndReleaseSonatypeStagingRepository env: ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }} ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }} diff --git a/.github/workflows/publish-jvm.yml b/.github/workflows/publish-jvm.yml index 1d1126982..ba12de12b 100644 --- a/.github/workflows/publish-jvm.yml +++ b/.github/workflows/publish-jvm.yml @@ -202,7 +202,9 @@ jobs: - if: ${{ github.event.inputs.maven_publish == 'true' }} name: Gradle Publish JVM Package to Maven Central repository - run: ./gradlew publishJvmPublicationToMavenCentralRepository -PremotePublication=true ${{ env.PUB_MODE }} + run: | + ./gradlew publishJvmPublicationToSonatypeRepository -PremotePublication=true ${{ env.PUB_MODE }} + ./gradlew closeAndReleaseSonatypeStagingRepository env: ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }} ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }} diff --git a/build.gradle.kts b/build.gradle.kts index 0fe28374c..9e0d29440 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -39,7 +39,10 @@ plugins { nexusPublishing { repositories { - sonatype() + sonatype { + username = System.getenv("ORG_OSSRH_USERNAME") + password = System.getenv("ORG_OSSRH_PASSWORD") + } } } diff --git a/zenoh-kotlin/build.gradle.kts b/zenoh-kotlin/build.gradle.kts index b781d4e87..17bdedb0c 100644 --- a/zenoh-kotlin/build.gradle.kts +++ b/zenoh-kotlin/build.gradle.kts @@ -157,18 +157,6 @@ kotlin { password = System.getenv("GITHUB_TOKEN") } } - maven { - name = "MavenCentral" - url = uri(if (project.hasProperty("SNAPSHOT")) - "https://oss.sonatype.org/content/repositories/snapshots/" - else - "https://oss.sonatype.org/service/local/staging/deploy/maven2/" - ) - credentials { - username = System.getenv("ORG_OSSRH_USERNAME") - password = System.getenv("ORG_OSSRH_PASSWORD") - } - } } } }