From e411f95ac085bc87593b52c9016fd0f9ab842ec5 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Wed, 24 Jan 2024 10:17:04 -0300 Subject: [PATCH 1/2] build(publication): modifying workflows to publish snapshot packages --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ .github/workflows/publish_android.yml | 9 ++++++++- .github/workflows/publish_jvm.yml | 9 ++++++++- zenoh-kotlin/build.gradle.kts | 2 +- 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d73f3cdd..ea79dc48 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -79,3 +79,26 @@ jobs: steps: - name: Check whether all jobs pass run: echo '${{ toJson(needs) }}' | jq -e 'all(.result == "success")' + + # Publish snapshot packages. These jobs will only be triggered when the CI is executed on main. + publish_jvm_snapshot_package: + name: Publish JVM snapshot package + if: github.ref == 'refs/heads/main' + needs: ci + uses: ./.github/workflows/publish_jvm.yml + permissions: + contents: read + packages: write + with: + version: 0.11.0-rc-SNAPSHOT + + publish_android_snapshot_package: + name: Publish Android snapshot package + if: github.ref == 'refs/heads/main' + needs: ci + uses: ./.github/workflows/publish_android.yml + permissions: + contents: read + packages: write + with: + version: 0.11.0-rc-SNAPSHOT diff --git a/.github/workflows/publish_android.yml b/.github/workflows/publish_android.yml index 6b015864..e9241511 100644 --- a/.github/workflows/publish_android.yml +++ b/.github/workflows/publish_android.yml @@ -3,6 +3,13 @@ name: Publish Android on: release: types: [published] + workflow_call: + inputs: + version: + required: false + type: string + description: 'The publication version' + default: '0.11.0-rc' workflow_dispatch: env: @@ -52,6 +59,6 @@ jobs: - name: Gradle Publish Android Package uses: gradle/gradle-build-action@v2 with: - arguments: publishAndroidReleasePublicationToGithubPackagesRepository + arguments: publishAndroidReleasePublicationToGithubPackagesRepository -PzkVersion=${{ inputs.version }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish_jvm.yml b/.github/workflows/publish_jvm.yml index 03093a8c..aa528e6a 100644 --- a/.github/workflows/publish_jvm.yml +++ b/.github/workflows/publish_jvm.yml @@ -3,6 +3,13 @@ name: Publish JVM on: release: types: [published] + workflow_call: + inputs: + version: + required: false + type: string + description: 'The publication version' + default: '0.11.0-rc' workflow_dispatch: env: @@ -156,6 +163,6 @@ jobs: - name: Gradle Publish JVM Package uses: gradle/gradle-build-action@v2 with: - arguments: publishJvmPublicationToGithubPackagesRepository + arguments: publishJvmPublicationToGithubPackagesRepository -PzkVersion=${{ inputs.version }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/zenoh-kotlin/build.gradle.kts b/zenoh-kotlin/build.gradle.kts index 7898aa84..2d955f7c 100644 --- a/zenoh-kotlin/build.gradle.kts +++ b/zenoh-kotlin/build.gradle.kts @@ -13,7 +13,7 @@ // group = "io.zenoh" -version = "0.11.0-dev" +version = project.findProperty("zkVersion") as String? ?: "0.11.0-dev" plugins { id("com.android.library") From b364ff45d98ec4a80ed530d46748e892f864e9a5 Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Fri, 26 Jan 2024 15:35:40 -0300 Subject: [PATCH 2/2] build(publication): modifying workflows to publish snapshot packages 2 --- .github/workflows/ci.yml | 4 ++-- .github/workflows/publish_android.yml | 22 ++++++++++++++++------ .github/workflows/publish_jvm.yml | 22 ++++++++++++++++------ build.gradle.kts | 5 +++++ examples/build.gradle.kts | 3 --- zenoh-kotlin/build.gradle.kts | 7 ++++--- 6 files changed, 43 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea79dc48..b69d2444 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: contents: read packages: write with: - version: 0.11.0-rc-SNAPSHOT + snapshot: true publish_android_snapshot_package: name: Publish Android snapshot package @@ -101,4 +101,4 @@ jobs: contents: read packages: write with: - version: 0.11.0-rc-SNAPSHOT + snapshot: true diff --git a/.github/workflows/publish_android.yml b/.github/workflows/publish_android.yml index e9241511..e9d1ca4c 100644 --- a/.github/workflows/publish_android.yml +++ b/.github/workflows/publish_android.yml @@ -5,11 +5,11 @@ on: types: [published] workflow_call: inputs: - version: - required: false - type: string - description: 'The publication version' - default: '0.11.0-rc' + snapshot: + required: true + type: boolean + description: 'If the publication is for a snapshot version.' + default: false workflow_dispatch: env: @@ -56,9 +56,19 @@ jobs: - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 + - name: Set pub mode env var + # Note: This step is intended to allow publishing snapshot packages. + # It allows to optionally append the property -PSNAPSHOT to the gradle + # publication task on the next step, resulting in the package version + # following the convention '-SNAPSHOT'. + run: | + if [[ "${{ inputs.snapshot }}" == "true" ]]; then + echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV + fi + - name: Gradle Publish Android Package uses: gradle/gradle-build-action@v2 with: - arguments: publishAndroidReleasePublicationToGithubPackagesRepository -PzkVersion=${{ inputs.version }} + arguments: publishAndroidReleasePublicationToGithubPackagesRepository ${{ env.PUB_MODE }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/publish_jvm.yml b/.github/workflows/publish_jvm.yml index aa528e6a..c168c611 100644 --- a/.github/workflows/publish_jvm.yml +++ b/.github/workflows/publish_jvm.yml @@ -5,11 +5,11 @@ on: types: [published] workflow_call: inputs: - version: - required: false - type: string - description: 'The publication version' - default: '0.11.0-rc' + snapshot: + required: true + type: boolean + description: 'If the publication is for a snapshot version.' + default: false workflow_dispatch: env: @@ -160,9 +160,19 @@ jobs: - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 + - name: Set pub mode env var + # Note: This step is intended to allow publishing snapshot packages. + # It allows to optionally append the property -PSNAPSHOT to the gradle + # publication task on the next step, resulting in the package version + # following the convention '-SNAPSHOT'. + run: | + if [[ "${{ inputs.snapshot }}" == "true" ]]; then + echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV + fi + - name: Gradle Publish JVM Package uses: gradle/gradle-build-action@v2 with: - arguments: publishJvmPublicationToGithubPackagesRepository -PzkVersion=${{ inputs.version }} + arguments: publishJvmPublicationToGithubPackagesRepository ${{ env.PUB_MODE }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.gradle.kts b/build.gradle.kts index 6944df56..3720f47a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,6 +12,8 @@ // ZettaScale Zenoh Team, // +val zenohGroup = "io.zenoh" +val zenohVersion = "1.0.0" buildscript { repositories { @@ -35,6 +37,9 @@ plugins { } subprojects { + group = zenohGroup + version = zenohVersion + repositories { google() mavenCentral() diff --git a/examples/build.gradle.kts b/examples/build.gradle.kts index 3b1eadff..19878411 100644 --- a/examples/build.gradle.kts +++ b/examples/build.gradle.kts @@ -12,9 +12,6 @@ // ZettaScale Zenoh Team, // -group = "io.zenoh" -version = "0.11.0-dev" - plugins { kotlin("jvm") } diff --git a/zenoh-kotlin/build.gradle.kts b/zenoh-kotlin/build.gradle.kts index 2d955f7c..594e0b41 100644 --- a/zenoh-kotlin/build.gradle.kts +++ b/zenoh-kotlin/build.gradle.kts @@ -12,9 +12,6 @@ // ZettaScale Zenoh Team, // -group = "io.zenoh" -version = project.findProperty("zkVersion") as String? ?: "0.11.0-dev" - plugins { id("com.android.library") kotlin("multiplatform") @@ -122,6 +119,10 @@ kotlin { } publishing { + publications.withType { + version = project.version.toString() + if (project.hasProperty("SNAPSHOT")) "-SNAPSHOT" else "" + } + repositories { maven { name = "GithubPackages"