diff --git a/.github/workflows/publish-android.yml b/.github/workflows/publish-android.yml index d3effc7e..3581315b 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,8 +95,11 @@ 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 - run: ./gradlew publishAndroidReleasePublicationToMavenCentralRepository -PremotePublication=true -Pandroid=true ${{ env.PUB_MODE }} + - if: ${{ github.event.inputs.maven_publish == 'true' }} + name: Gradle Publish Android Package to Maven Central repository + 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 974a027f..ba12de12 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,9 +200,11 @@ 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 - run: ./gradlew publishJvmPublicationToMavenCentralRepository -PremotePublication=true ${{ env.PUB_MODE }} + - if: ${{ github.event.inputs.maven_publish == 'true' }} + name: Gradle Publish JVM Package to Maven Central repository + 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 44bd0f13..9e0d2944 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -34,6 +34,16 @@ 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 { + username = System.getenv("ORG_OSSRH_USERNAME") + password = System.getenv("ORG_OSSRH_PASSWORD") + } + } } subprojects { diff --git a/zenoh-kotlin/build.gradle.kts b/zenoh-kotlin/build.gradle.kts index b781d4e8..17bdedb0 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") - } - } } } }