Release: set CMAKE_POLICY_VERSION_MINIMUM=3.5 for opus on CMake 4.x #15
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: ['v*'] | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| build: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| # Linux x86_64 server + client (gnu — musl can't compile OpenH264 C++) | |
| # Use ubuntu-22.04 for glibc 2.35 compatibility (ubuntu-latest = 24.04 = glibc 2.39) | |
| - target: x86_64-unknown-linux-gnu | |
| os: ubuntu-22.04 | |
| suffix: linux-x86_64 | |
| build_server: true | |
| build_client: true | |
| # Windows x86_64 server + client | |
| - target: x86_64-pc-windows-msvc | |
| os: windows-latest | |
| suffix: windows-x86_64 | |
| build_server: true | |
| build_client: true | |
| # Linux aarch64 (cross-compiled — for AWS Graviton, Ampere, etc.) | |
| - target: aarch64-unknown-linux-gnu | |
| os: ubuntu-22.04 | |
| suffix: linux-aarch64 | |
| build_server: true | |
| build_client: true | |
| cross: true | |
| # macOS ARM (client only — server needs X11/DXGI for capture) | |
| - target: aarch64-apple-darwin | |
| os: macos-latest | |
| suffix: macos-aarch64 | |
| build_server: false | |
| build_client: true | |
| # macOS x86_64 | |
| - target: x86_64-apple-darwin | |
| os: macos-latest | |
| suffix: macos-x86_64 | |
| build_server: false | |
| build_client: true | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - uses: Swatinem/rust-cache@v2 | |
| # Linux x86_64: install X11 dev libs + nasm (OpenH264) + cmake (opus static build) | |
| - name: Install Linux dependencies (x86_64) | |
| if: contains(matrix.target, 'linux') && !matrix.cross | |
| run: | | |
| sudo apt-get update && sudo apt-get install -y \ | |
| libxcb1-dev libxcb-shm0-dev libxcb-randr0-dev libxdo-dev \ | |
| nasm cmake \ | |
| libpulse-dev libasound2-dev | |
| # macOS: nasm (OpenH264 SIMD asm) + cmake (opus static build) | |
| # macos-latest runners have cmake pre-installed but NOT nasm. | |
| - name: Install macOS dependencies | |
| if: contains(matrix.target, 'apple-darwin') | |
| run: brew install nasm cmake | |
| # Opus's bundled CMakeLists.txt calls cmake_minimum_required below 3.5, | |
| # which CMake 4.x (installed on macos-latest) rejects. Env var tells | |
| # CMake to accept the old policies. Applies globally to all cmake-crate | |
| # invocations. No harm on Linux/Windows runners. | |
| - name: Set CMake policy fallback | |
| run: echo "CMAKE_POLICY_VERSION_MINIMUM=3.5" >> $GITHUB_ENV | |
| shell: bash | |
| # Linux aarch64: cross-compilation toolchain | |
| - name: Install Linux cross-compile dependencies (aarch64) | |
| if: matrix.cross | |
| run: | | |
| sudo dpkg --add-architecture arm64 | |
| sudo sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list | |
| echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list | |
| echo "deb [arch=arm64] http://ports.ubuntu.com/ jammy-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \ | |
| libxcb1-dev:arm64 libxcb-shm0-dev:arm64 libxcb-randr0-dev:arm64 libxdo-dev:arm64 nasm cmake \ | |
| libpulse-dev:arm64 libasound2-dev:arm64 | |
| - name: Set cross-compile env | |
| if: matrix.cross | |
| run: | | |
| echo "PKG_CONFIG_SYSROOT_DIR=/usr/aarch64-linux-gnu" >> $GITHUB_ENV | |
| echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV | |
| echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV | |
| echo "CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++" >> $GITHUB_ENV | |
| # Build WASM for server (Linux native only — Windows/macOS/cross use committed WASM files) | |
| - name: Build WASM | |
| if: matrix.build_server && !contains(matrix.target, 'windows') && !matrix.cross | |
| run: | | |
| cargo install wasm-pack | |
| wasm-pack build crates/web --target web --no-typescript | |
| # Build server (Linux native: with embedded web client from fresh WASM build) | |
| - name: Build server (Linux, with web client) | |
| if: matrix.build_server && !contains(matrix.target, 'windows') && !matrix.cross | |
| run: cargo build --release --target ${{ matrix.target }} -p phantom-server | |
| # Build server (Windows: uses committed WASM files for web-client) | |
| - name: Build server (Windows, with web client) | |
| if: matrix.build_server && contains(matrix.target, 'windows') | |
| run: cargo build --release --target ${{ matrix.target }} -p phantom-server --features audio | |
| # Build server (cross-compile: without web client, with audio) | |
| - name: Build server (cross-compile, no web client) | |
| if: matrix.build_server && matrix.cross | |
| run: cargo build --release --target ${{ matrix.target }} -p phantom-server --no-default-features --features audio | |
| # Build client (all platforms: without av1/dav1d for portability) | |
| - name: Build client | |
| if: matrix.build_client | |
| run: cargo build --release --target ${{ matrix.target }} -p phantom-client --no-default-features --features audio | |
| # Package — Unix | |
| - name: Package binaries (Unix) | |
| if: "!contains(matrix.target, 'windows')" | |
| run: | | |
| mkdir -p dist | |
| if [ "${{ matrix.build_server }}" = "true" ]; then | |
| cp target/${{ matrix.target }}/release/phantom-server dist/phantom-server-${{ matrix.suffix }} | |
| fi | |
| if [ "${{ matrix.build_client }}" = "true" ]; then | |
| cp target/${{ matrix.target }}/release/phantom-client dist/phantom-client-${{ matrix.suffix }} | |
| fi | |
| # Package — Windows | |
| - name: Package binaries (Windows) | |
| if: contains(matrix.target, 'windows') | |
| shell: pwsh | |
| run: | | |
| New-Item -ItemType Directory -Force -Path dist | |
| if ("${{ matrix.build_server }}" -eq "true") { | |
| Copy-Item "target/${{ matrix.target }}/release/phantom-server.exe" "dist/phantom-server-${{ matrix.suffix }}.exe" | |
| } | |
| if ("${{ matrix.build_client }}" -eq "true") { | |
| Copy-Item "target/${{ matrix.target }}/release/phantom-client.exe" "dist/phantom-client-${{ matrix.suffix }}.exe" | |
| } | |
| - name: Upload artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: binaries-${{ matrix.suffix }} | |
| path: dist/* | |
| # Build and push Docker image to GitHub Container Registry | |
| docker: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT" | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: true | |
| tags: | | |
| ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }} | |
| ghcr.io/${{ github.repository }}:latest | |
| release: | |
| needs: [build] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| merge-multiple: true | |
| - name: List artifacts | |
| run: find dist -type f && ls -la dist/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist/* | |
| generate_release_notes: true | |
| fail_on_unmatched_files: false | |
| body: | | |
| ## Install | |
| **Linux / macOS:** | |
| ```bash | |
| curl -fsSL https://raw.githubusercontent.com/huaying/phantom/main/install.sh | sh | |
| ``` | |
| **Windows (PowerShell):** | |
| ```powershell | |
| irm https://raw.githubusercontent.com/huaying/phantom/main/install.ps1 | iex | |
| ``` | |
| **Docker:** | |
| ```bash | |
| docker run --rm -p 9900:9900 ghcr.io/huaying/phantom:latest | |
| ``` | |
| See [README](https://github.com/huaying/phantom#installation) for more options. |