Skip to content

Commit

Permalink
feat: rework release workflow
Browse files Browse the repository at this point in the history
- split jvm build from publication
- split github/maven into their own jobs
- make github publication depend on maven one
  • Loading branch information
diogomatsubara committed Jan 14, 2025
1 parent 64593b7 commit 092f2e4
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 118 deletions.
128 changes: 128 additions & 0 deletions .github/workflows/build-jvm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
name: Build (JVM)

on:
workflow_call:
inputs:
branch:
description: Target branch
type: string
required: false
workflow_dispatch:

env:
CARGO_TERM_COLOR: always
JNI_LIB_PATHS: jni-libs # Edit on the inner build.gradle.kts file as well.

jobs:
builds:
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.os }}
if: ${{ !(github.event.inputs.build == 'false') }}
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
# In order to load any added target at runtime, editing the Zenoh class under jvmMain is required.
- {
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cargo",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
- {
target: aarch64-pc-windows-msvc,
arch: arm64,
os: windows-2019,
build-cmd: "cargo",
}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
*-linux-gnu*) cargo +stable install cargo-deb --locked ;;
esac
case ${{ matrix.job.target }} in
aarch64-unknown-linux-gnu)
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
;;
esac
cargo +stable install cross --locked
- name: Install Rust toolchain
run: |
rustup show
rustup target add ${{ matrix.job.target }}
- name: Build
run: ${{ matrix.job.build-cmd }} build --release --bins --lib --features=${{ github.event.inputs.features}} --target=${{ matrix.job.target }} --manifest-path zenoh-jni/Cargo.toml

- name: Packaging
id: package
shell: bash
run: |
TARGET=${{ matrix.job.target }}
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/${TARGET}.zip"
case ${TARGET} in
*linux*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} libzenoh_jni.so
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*apple*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} libzenoh_jni.dylib
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*windows*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
7z -y a "${MAIN_PKG_NAME}" zenoh_jni.dll
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
esac
- name: "Upload packages"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.job.target }}
path: |
${{ steps.package.outputs.MAIN_PKG_NAME }}
2 changes: 2 additions & 0 deletions .github/workflows/publish-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ on:
inputs:
github_publish:
description: 'Publish to github packages'
type: boolean
default: true
maven_publish:
description: 'Publish to Maven Central'
type: boolean
default: true

env:
Expand Down
114 changes: 0 additions & 114 deletions .github/workflows/publish-jvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,122 +34,8 @@ env:
JNI_LIB_PATHS: jni-libs # Edit on the inner build.gradle.kts file as well.

jobs:
builds:
name: Build for ${{ matrix.job.target }} on ${{ matrix.job.os }}
if: ${{ !(github.event.inputs.build == 'false') }}
runs-on: ${{ matrix.job.os }}
strategy:
fail-fast: false
matrix:
job:
# In order to load any added target at runtime, editing the Zenoh class under jvmMain is required.
- {
target: x86_64-unknown-linux-gnu,
arch: amd64,
os: ubuntu-20.04,
build-cmd: "cargo",
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
build-cmd: "cross",
}
- {
target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest,
build-cmd: "cargo",
}
- {
target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019,
build-cmd: "cargo",
}
- {
target: aarch64-pc-windows-msvc,
arch: arm64,
os: windows-2019,
build-cmd: "cargo",
}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}

- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
*-linux-gnu*) cargo +stable install cargo-deb --locked ;;
esac
case ${{ matrix.job.target }} in
aarch64-unknown-linux-gnu)
sudo apt-get -y update
sudo apt-get -y install gcc-aarch64-linux-gnu
;;
esac
cargo +stable install cross --locked
- name: Install Rust toolchain
run: |
rustup show
rustup target add ${{ matrix.job.target }}
- name: Build
run: ${{ matrix.job.build-cmd }} build --release --bins --lib --features=${{ github.event.inputs.features}} --target=${{ matrix.job.target }} --manifest-path zenoh-jni/Cargo.toml

- name: Packaging
id: package
shell: bash
run: |
TARGET=${{ matrix.job.target }}
MAIN_PKG_NAME="${GITHUB_WORKSPACE}/${TARGET}.zip"
case ${TARGET} in
*linux*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} libzenoh_jni.so
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*apple*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
zip ${MAIN_PKG_NAME} libzenoh_jni.dylib
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
*windows*)
cd "zenoh-jni/target/${TARGET}/release/"
echo "Packaging ${MAIN_PKG_NAME}:"
7z -y a "${MAIN_PKG_NAME}" zenoh_jni.dll
cd -
echo "MAIN_PKG_NAME=${MAIN_PKG_NAME}" >> $GITHUB_OUTPUT
;;
esac
- name: "Upload packages"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.job.target }}
path: |
${{ steps.package.outputs.MAIN_PKG_NAME }}
publish_jvm_package:
name: Publish JVM package
needs: builds
permissions:
contents: read
packages: write
Expand Down
51 changes: 47 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,68 @@ jobs:
GIT_USER_NAME: eclipse-zenoh-bot
GIT_USER_EMAIL: [email protected]

publish-jvm:
name: Publish JVM package
build-jvm:
name: Build JVM package
needs: tag
uses: ./.github/workflows/build-jvm.yml
with:
branch: ${{ needs.tag.outputs.branch }}
permissions:
contents: read
packages: write
secrets: inherit

publish-jvm-maven:
name: Publish JVM package
needs: [tag, build-jvm]
uses: ./.github/workflows/publish-jvm.yml
with:
snapshot: ${{ !(inputs.live-run || false) }}
branch: ${{ needs.tag.outputs.branch }}
maven_publish: true
github_publish: false
permissions:
contents: read
packages: write
secrets: inherit

publish-jvm-github:
name: Publish JVM package
needs: [tag, build-jvm, publish-jvm-maven]
uses: ./.github/workflows/publish-jvm.yml
with:
snapshot: ${{ !(inputs.live-run || false) }}
branch: ${{ needs.tag.outputs.branch }}
maven_publish: false
github_publish: true
permissions:
contents: read
packages: write
secrets: inherit

publish-android:
publish-android-maven:
name: Publish Android package
needs: tag
uses: ./.github/workflows/publish-android.yml
with:
snapshot: ${{ !(inputs.live-run || false) }}
branch: ${{ needs.tag.outputs.branch }}
maven_publish: true
github_publish: false
permissions:
contents: read
packages: write
secrets: inherit

publish-android-github:
name: Publish Android package
needs: [tag, publish-android-maven]
uses: ./.github/workflows/publish-android.yml
with:
snapshot: ${{ !(inputs.live-run || false) }}
branch: ${{ needs.tag.outputs.branch }}
maven_publish: false
github_publish: true
permissions:
contents: read
packages: write
Expand All @@ -101,7 +144,7 @@ jobs:
branch: ${{ needs.tag.outputs.branch }}

publish-github:
needs: tag
needs: [tag, publish-android-github, publish-jvm-github]
runs-on: macos-latest
steps:
- uses: eclipse-zenoh/ci/publish-crates-github@main
Expand Down

0 comments on commit 092f2e4

Please sign in to comment.