-
Notifications
You must be signed in to change notification settings - Fork 0
266 lines (244 loc) · 8.44 KB
/
Copy pathrelease.yml
File metadata and controls
266 lines (244 loc) · 8.44 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
name: build
on:
release:
types:
- created
workflow_dispatch:
env:
# Force HTTP/1.1 for cargo downloads — runners intermittently hit
# "[16] Error in the HTTP2 framing layer" while fetching crates, which fails the build.
CARGO_HTTP_MULTIPLEXING: "false"
jobs:
build-linux-x86-64:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./rust
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install camera build deps
# nokhwa's v4l2-sys-mit runs bindgen against linux/videodev2.h, so clang (libclang) and the
# V4L2 headers must be present.
run: sudo apt-get update && sudo apt-get install -y clang libv4l-dev
- name: Cargo build
run: |
cargo build --release --lib
- uses: actions/upload-artifact@v4
with:
name: javah264-linux-x86-64
path: ./rust/target/release/libjavah264.so
build-linux-x86:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./rust
env:
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-gcc
CC: i686-linux-gnu-gcc
CXX: i686-linux-gnu-g++
# nokhwa's v4l2-sys-mit runs bindgen; point it at the i686 target so the generated V4L2 struct
# layouts match the cross target rather than the x86_64 host.
BINDGEN_EXTRA_CLANG_ARGS: "--target=i686-linux-gnu"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: i686-unknown-linux-gnu
- name: Install i686 cross-compilers
run: |
sudo apt-get update
sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu clang libv4l-dev
- name: Set i686 Cross-Compilation Env
env:
CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-gcc
CC: i686-linux-gnu-gcc
CXX: i686-linux-gnu-g++
run: echo "Environment variables for i686 set."
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --release --target i686-unknown-linux-gnu
- uses: actions/upload-artifact@v4
with:
name: javah264-linux-x86
path: ./rust/target/i686-unknown-linux-gnu/release/libjavah264.so
build-linux-aarch64:
runs-on: ubuntu-22.04
defaults:
run:
working-directory: ./rust
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CC: aarch64-linux-gnu-gcc
CXX: aarch64-linux-gnu-g++
# nokhwa's v4l2-sys-mit runs bindgen; point it at the aarch64 target so the generated V4L2 struct
# layouts match the cross target rather than the x86_64 host.
BINDGEN_EXTRA_CLANG_ARGS: "--target=aarch64-linux-gnu"
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install aarch64 cross-compilers
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu clang libv4l-dev
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
target: aarch64-unknown-linux-gnu
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Build
run: cargo build --release --target aarch64-unknown-linux-gnu
- uses: actions/upload-artifact@v4
with:
name: javah264-linux-aarch64
path: ./rust/target/aarch64-unknown-linux-gnu/release/libjavah264.so
build-macos-x86-64:
# macos-14 is arm64, so the x86_64 dylib must be cross-compiled (a plain `cargo build` here would
# produce an arm64 binary mislabelled as x86_64). nasm assembles openh264's x86 SIMD.
runs-on: macos-14
defaults:
run:
working-directory: ./rust
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install nasm
run: brew install nasm
- name: Add x86_64 target
run: rustup target add x86_64-apple-darwin
- name: Cargo build
run: MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --lib --target x86_64-apple-darwin
- uses: actions/upload-artifact@v4
with:
name: javah264-macos-x86-64
path: ./rust/target/x86_64-apple-darwin/release/libjavah264.dylib
build-macos-aarch64:
# macos-14 is an Apple-Silicon (arm64) runner, so the aarch64 dylib builds natively.
runs-on: macos-14
defaults:
run:
working-directory: ./rust
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cargo build
run: MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --lib
- uses: actions/upload-artifact@v4
with:
name: javah264-macos-aarch64
path: ./rust/target/release/libjavah264.dylib
build-windows-x86-64:
runs-on: windows-2025
defaults:
run:
working-directory: ./rust
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cargo build
run: |
cargo build --release --lib
- uses: actions/upload-artifact@v4
with:
name: javah264-windows-x86-64
path: ./rust/target/release/javah264.dll
build-windows-x86:
runs-on: windows-2025
defaults:
run:
working-directory: ./rust
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Cargo build
run: |
rustup target add i686-pc-windows-msvc
cargo build --target=i686-pc-windows-msvc --release --lib
- uses: actions/upload-artifact@v4
with:
name: javah264-windows-x86
path: ./rust/target/i686-pc-windows-msvc/release/javah264.dll
build-java-library:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
needs: [build-linux-x86-64, build-linux-x86, build-linux-aarch64, build-macos-x86-64, build-macos-aarch64, build-windows-x86-64, build-windows-x86]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Java 8
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '8'
- name: Download linux-x86-64
uses: actions/download-artifact@v4
with:
name: javah264-linux-x86-64
path: ./src/main/resources/natives/linux-x64/
- name: Download linux-x86
uses: actions/download-artifact@v4
with:
name: javah264-linux-x86
path: ./src/main/resources/natives/linux-x86/
- name: Download linux-aarch64
uses: actions/download-artifact@v4
with:
name: javah264-linux-aarch64
path: ./src/main/resources/natives/linux-aarch64/
- name: Download macos-x86-64
uses: actions/download-artifact@v4
with:
name: javah264-macos-x86-64
path: ./src/main/resources/natives/mac-x64/
- name: Download macos-aarch64
uses: actions/download-artifact@v4
with:
name: javah264-macos-aarch64
path: ./src/main/resources/natives/mac-aarch64/
- name: Download windows-x86-64
uses: actions/download-artifact@v4
with:
name: javah264-windows-x86-64
path: ./src/main/resources/natives/windows-x64/
- name: Download windows-x86
uses: actions/download-artifact@v4
with:
name: javah264-windows-x86
path: ./src/main/resources/natives/windows-x86/
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
- name: Publish to GitHub Packages
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: ./gradlew publish
- name: Upload all JARs to Release Assets
uses: softprops/action-gh-release@v1
with:
files: ./build/libs/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}