-
Notifications
You must be signed in to change notification settings - Fork 15
155 lines (137 loc) · 4.37 KB
/
publish_jvm.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Publish JVM
on:
release:
types: [published]
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
}
- {
target: aarch64-unknown-linux-gnu,
arch: arm64,
os: ubuntu-20.04,
use-cross: true,
}
- { target: x86_64-apple-darwin,
arch: darwin,
os: macos-latest
}
- { target: aarch64-apple-darwin,
arch: darwin,
os: macos-latest
}
- { target: x86_64-pc-windows-msvc,
arch: win64,
os: windows-2019
}
steps:
- name: Checkout source code
uses: actions/checkout@v4
- name: Install prerequisites
shell: bash
run: |
case ${{ matrix.job.target }} in
*-linux-gnu*) cargo install cargo-deb ;;
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
- name: Install Rust toolchain
run: |
rustup show
rustup target add ${{ matrix.job.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: ${{ matrix.job.use-cross }}
command: build
args: --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@v3
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
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Create resources destination
run: mkdir ${{env.JNI_LIB_PATHS}}
- name: Download result of previous builds
uses: actions/download-artifact@v3
with:
path: ${{env.JNI_LIB_PATHS}}
- uses: actions/setup-java@v3
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
- name: Gradle Publish JVM Package
uses: gradle/gradle-build-action@v2
with:
arguments: publishJvmPublicationToGithubPackagesRepository
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}