|
| 1 | +name: Build examples against latest LiveKit SDK (via CMake) |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +env: |
| 11 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + strategy: |
| 16 | + fail-fast: false |
| 17 | + matrix: |
| 18 | + include: |
| 19 | + - os: ubuntu-latest |
| 20 | + name: linux-x64 |
| 21 | + - os: macos-latest |
| 22 | + name: macos-arm64 |
| 23 | + - os: windows-latest |
| 24 | + name: windows-x64 |
| 25 | + |
| 26 | + name: Build (${{ matrix.name }}) |
| 27 | + runs-on: ${{ matrix.os }} |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: actions/checkout@v4 |
| 32 | + |
| 33 | + # ---------- deps ---------- |
| 34 | + - name: Install deps (Ubuntu) |
| 35 | + if: runner.os == 'Linux' |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + set -eux |
| 39 | + sudo apt-get update |
| 40 | + sudo apt-get install -y \ |
| 41 | + cmake ninja-build pkg-config \ |
| 42 | + protobuf-compiler libprotobuf-dev \ |
| 43 | + libssl-dev \ |
| 44 | + curl |
| 45 | +
|
| 46 | + - name: Install deps (macOS) |
| 47 | + if: runner.os == 'macOS' |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + set -eux |
| 51 | + brew update |
| 52 | + brew install cmake ninja protobuf |
| 53 | +
|
| 54 | + - name: Install deps (Windows) |
| 55 | + if: runner.os == 'Windows' |
| 56 | + shell: pwsh |
| 57 | + run: | |
| 58 | + choco install -y cmake --installargs 'ADD_CMAKE_TO_PATH=System' |
| 59 | + choco install -y ninja |
| 60 | +
|
| 61 | + - name: Setup MSVC (Windows) |
| 62 | + if: runner.os == 'Windows' |
| 63 | + uses: ilammy/msvc-dev-cmd@v1 |
| 64 | + with: |
| 65 | + arch: x64 |
| 66 | + |
| 67 | + # ---------- configure + build ---------- |
| 68 | + - name: Configure (Unix) |
| 69 | + if: runner.os != 'Windows' |
| 70 | + shell: bash |
| 71 | + env: |
| 72 | + GITHUB_TOKEN: ${{ github.token }} |
| 73 | + run: | |
| 74 | + set -eux |
| 75 | + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release |
| 76 | +
|
| 77 | + - name: Build (Unix) |
| 78 | + if: runner.os != 'Windows' |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + set -eux |
| 82 | + cmake --build build --config Release |
| 83 | +
|
| 84 | + - name: Configure (Windows) |
| 85 | + if: runner.os == 'Windows' |
| 86 | + shell: pwsh |
| 87 | + run: | |
| 88 | + cmake -S . -B build -G Ninja ` |
| 89 | + -DCMAKE_BUILD_TYPE=Release ` |
| 90 | + -DCMAKE_C_COMPILER=cl ` |
| 91 | + -DCMAKE_CXX_COMPILER=cl |
| 92 | +
|
| 93 | + - name: Build (Windows) |
| 94 | + if: runner.os == 'Windows' |
| 95 | + shell: pwsh |
| 96 | + run: | |
| 97 | + cmake --build build --config Release |
| 98 | +
|
| 99 | + # ---------- smoke test ---------- |
| 100 | + - name: Smoke test (Linux/macOS) |
| 101 | + if: runner.os != 'Windows' |
| 102 | + shell: bash |
| 103 | + run: | |
| 104 | + set -euo pipefail |
| 105 | +
|
| 106 | + sdk_root="$(ls -d build/_deps/livekit-sdk/* | head -n 1)" |
| 107 | + echo "SDK root: ${sdk_root}" |
| 108 | + ls -la "${sdk_root}/lib" || true |
| 109 | + # Locate executable (it may not be directly under build/) |
| 110 | + exe="$(find build -type f -name basic_room -perm -111 | head -n 1)" |
| 111 | + if [[ -z "${exe}" ]]; then |
| 112 | + echo "basic_room executable not found under build/" |
| 113 | + find build -maxdepth 3 -type f -print |
| 114 | + exit 1 |
| 115 | + fi |
| 116 | + echo "Running: ${exe} --self-test" |
| 117 | + if [[ "$RUNNER_OS" == "Linux" ]]; then |
| 118 | + export LD_LIBRARY_PATH="${sdk_root}/lib:${LD_LIBRARY_PATH:-}" |
| 119 | + else |
| 120 | + export DYLD_LIBRARY_PATH="${sdk_root}/lib:${DYLD_LIBRARY_PATH:-}" |
| 121 | + fi |
| 122 | + "${exe}" --self-test |
| 123 | +
|
| 124 | +
|
| 125 | + - name: Smoke test (Windows) |
| 126 | + if: runner.os == 'Windows' |
| 127 | + shell: pwsh |
| 128 | + run: | |
| 129 | + # Locate SDK root |
| 130 | + $sdkRoot = Get-ChildItem -Directory "build/_deps/livekit-sdk" | Select-Object -First 1 |
| 131 | + if (-not $sdkRoot) { |
| 132 | + throw "SDK root not found under build/_deps/livekit-sdk" |
| 133 | + } |
| 134 | + Write-Host "SDK root: $($sdkRoot.FullName)" |
| 135 | + # Make sure DLLs are found at runtime |
| 136 | + $env:PATH = "$($sdkRoot.FullName)\bin;$($sdkRoot.FullName)\lib;$env:PATH" |
| 137 | + # Locate the built executable |
| 138 | + $exe = Get-ChildItem -Recurse build -Filter basic_room.exe | Select-Object -First 1 |
| 139 | + if (-not $exe) { |
| 140 | + throw "basic_room.exe not found in build directory" |
| 141 | + } |
| 142 | + Write-Host "Running $($exe.FullName) --help" |
| 143 | + # Try to execute it. We only care that it launches. |
| 144 | + $out = & $exe.FullName --self-test 2>&1 |
| 145 | + $code = $LASTEXITCODE |
| 146 | + if ($code -ne 0) { |
| 147 | + Write-Host $out |
| 148 | + throw "basic_room.exe --self-test failed with exit code $code" |
| 149 | + } |
| 150 | + Write-Host $out |
| 151 | +
|
| 152 | + # ---------- upload build output ---------- |
| 153 | + - name: Upload binary |
| 154 | + uses: actions/upload-artifact@v4 |
| 155 | + with: |
| 156 | + name: basic_room-${{ matrix.name }} |
| 157 | + path: | |
| 158 | + build/basic_room* |
| 159 | + build/basic_room.exe |
| 160 | + retention-days: 7 |
0 commit comments