|
| 1 | +name: C++ SDK |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: ["main"] |
| 5 | + tags: |
| 6 | + - "cpp-sdks/livekit-cpp@*" |
| 7 | + workflow_dispatch: |
| 8 | + workflow_call: |
| 9 | + inputs: |
| 10 | + tag: |
| 11 | + required: false |
| 12 | + type: string |
| 13 | + |
| 14 | +env: |
| 15 | + BUILD_TYPE: Release |
| 16 | + TAG_NAME: ${{ inputs.tag || github.ref_name }} |
| 17 | + |
| 18 | +jobs: |
| 19 | + build: |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + include: |
| 24 | + - os: ubuntu-latest |
| 25 | + name: linux-x86_64 |
| 26 | + generator: Ninja |
| 27 | + - os: windows-latest |
| 28 | + name: windows-x86_64 |
| 29 | + generator: "Visual Studio 17 2022" |
| 30 | + - os: macos-latest |
| 31 | + name: macos-arm64 |
| 32 | + generator: Ninja |
| 33 | + macos_arch: "arm64" |
| 34 | + # optionally add x86_64 mac build if you need it: |
| 35 | + # - os: macos-latest |
| 36 | + # name: macos-x86_64 |
| 37 | + # generator: Ninja |
| 38 | + # macos_arch: "x86_64" |
| 39 | + |
| 40 | + name: Build (${{ matrix.name }}) |
| 41 | + runs-on: ${{ matrix.os }} |
| 42 | + |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + with: |
| 46 | + submodules: true |
| 47 | + |
| 48 | + - name: Install Rust toolchain |
| 49 | + uses: dtolnay/rust-toolchain@stable |
| 50 | + |
| 51 | + - name: Install Protoc |
| 52 | + uses: arduino/setup-protoc@v2 |
| 53 | + with: |
| 54 | + version: "25.2" |
| 55 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + - name: Install deps (Ubuntu) |
| 58 | + if: startsWith(matrix.os, 'ubuntu') |
| 59 | + run: | |
| 60 | + sudo apt-get update |
| 61 | + sudo apt-get install -y ninja-build cmake pkg-config libprotobuf-dev libssl-dev |
| 62 | +
|
| 63 | + - name: Install deps (macOS) |
| 64 | + if: startsWith(matrix.os, 'macos') |
| 65 | + run: | |
| 66 | + brew update |
| 67 | + brew install ninja cmake protobuf openssl abseil |
| 68 | +
|
| 69 | + - name: Install deps (Windows) |
| 70 | + if: startsWith(matrix.os, 'windows') |
| 71 | + shell: pwsh |
| 72 | + run: | |
| 73 | + choco install ninja cmake -y |
| 74 | +
|
| 75 | + - name: Build + bundle |
| 76 | + shell: bash |
| 77 | + run: | |
| 78 | + chmod +x ./build.sh |
| 79 | + args=(release -G "${{ matrix.generator }}" \ |
| 80 | + --version "${{ steps.ver.outputs.version }}" \ |
| 81 | + --bundle --prefix "sdk-out/livekit-sdk-${{ matrix.name }}") |
| 82 | + if [[ "${{ runner.os }}" == "macOS" && -n "${{ matrix.macos_arch }}" ]]; then |
| 83 | + args+=(--macos-arch "${{ matrix.macos_arch }}") |
| 84 | + fi |
| 85 | + ./build.sh "${args[@]}" |
| 86 | +
|
| 87 | + - name: Archive (Unix) |
| 88 | + if: ${{ !startsWith(matrix.os, 'windows') }} |
| 89 | + shell: bash |
| 90 | + run: | |
| 91 | + tar -czf "livekit-sdk-${{ matrix.name }}.tar.gz" -C sdk-out "livekit-sdk-${{ matrix.name }}" |
| 92 | +
|
| 93 | + - name: Archive (Windows) |
| 94 | + if: startsWith(matrix.os, 'windows') |
| 95 | + shell: pwsh |
| 96 | + run: | |
| 97 | + Compress-Archive -Path "sdk-out/livekit-sdk-${{ matrix.name }}/*" -DestinationPath "livekit-sdk-${{ matrix.name }}.zip" |
| 98 | +
|
| 99 | + - name: Upload build artifact |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: sdk-builds-${{ matrix.name }} |
| 103 | + path: | |
| 104 | + livekit-sdk-${{ matrix.name }}.tar.gz |
| 105 | + livekit-sdk-${{ matrix.name }}.zip |
| 106 | +
|
| 107 | + release: |
| 108 | + name: Release to GH (Draft) |
| 109 | + runs-on: ubuntu-latest |
| 110 | + needs: build |
| 111 | + permissions: |
| 112 | + contents: write |
| 113 | + if: startsWith(inputs.tag || github.ref_name, 'cpp-sdks/livekit-cpp@') |
| 114 | + env: |
| 115 | + GH_TOKEN: ${{ github.token }} |
| 116 | + steps: |
| 117 | + - uses: actions/checkout@v4 |
| 118 | + |
| 119 | + - name: Download artifacts |
| 120 | + uses: actions/download-artifact@v4 |
| 121 | + with: |
| 122 | + pattern: sdk-builds-* |
| 123 | + merge-multiple: true |
| 124 | + path: ${{ github.workspace }}/sdk-builds |
| 125 | + |
| 126 | + - name: Create draft release (idempotent) |
| 127 | + run: | |
| 128 | + gh release view "${{ env.TAG_NAME }}" >/dev/null 2>&1 || \ |
| 129 | + gh release create "${{ env.TAG_NAME }}" --draft --title "${{ env.TAG_NAME }}" --generate-notes |
| 130 | +
|
| 131 | + - name: Upload assets |
| 132 | + run: | |
| 133 | + gh release upload "${{ env.TAG_NAME }}" ${{ github.workspace }}/sdk-builds/*.zip ${{ github.workspace }}/sdk-builds/*.tar.gz |
| 134 | +
|
0 commit comments