Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(publication): modifying workflows to publish snapshot packages #27

Merged
merged 2 commits into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How much slower will the CI be because of this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Publications tend to take around 10 minutes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that almost doubles it, making it ~20mins. I don't see it as particularly problematic. But we can always do it later on a nightly basis if it turns out to be too long.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So far the cron job is set to be run at 6am, I think it's ok, if not we can change it later as you say.

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:
snapshot: true

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:
snapshot: true
19 changes: 18 additions & 1 deletion .github/workflows/publish_android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name: Publish Android
on:
release:
types: [published]
workflow_call:
inputs:
snapshot:
required: true
type: boolean
description: 'If the publication is for a snapshot version.'
default: false
workflow_dispatch:

env:
Expand Down Expand Up @@ -49,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 '<version>-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
arguments: publishAndroidReleasePublicationToGithubPackagesRepository ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 18 additions & 1 deletion .github/workflows/publish_jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ name: Publish JVM
on:
release:
types: [published]
workflow_call:
inputs:
snapshot:
required: true
type: boolean
description: 'If the publication is for a snapshot version.'
default: false
workflow_dispatch:

env:
Expand Down Expand Up @@ -153,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 '<version>-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
arguments: publishJvmPublicationToGithubPackagesRepository ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5 changes: 5 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// ZettaScale Zenoh Team, <[email protected]>
//

val zenohGroup = "io.zenoh"
val zenohVersion = "1.0.0"

buildscript {
repositories {
Expand All @@ -35,6 +37,9 @@ plugins {
}

subprojects {
group = zenohGroup
version = zenohVersion

repositories {
google()
mavenCentral()
Expand Down
3 changes: 0 additions & 3 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// ZettaScale Zenoh Team, <[email protected]>
//

group = "io.zenoh"
version = "0.11.0-dev"

plugins {
kotlin("jvm")
}
Expand Down
7 changes: 4 additions & 3 deletions zenoh-kotlin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
// ZettaScale Zenoh Team, <[email protected]>
//

group = "io.zenoh"
version = "0.11.0-dev"

plugins {
id("com.android.library")
kotlin("multiplatform")
Expand Down Expand Up @@ -122,6 +119,10 @@ kotlin {
}

publishing {
publications.withType<MavenPublication> {
version = project.version.toString() + if (project.hasProperty("SNAPSHOT")) "-SNAPSHOT" else ""
}

repositories {
maven {
name = "GithubPackages"
Expand Down
Loading