Skip to content

Commit

Permalink
Update main release workflow (#133)
Browse files Browse the repository at this point in the history
* Using 'android' property to enable/disable Android configuration (#127)

* Enabling snapshot publications for dev/1.0.0

* refactor(gradle): using 'android' property to enable/disable Android configuration

Examples:
- `gradle build -Pandroid=true` enables build with android
- `gradle build` won't consider any android configuration
- `gradle publishAndroidReleaseToMavenLocal -Pandroid=true` publishes to maven local,
	without `-Pandroid=true` it won't work.

* refactor(gradle): updating publication workflows

* refactor(gradle): updating readme instructions

---------

Co-authored-by: zettascale-bot <[email protected]>

* fix(local publication): triggering compilation of zenoh jni when publishing jvm to maven local (#128)

* Update actions (#130)

* chore: Update setup-java to v4

* chore: update gradle action to newer version

* chore: update gradle/wrapper-validation-action@v3

---------

Co-authored-by: Darius Maitia <[email protected]>
Co-authored-by: zettascale-bot <[email protected]>
  • Loading branch information
3 people authored Jul 17, 2024
1 parent 34f03cb commit b634fb7
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 139 deletions.
11 changes: 2 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,11 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26
add-to-path: false
link-to-sdk: true

- name: Install Rust toolchain
run: |
rustup show
Expand All @@ -61,7 +54,7 @@ jobs:
run: cargo build

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3

- name: Gradle Test
run: gradle jvmTest --info
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
Expand Down Expand Up @@ -54,7 +54,7 @@ jobs:
run: cargo build

- name: Setup Gradle
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3

- name: Gradle Test
run: gradle jvmTest --info
8 changes: 4 additions & 4 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
with:
ref: ${{ inputs.branch }}

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
gradle wrapper
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v3

- name: Set pub mode env var
# Note: This step is intended to allow publishing snapshot packages.
Expand All @@ -71,8 +71,8 @@ jobs:
fi
- name: Gradle Publish Android Package
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3
with:
arguments: publishAndroidReleasePublicationToGithubPackagesRepository ${{ env.PUB_MODE }}
arguments: publishAndroidReleasePublicationToGithubPackagesRepository -Pandroid=true ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15 changes: 4 additions & 11 deletions .github/workflows/publish-jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,24 +147,17 @@ jobs:
with:
path: ${{env.JNI_LIB_PATHS}}

- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 11

- uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: r26
add-to-path: false
link-to-sdk: true

- name: Gradle Wrapper
run: |
gradle wrapper
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v3

- name: Set pub mode env var
# Note: This step is intended to allow publishing snapshot packages.
Expand All @@ -177,8 +170,8 @@ jobs:
fi
- name: Gradle Publish JVM Package
uses: gradle/gradle-build-action@v2
uses: gradle/actions/setup-gradle@v3
with:
arguments: publishJvmPublicationToGithubPackagesRepository ${{ env.PUB_MODE }}
arguments: publishJvmPublicationToGithubPackagesRepository -PgithubPublish=true ${{ env.PUB_MODE }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
96 changes: 43 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This is required by Github in order to import the package, even if it's from a p
After that add to the dependencies in the app's `build.gradle.kts`:

```kotlin
implementation("io.zenoh:zenoh-kotlin-android:0.10.1-rc")
implementation("io.zenoh:zenoh-kotlin-android:0.11.0")
```

### Platforms
Expand Down Expand Up @@ -122,7 +122,7 @@ This is required by Github in order to import the package, even if it's from a p
After that add to the dependencies in the app's `build.gradle.kts`:

```kotlin
implementation("io.zenoh:zenoh-kotlin-jvm:0.10.1-rc")
implementation("io.zenoh:zenoh-kotlin-jvm:0.11.0")
```

### Platforms
Expand All @@ -146,8 +146,40 @@ Basically:
* Rust ([Installation guide](https://doc.rust-lang.org/cargo/getting-started/installation.html))
* Kotlin ([Installation guide](https://kotlinlang.org/docs/getting-started.html#backend))
* Gradle ([Installation guide](https://gradle.org/install/))

and in case of targetting Android you'll also need:
* Android SDK ([Installation guide](https://developer.android.com/about/versions/11/setup-sdk))

## <img src="jvm.png" alt="JVM" height="50"> JVM

To publish a library for a JVM project into Maven local, run

```bash
gradle -Prelease=true publishJvmPublicationToMavenLocal
```

This will first, trigger the compilation of Zenoh-JNI in release (if you want debug, specify `-Prelease=false`), and second publish the library into maven local, containing the native library
as a resource that will be loaded during runtime.

:warning: The native library will be compiled against the default rustup target on your machine, so although it may work fine
for you on your desktop, the generated publication may not be working on another computer with a different operating system and/or a different cpu architecture.

Once we have published the package, we should be able to find it under `~/.m2/repository/io/zenoh/zenoh-kotlin-jvm/0.11.0`.

Finally, in the `build.gradle.kts` file of the project where you intend to use this library, add mavenLocal to the list of repositories and add zenoh-kotlin as a dependency:

```
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testImplementation(kotlin("test"))
implementation("io.zenoh:zenoh-kotlin-jvm:0.11.0")
}
```

## <img src="android-robot.png" alt="Android" height="50"> Android

In order to use these bindings in a native Android project, what we will do is to build them as an Android NDK Library,
Expand Down Expand Up @@ -179,19 +211,19 @@ to install them.

So, in order to publish the library onto Maven Local, run:
```bash
gradle publishAndroidReleasePublicationToMavenLocal
gradle -Pandroid=true publishAndroidReleasePublicationToMavenLocal
```

This will first trigger the compilation of the Zenoh-JNI for the previously mentioned targets, and secondly will
publish the library, containing the native binaries.

You should now be able to see the package under `~/.m2/repository/io/zenoh/zenoh-kotlin-android/0.10.1-rc`
You should now be able to see the package under `~/.m2/repository/io/zenoh/zenoh-kotlin-android/0.11.0`
with the following files:
```
zenoh-kotlin-android-0.10.1-rc-sources.jar
zenoh-kotlin-android-0.10.1-rc.aar
zenoh-kotlin-android-0.10.1-rc.module
zenoh-kotlin-android-0.10.1-rc.pom
zenoh-kotlin-android-0.11.0-sources.jar
zenoh-kotlin-android-0.11.0.aar
zenoh-kotlin-android-0.11.0.module
zenoh-kotlin-android-0.11.0.pom
```

Now the library is published on maven local, let's now see how to import it into an Android project.
Expand All @@ -208,7 +240,7 @@ repositories {

Then in your app's `build.gradle.kts` filen add the dependency:
```
implementation("io.zenoh:zenoh-kotlin-android:0.10.1-rc")
implementation("io.zenoh:zenoh-kotlin-android:0.11.0")
```

And finally, do not forget to add the required internet permissions on your manifest!
Expand All @@ -220,38 +252,6 @@ And finally, do not forget to add the required internet permissions on your mani

And that was it! You can now import the code from the `io.zenoh` package and use it at your will.

## <img src="jvm.png" alt="JVM" height="50"> JVM

To publish a library for a JVM project into Maven local, run

```bash
gradle publishJvmPublicationToMavenLocal
```

This will first, trigger the compilation of Zenoh-JNI, and second publish the library into maven local, containing the native library
as a resource that will be loaded during runtime.

:warning: The native library will be compiled against the default rustup target on your machine, so although it may work fine
for you on your desktop, the generated publication may not be working on another computer with a different operating system and/or a different cpu architecture.
This is different from Android in the fact that Android provides an in build mechanism to dynamically load native libraries depending on the CPU's architecture, while
for JVM it's not the case and that logic must be implemented. Building against multiple targets and loading them dynamically is one of our short term goals.

Once we have published the package, we should be able to find it under `~/.m2/repository/io/zenoh/zenoh-kotlin-jvm/0.10.1-rc`.

Finally, in the `build.gradle.kts` file of the project where you intend to use this library, add mavenLocal to the list of repositories and add zenoh-kotlin as a dependency:

```
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
testImplementation(kotlin("test"))
implementation("io.zenoh:zenoh-kotlin-jvm:0.10.1-rc")
}
```

## Building the documentation

Because it's a Kotlin project, we use [Dokka](https://kotlinlang.org/docs/dokka-introduction.html) to generate the documentation.
Expand All @@ -263,13 +263,7 @@ gradle zenoh-kotlin:dokkaHtml

## Running the tests

To run the tests, we must first build the native library
```bash
cd zenoh-jni
cargo build
```

and then run:
To run the tests, run:

```bash
gradle jvmTest
Expand Down Expand Up @@ -323,12 +317,8 @@ add some extra functionalities and test this library a bit further, we will only

### Potential API changes

When using this library, keep in mind changes may occur, especially since this is the first version of the library. We have, however,
aimed to make the design as stable as possible from the very beginning, so changes on the code probably won't be substantial.

### Missing features
When using this library, keep in mind the api is not fully stable. Changes are to be expected, especially for version 1.0.0.

There are some missing features we will implement soon. The most notorious is the Pull Subscriber feature.

### Performance

Expand Down
Loading

0 comments on commit b634fb7

Please sign in to comment.