-
Notifications
You must be signed in to change notification settings - Fork 208
298 lines (274 loc) · 12.1 KB
/
Copy pathffi-builds.yml
File metadata and controls
298 lines (274 loc) · 12.1 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
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
# Copyright 2023 LiveKit, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: FFI
on:
push:
branches: ["main"]
workflow_dispatch:
inputs:
tag_name:
description: "Release tag (e.g. livekit-ffi/v0.12.49). Takes precedence over draft release lookup and creates a draft release."
required: false
type: string
dry_run:
description: "Dry run: build artifacts but skip release upload/publish."
required: false
type: boolean
default: false
build_profile:
description: "Build profile"
type: choice
options:
- release
- debug
default: release
env:
CARGO_TERM_COLOR: always
jobs:
get-tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: "Resolve tag"
run: |
MANUAL_TAG="${{ inputs.tag_name }}"
if [ -n "$MANUAL_TAG" ]; then
echo "Using manually provided tag: '${MANUAL_TAG}'"
gh release create "$MANUAL_TAG" --draft --title "$MANUAL_TAG" --generate-notes
echo "tag_name=${MANUAL_TAG}" >> $GITHUB_OUTPUT
else
TAG=$(gh release list --repo ${{ github.repository }} --json 'isDraft,tagName' --jq '[.[] | select(.isDraft and (.tagName | startswith("livekit-ffi/")))] | first | .tagName // empty')
echo "Resolved FFI draft release tag: '${TAG:-}'"
echo "tag_name=${TAG:-}" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ github.token }}
id: get-tag
outputs:
tag_name: ${{ steps.get-tag.outputs.tag_name }}
build:
env:
CARGO_PROFILE_DIR: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build_profile == 'debug' && 'debug' || 'release' }}
CARGO_RUST_PROFILE: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.build_profile == 'debug' && 'dev' || 'release' }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
platform: windows
dylib: livekit_ffi.dll
target: x86_64-pc-windows-msvc
name: ffi-windows-x86_64
- os: windows-latest
platform: windows
dylib: livekit_ffi.dll
buildargs: --no-default-features --features "native-tls" # ring 0.16 is incompatible with win aarch64
target: aarch64-pc-windows-msvc
name: ffi-windows-arm64
- os: macos-latest
platform: macos
dylib: liblivekit_ffi.dylib
target: x86_64-apple-darwin
macosx_deployment_target: "10.15"
name: ffi-macos-x86_64
- os: macos-latest
platform: macos
dylib: liblivekit_ffi.dylib
target: aarch64-apple-darwin
macosx_deployment_target: "11.0" # aarch64 requires 11
name: ffi-macos-arm64
- os: macos-latest
platform: ios
dylib: liblivekit_ffi.a
target: aarch64-apple-ios
iphoneos_deployment_target: "13.0"
name: ffi-ios-arm64
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
- os: macos-latest
platform: ios
dylib: liblivekit_ffi.a
target: aarch64-apple-ios-sim
iphoneos_deployment_target: "13.0"
name: ffi-ios-sim-arm64
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
- os: ubuntu-latest
platform: linux
build_image: sameli/manylinux_2_28_x86_64_cuda_12.3
dylib: liblivekit_ffi.so
target: x86_64-unknown-linux-gnu
name: ffi-linux-x86_64
- os: ubuntu-24.04-arm
platform: linux
build_image: quay.io/pypa/manylinux_2_28_aarch64
dylib: liblivekit_ffi.so
target: aarch64-unknown-linux-gnu
name: ffi-linux-arm64
- os: ubuntu-latest
platform: android
dylib: liblivekit_ffi.so
jar: libwebrtc.jar
target: aarch64-linux-android
name: ffi-android-arm64
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
- os: ubuntu-latest
platform: android
dylib: liblivekit_ffi.so
jar: libwebrtc.jar
target: armv7-linux-androideabi
name: ffi-android-armv7
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
- os: ubuntu-latest
platform: android
dylib: liblivekit_ffi.so
jar: libwebrtc.jar
target: x86_64-linux-android
name: ffi-android-x86_64
buildargs: --no-default-features --features "rustls-tls-webpki-roots"
name: Build (${{ matrix.target }}${{ github.event_name == 'workflow_dispatch' && format(' [{0}]', github.event.inputs.build_profile) || '' }})
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
with:
submodules: true
- name: Setup Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
with:
target: ${{ matrix.target }}
cache: false
rustflags: ""
- name: Cache cargo registry
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache cargo target
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: target/
key: ${{ runner.os }}-cargo-target-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-target-${{ matrix.target }}-
- name: Install Protoc
uses: arduino/setup-protoc@a8b67ba40b37d35169e222f3bb352603327985b6 # v2.1.0
with:
version: "25.2"
repo-token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Build (macOS)
if: ${{ matrix.platform == 'macos' }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
run: |
cd livekit-ffi
cargo build --profile "$CARGO_RUST_PROFILE" --target ${{ matrix.target }} ${{ matrix.buildargs }}
- name: Build (iOS)
if: ${{ matrix.platform == 'ios' }}
# TODO(theomonnom): Seems like this is causing issues with the linker (let’s ignore for now)
#env:
# IPHONEOS_DEPLOYMENT_TARGET: ${{ matrix.iphoneos_deployment_target }}
# run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
run: |
cd livekit-ffi
cargo rustc --crate-type staticlib --profile "$CARGO_RUST_PROFILE" --target ${{ matrix.target }} ${{ matrix.buildargs }}
- name: Build (Windows)
if: ${{ matrix.platform == 'windows' }}
run: |
cd livekit-ffi
cargo build --profile $env:CARGO_RUST_PROFILE --target ${{ matrix.target }} ${{ matrix.buildargs }}
# Use Docker on linux, so we can use manylinux images (ensure maximum mcompatibility)
- name: Build (Linux)
if: ${{ matrix.platform == 'linux' }}
run: |
docker run --rm -e CARGO_RUST_PROFILE="$CARGO_RUST_PROFILE" -v $PWD:/workspace -w /workspace ${{ matrix.build_image }} bash -c "\
uname -a; \
export PATH=/root/.cargo/bin:\$PATH; \
yum install llvm llvm-libs lld -y; \
yum install clang -y; \
yum install protobuf-compiler -y; \
yum groupinstall 'Development Tools' -y; \
clang --version; \
yum install openssl-devel libX11-devel mesa-libGL-devel libXext-devel libva-devel libdrm-devel libgbm-devel libXdamage-devel libXrandr-devel libXfixes-devel libXcomposite-devel -y; \
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
cd livekit-ffi && cargo build --profile \"\$CARGO_RUST_PROFILE\" --target ${{ matrix.target }} ${{ matrix.buildargs }}"
sudo chown -R $USER:$USER "target/${{ matrix.target }}/$CARGO_PROFILE_DIR/"
# on android use cargo ndk
- name: Build (Android)
if: ${{ matrix.platform == 'android' }}
run: |
cd livekit-ffi/
cargo install cargo-ndk
cargo ndk --target ${{ matrix.target }} build --profile "$CARGO_RUST_PROFILE" ${{ matrix.buildargs }}
- name: Copy/Build licenses
run: |
echo "# livekit" > TEMP_LICENSE.md
echo "```" >> TEMP_LICENSE.md
cat LICENSE >> TEMP_LICENSE.md
echo "```" >> TEMP_LICENSE.md
cat livekit-ffi/WEBRTC_LICENSE.md >> TEMP_LICENSE.md
mv TEMP_LICENSE.md "target/${{ matrix.target }}/$CARGO_PROFILE_DIR/LICENSE.md"
shell: bash
# zip the files
- name: Zip artifact (Unix)
if: ${{ matrix.os != 'windows-latest' && matrix.platform != 'android'}}
run: |
cp livekit-ffi/include/livekit_ffi.h "target/${{ matrix.target }}/$CARGO_PROFILE_DIR/"
cd "target/${{ matrix.target }}/$CARGO_PROFILE_DIR/"
zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} livekit_ffi.h LICENSE.md
- name: Zip artifact (Unix for Android)
if: ${{ matrix.os != 'windows-latest' && matrix.platform == 'android'}}
run: |
cp livekit-ffi/include/livekit_ffi.h "target/${{ matrix.target }}/$CARGO_PROFILE_DIR/"
cd "target/${{ matrix.target }}/$CARGO_PROFILE_DIR/"
zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} ${{ matrix.jar }} livekit_ffi.h LICENSE.md
- name: Zip artifact (Windows)
if: ${{ matrix.os == 'windows-latest' }}
run: |
cp livekit-ffi/include/livekit_ffi.h "target/${{ matrix.target }}/$env:CARGO_PROFILE_DIR/"
cd "target/${{ matrix.target }}/$env:CARGO_PROFILE_DIR/"
Get-ChildItem -Path ${{ matrix.dylib }}, livekit_ffi.h, LICENSE.md | Compress-Archive -DestinationPath ${{ github.workspace }}\${{ matrix.name }}.zip
- name: Upload artifacts
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ffi-builds-${{ matrix.target }}
path: ${{ matrix.name }}.zip
release:
name: Upload artifacts and publish GH release
runs-on: ubuntu-latest
needs: [get-tag, build]
permissions:
contents: write
if: needs.get-tag.outputs.tag_name != '' && inputs.dry_run != true
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
- name: Download artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
pattern: ffi-builds-*
merge-multiple: true
path: ${{ github.workspace }}/ffi-builds
- name: Upload artifacts and publish release
run: |
gh release upload ${{ needs.get-tag.outputs.tag_name }} ${{ github.workspace }}/ffi-builds/*
gh release edit ${{ needs.get-tag.outputs.tag_name }} --draft=false