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

feat: rework release workflow #341

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
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
Loading