fork/rust-sdks

git clone https://git.julia.blue/fork/rust-sdks

Mathew Kamkarupdate more gh runner images (#579)e41cced

livekit/livekit-ffi@0.13.0
8.8 KiB226 linesraw
1# Copyright 2023 LiveKit, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15name: FFI
16on:
17  push:
18    branches: ["main"]
19    tags:
20      - "rust-sdks/livekit-ffi@*"
21  workflow_dispatch:
22
23env:
24  CARGO_TERM_COLOR: always
25
26jobs:
27  build:
28    strategy:
29      fail-fast: false
30      matrix:
31        include:
32          - os: windows-latest
33            platform: windows
34            dylib: livekit_ffi.dll
35            target: x86_64-pc-windows-msvc
36            name: ffi-windows-x86_64
37          - os: windows-latest
38            platform: windows
39            dylib: livekit_ffi.dll
40            buildargs: --no-default-features --features "native-tls" # ring 0.16 is incompatible with win aarch64
41            target: aarch64-pc-windows-msvc
42            name: ffi-windows-arm64
43          - os: macos-latest
44            platform: macos
45            dylib: liblivekit_ffi.dylib
46            target: x86_64-apple-darwin
47            macosx_deployment_target: "10.15"
48            name: ffi-macos-x86_64
49          - os: macos-latest
50            platform: macos
51            dylib: liblivekit_ffi.dylib
52            target: aarch64-apple-darwin
53            macosx_deployment_target: "11.0" # aarch64 requires 11
54            name: ffi-macos-arm64
55          - os: macos-latest
56            platform: ios
57            dylib: liblivekit_ffi.a
58            target: aarch64-apple-ios
59            iphoneos_deployment_target: "13.0"
60            name: ffi-ios-arm64
61            buildargs: --no-default-features --features "rustls-tls-webpki-roots"
62          - os: macos-latest
63            platform: ios
64            dylib: liblivekit_ffi.a
65            target: aarch64-apple-ios-sim
66            iphoneos_deployment_target: "13.0"
67            name: ffi-ios-sim-arm64
68            buildargs: --no-default-features --features "rustls-tls-webpki-roots"
69          - os: ubuntu-latest
70            platform: linux
71            build_image: quay.io/pypa/manylinux_2_28_x86_64
72            dylib: liblivekit_ffi.so
73            target: x86_64-unknown-linux-gnu
74            name: ffi-linux-x86_64
75          - os: ubuntu-24.04-arm
76            platform: linux
77            build_image: quay.io/pypa/manylinux_2_28_aarch64
78            dylib: liblivekit_ffi.so
79            target: aarch64-unknown-linux-gnu
80            name: ffi-linux-arm64
81          - os: ubuntu-latest
82            platform: android
83            dylib: liblivekit_ffi.so
84            jar: libwebrtc.jar
85            target: aarch64-linux-android
86            ndk_arch: aarch64-unknown-linux-musl
87            name: ffi-android-arm64
88            buildargs: --no-default-features --features "rustls-tls-webpki-roots"
89          - os: ubuntu-latest
90            platform: android
91            dylib: liblivekit_ffi.so
92            jar: libwebrtc.jar
93            target: armv7-linux-androideabi
94            ndk_arch: arm-unknown-linux-musleabihf
95            name: ffi-android-armv7
96            buildargs: --no-default-features --features "rustls-tls-webpki-roots"
97          - os: ubuntu-latest
98            platform: android
99            dylib: liblivekit_ffi.so
100            jar: libwebrtc.jar
101            target: x86_64-linux-android
102            ndk_arch: x86_64-unknown-linux-musl
103            name: ffi-android-x86_64
104            buildargs: --no-default-features --features "rustls-tls-webpki-roots"
105
106    name: Build (${{ matrix.target }})
107    runs-on: ${{ matrix.os }}
108    steps:
109      - uses: actions/checkout@v3
110        with:
111          submodules: true
112
113      - uses: actions-rs/toolchain@v1
114        with:
115          toolchain: stable
116          target: ${{ matrix.target }}
117
118      - name: Set up QEMU
119        if: ${{ matrix.target == 'aarch64-unknown-linux-gnu' }}
120        uses: docker/setup-qemu-action@v3
121
122      - name: Build (macOS)
123        if: ${{ matrix.platform == 'macos' }}
124        env:
125          MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
126        run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
127
128      - name: Build (iOS)
129        if: ${{ matrix.platform == 'ios' }}
130        # TODO(theomonnom): Seems like this is causing issues with the linker (let’s ignore for now)
131        #env:
132        #  IPHONEOS_DEPLOYMENT_TARGET: ${{ matrix.iphoneos_deployment_target }}
133        # run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
134        run: cd livekit-ffi && cargo rustc --crate-type staticlib --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
135
136      - name: Build (Windows)
137        if: ${{ matrix.platform == 'windows' }}
138        run: cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}
139
140      # Use Docker on linux, so we can use manylinux images (ensure maximum mcompatibility)
141      - name: Build (Linux)
142        if: ${{ matrix.platform == 'linux' }}
143        run: |
144          docker run --rm -v $PWD:/workspace -w /workspace ${{ matrix.build_image }} bash -c "\
145            uname -a; \
146            export PATH=/root/.cargo/bin:\$PATH; \
147            yum install llvm llvm-libs -y; \
148            yum install clang -y; \
149            yum groupinstall 'Development Tools' -y; \
150            clang --version; \
151            yum install openssl-devel libX11-devel mesa-libGL-devel libXext-devel -y; \
152            curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
153            cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}"
154
155          sudo chown -R $USER:$USER target/${{ matrix.target }}/release/
156
157      # on android use cargo ndk
158      - name: Build (Android)
159        if: ${{ matrix.platform == 'android' }}
160        run: |
161          cd livekit-ffi/
162          ln -sf $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/${{ matrix.ndk_arch }}/{libunwind.so,libc++abi.a} $ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/lib/
163          cargo install cargo-ndk
164          cargo ndk --bindgen --target ${{ matrix.target }} build --release ${{ matrix.buildargs }}
165
166      - name: Copy/Build licenses
167        run: |
168          echo "# livekit" > TEMP_LICENSE.md
169          echo "```" >> TEMP_LICENSE.md
170          cat LICENSE >> TEMP_LICENSE.md
171          echo "```" >> TEMP_LICENSE.md
172          cat livekit-ffi/WEBRTC_LICENSE.md >> TEMP_LICENSE.md
173          mv TEMP_LICENSE.md target/${{ matrix.target }}/release/LICENSE.md
174        shell: bash
175
176      # zip the files
177      - name: Zip artifact (Unix)
178        if: ${{ matrix.os != 'windows-latest' && matrix.platform != 'android'}}
179        run: |
180          cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/ 
181          cd target/${{ matrix.target }}/release/
182          zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} livekit_ffi.h LICENSE.md
183
184      - name: Zip artifact (Unix for Android)
185        if: ${{ matrix.os != 'windows-latest' && matrix.platform == 'android'}}
186        run: |
187          cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/ 
188          cd target/${{ matrix.target }}/release/
189          zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} ${{ matrix.jar }} livekit_ffi.h LICENSE.md
190
191      - name: Zip artifact (Windows)
192        if: ${{ matrix.os == 'windows-latest' }}
193        run: |
194          cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/
195          cd target/${{ matrix.target }}/release/
196          Get-ChildItem -Path ${{ matrix.dylib }}, livekit_ffi.h, LICENSE.md | Compress-Archive -DestinationPath ${{ github.workspace }}\${{ matrix.name }}.zip
197
198      - name: Upload artifacts
199        uses: actions/upload-artifact@v4
200        with:
201          name: ffi-builds-${{ matrix.target }}
202          path: ${{ matrix.name }}.zip
203
204  release:
205    name: Release to GH (Draft)
206    runs-on: ubuntu-latest
207    needs: build
208    permissions:
209      contents: write
210    if: startsWith(github.ref, 'refs/tags/rust-sdks/livekit-ffi')
211    env:
212      GH_TOKEN: ${{ github.token }}
213    steps:
214      - uses: actions/checkout@v3
215
216      - name: Download artifacts
217        uses: actions/download-artifact@v4
218        with:
219          pattern: ffi-builds-*
220          merge-multiple: true
221          path: ${{ github.workspace }}/ffi-builds
222
223      - name: Create draft release
224        run: |
225          gh release create ${{ github.ref_name }} --draft --title "${{ github.ref_name }}"
226          gh release upload ${{ github.ref_name }} ${{ github.workspace }}/ffi-builds/*