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

Publications alignment #164

Merged
merged 1 commit into from
Dec 20, 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
8 changes: 6 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,26 @@ jobs:
# 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'
if: contains(fromJSON('["refs/heads/main"]'), github.ref)
needs: ci
uses: ./.github/workflows/publish-jvm.yml
permissions:
contents: read
packages: write
with:
snapshot: true
branch: ${{ github.ref_name }}
secrets: inherit

publish_android_snapshot_package:
name: Publish Android snapshot package
if: github.ref == 'refs/heads/main'
if: contains(fromJSON('["refs/heads/main"]'), github.ref)
needs: ci
uses: ./.github/workflows/publish-android.yml
permissions:
contents: read
packages: write
with:
snapshot: true
branch: ${{ github.ref_name }}
secrets: inherit
20 changes: 17 additions & 3 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ env:

jobs:
publish_android_package:
name: Publish Android Package to Github Packages
name: Publish Android package
runs-on: ubuntu-latest
permissions:
contents: read
Expand Down Expand Up @@ -70,7 +70,21 @@ jobs:
echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV
fi

- name: Gradle Publish Android Package
run: ./gradlew publishAndroidReleasePublicationToGithubPackagesRepository -Pandroid=true ${{ env.PUB_MODE }}
- 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 }}
ORG_GPG_KEY_ID: ${{ secrets.ORG_GPG_KEY_ID }}
ORG_GPG_SUBKEY_ID: ${{ secrets.ORG_GPG_SUBKEY_ID }}
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 }}
env:
ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
ORG_GPG_KEY_ID: ${{ secrets.ORG_GPG_KEY_ID }}
ORG_GPG_SUBKEY_ID: ${{ secrets.ORG_GPG_SUBKEY_ID }}
ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
ORG_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
19 changes: 17 additions & 2 deletions .github/workflows/publish-jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,22 @@ jobs:
echo "PUB_MODE=-PSNAPSHOT" >> $GITHUB_ENV
fi

- name: Gradle Publish JVM Package
run: ./gradlew publishJvmPublicationToGithubPackagesRepository -PgithubPublish=true ${{ env.PUB_MODE }}
- name: Gradle Publish JVM Package to GitHub packages repository
run: ./gradlew publishJvmPublicationToGithubPackagesRepository -PremotePublication=true ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ORG_GPG_KEY_ID: ${{ secrets.ORG_GPG_KEY_ID }}
ORG_GPG_SUBKEY_ID: ${{ secrets.ORG_GPG_SUBKEY_ID }}
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 }}
env:
ORG_OSSRH_USERNAME: ${{ secrets.ORG_OSSRH_USERNAME }}
ORG_OSSRH_PASSWORD: ${{ secrets.ORG_OSSRH_PASSWORD }}
ORG_GPG_KEY_ID: ${{ secrets.ORG_GPG_KEY_ID }}
ORG_GPG_SUBKEY_ID: ${{ secrets.ORG_GPG_SUBKEY_ID }}
ORG_GPG_PRIVATE_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
ORG_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
permissions:
contents: read
packages: write
secrets: inherit

publish-android:
name: Publish Android package
Expand All @@ -89,6 +90,7 @@ jobs:
permissions:
contents: read
packages: write
secrets: inherit

publish-dokka:
name: Publish documentation
Expand Down
9 changes: 2 additions & 7 deletions examples/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,11 @@ tasks {
register(example, JavaExec::class) {
dependsOn("CompileZenohJNI")
description = "Run the $example example"
mainClass.set("io.zenoh.${example}")
mainClass.set("io.zenoh.$example")
classpath(sourceSets["main"].runtimeClasspath)
val zenohPaths = "../zenoh-jni/target/release"
val defaultJvmArgs = arrayListOf("-Djava.library.path=$zenohPaths")
val loggerLvl = project.findProperty("zenoh.logger")?.toString()
if (loggerLvl != null) {
jvmArgs(defaultJvmArgs + "-Dzenoh.logger=$loggerLvl")
} else {
jvmArgs(defaultJvmArgs)
}
jvmArgs(defaultJvmArgs)
}
}
}
Expand Down
64 changes: 61 additions & 3 deletions zenoh-java/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ plugins {
id("com.adarshr.test-logger")
id("org.jetbrains.dokka")
`maven-publish`
signing
}

val androidEnabled = project.findProperty("android")?.toString()?.toBoolean() == true
val release = project.findProperty("release")?.toString()?.toBoolean() == true
val githubPublish = project.findProperty("githubPublish")?.toString()?.toBoolean() == true

// If the publication is meant to be done on a remote repository (GitHub packages or Maven central).
// Modifying this property will affect the release workflows!
val isRemotePublication = project.findProperty("remotePublication")?.toString()?.toBoolean() == true

var buildMode = if (release) BuildMode.RELEASE else BuildMode.DEBUG

Expand Down Expand Up @@ -74,7 +78,7 @@ kotlin {
}
}
val jvmMain by getting {
if (githubPublish) {
if (isRemotePublication) {
// The line below is intended to load the native libraries that are crosscompiled on GitHub actions when publishing a JVM package.
resources.srcDir("../jni-libs").include("*/**")
} else {
Expand All @@ -89,7 +93,39 @@ kotlin {

publishing {
publications.withType<MavenPublication> {
groupId = "org.eclipse.zenoh"
artifactId = "zenoh-java"
version = project.version.toString() + if (project.hasProperty("SNAPSHOT")) "-SNAPSHOT" else ""

pom {
name.set("Zenoh Java")
description.set("The Eclipse Zenoh: Zero Overhead Pub/sub, Store/Query and Compute.")
url.set("https://zenoh.io/")

licenses {
license {
name.set("Eclipse Public License 2.0 OR Apache License 2.0")
url.set("http://www.eclipse.org/legal/epl-2.0")
}
}
developers {
developer {
id.set("ZettaScale")
name.set("ZettaScale Zenoh Team")
email.set("[email protected]")
}
developer {
id.set("DariusIMP")
name.set("Darius Maitia")
email.set("[email protected]")
}
}
scm {
connection.set("scm:git:https://github.com/eclipse-zenoh/zenoh-java.git")
developerConnection.set("scm:git:https://github.com/eclipse-zenoh/zenoh-java.git")
url.set("https://github.com/eclipse-zenoh/zenoh-java")
}
}
}

repositories {
Expand All @@ -101,10 +137,32 @@ 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")
}
}
}
}
}

signing {
isRequired = isRemotePublication
useInMemoryPgpKeys(System.getenv("ORG_GPG_SUBKEY_ID"), System.getenv("ORG_GPG_PRIVATE_KEY"), System.getenv("ORG_GPG_PASSPHRASE"))
sign(publishing.publications)
}

tasks.withType<PublishToMavenRepository>().configureEach {
dependsOn(tasks.withType<Sign>())
}

tasks.withType<Test> {
doFirst {
// The line below is added for the Android Unit tests which are equivalent to the JVM tests.
Expand All @@ -125,7 +183,7 @@ tasks.named("compileKotlinJvm") {

tasks.register("buildZenohJni") {
doLast {
if (!githubPublish) {
if (!isRemotePublication) {
// This is intended for local publications. For publications done through GitHub workflows,
// the zenoh-jni build is achieved and loaded differently from the CI
buildZenohJNI(buildMode)
Expand Down
Loading