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: automatically release drafts for ffi & add license #199

Merged
merged 13 commits into from
Sep 25, 2023
59 changes: 48 additions & 11 deletions .github/workflows/ffi-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ name: FFI
on:
push:
branches: ["main"]
tags:
- "ffi-v*"
workflow_dispatch:

env:
Expand Down Expand Up @@ -68,12 +70,12 @@ jobs:
dylib: liblivekit_ffi.so
target: x86_64-unknown-linux-gnu
name: ffi-linux-x86_64
- os: buildjet-4vcpu-ubuntu-2204-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: buildjet-4vcpu-ubuntu-2204-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
Expand Down Expand Up @@ -130,6 +132,8 @@ jobs:
curl --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y; \
cd livekit-ffi && cargo build --release --target ${{ matrix.target }} ${{ matrix.buildargs }}"

sudo chown -R $USER:$USER target/${{ matrix.target }}/release/

# on android use cargo ndk
- name: Build (Android)
if: ${{ matrix.platform == 'android' }}
Expand All @@ -138,24 +142,57 @@ jobs:
cargo install cargo-ndk
cargo ndk --target ${{ matrix.target }} build --release ${{ 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 }}/release/LICENSE.md
shell: bash

# zip the files
- name: Zip artifact (Unix)
if: ${{ matrix.os != 'windows-latest' }}
# using sudo because the above container (manylinux) runs as root
run: |
sudo cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/
cp livekit-ffi/include/livekit_ffi.h target/${{ matrix.target }}/release/
cd target/${{ matrix.target }}/release/
zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} livekit_ffi.h
zip ${{ github.workspace }}/${{ matrix.name }}.zip ${{ matrix.dylib }} 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 }}/release/
cd target/${{ matrix.target }}/release/
Get-ChildItem -Path ${{ matrix.dylib }}, livekit_ffi.h | Compress-Archive -DestinationPath ${{ github.workspace }}\${{ matrix.name }}.zip
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@v3
with:
name: ${{ matrix.name }}.zip
name: ffi-builds
path: ${{ matrix.name }}.zip


release:
name: Release to GH (Draft)
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
if: startsWith(github.ref, 'refs/tags/ffi-v')
env:
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3
with:
name: ffi-builds
path: ${{ github.workspace }}/ffi-builds

- name: Create draft release
run: |
gh release create ${{ github.ref_name }} --draft --title "${{ github.ref_name }}"
gh release upload ${{ github.ref_name }} ${{ github.workspace }}/ffi-builds/*
8 changes: 6 additions & 2 deletions .github/workflows/webrtc-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
# limitations under the License.

name: WebRTC builds
on: workflow_dispatch
on:
push:
tags:
- "webrtc-*"
workflow_dispatch:

jobs:
build:
Expand Down Expand Up @@ -148,5 +152,5 @@ jobs:
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ steps.setup.outputs.ZIP }}
name: webrtc-builds
path: ${{ steps.setup.outputs.ZIP }}
1 change: 1 addition & 0 deletions livekit-ffi/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WEBRTC_LICENSE.md
14 changes: 14 additions & 0 deletions livekit-ffi/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@
// limitations under the License.

use std::env;
use std::path::Path;

fn main() {
if env::var("DOCS_RS").is_ok() {
return;
}

webrtc_sys_build::download_webrtc().unwrap();
if env::var("CARGO_CFG_TARGET_OS").unwrap() == "android" {
webrtc_sys_build::configure_jni_symbols().unwrap();
}

{
// Copy the webrtc license to CARGO_MANIFEST_DIR
// (used by the ffi release action)
let webrtc_dir = webrtc_sys_build::webrtc_dir();
let license = webrtc_dir.join("LICENSE.md");
let target_dir = env::var("CARGO_MANIFEST_DIR").unwrap();

let out_file = Path::new(&target_dir).join("WEBRTC_LICENSE.md");

std::fs::copy(license, out_file).unwrap();
}
}
Loading