v1.1.0 — Native camera #6
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: build | |
| on: | |
| release: | |
| types: | |
| - created | |
| workflow_dispatch: | |
| env: | |
| # Force HTTP/1.1 for cargo downloads — runners intermittently hit | |
| # "[16] Error in the HTTP2 framing layer" while fetching crates, which fails the build. | |
| CARGO_HTTP_MULTIPLEXING: "false" | |
| jobs: | |
| build-linux-x86-64: | |
| runs-on: ubuntu-22.04 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install camera build deps | |
| # nokhwa's v4l2-sys-mit runs bindgen against linux/videodev2.h, so clang (libclang) and the | |
| # V4L2 headers must be present. | |
| run: sudo apt-get update && sudo apt-get install -y clang libv4l-dev | |
| - name: Cargo build | |
| run: | | |
| cargo build --release --lib | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-linux-x86-64 | |
| path: ./rust/target/release/libjavah264.so | |
| build-linux-x86: | |
| runs-on: ubuntu-22.04 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| env: | |
| CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-gcc | |
| CC: i686-linux-gnu-gcc | |
| CXX: i686-linux-gnu-g++ | |
| # nokhwa's v4l2-sys-mit runs bindgen; point it at the i686 target so the generated V4L2 struct | |
| # layouts match the cross target rather than the x86_64 host. | |
| BINDGEN_EXTRA_CLANG_ARGS: "--target=i686-linux-gnu" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| target: i686-unknown-linux-gnu | |
| - name: Install i686 cross-compilers | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-i686-linux-gnu g++-i686-linux-gnu clang libv4l-dev | |
| - name: Set i686 Cross-Compilation Env | |
| env: | |
| CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER: i686-linux-gnu-gcc | |
| CC: i686-linux-gnu-gcc | |
| CXX: i686-linux-gnu-g++ | |
| run: echo "Environment variables for i686 set." | |
| - name: Cache Cargo dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build | |
| run: cargo build --release --target i686-unknown-linux-gnu | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-linux-x86 | |
| path: ./rust/target/i686-unknown-linux-gnu/release/libjavah264.so | |
| build-linux-aarch64: | |
| runs-on: ubuntu-22.04 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| env: | |
| CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc | |
| CC: aarch64-linux-gnu-gcc | |
| CXX: aarch64-linux-gnu-g++ | |
| # nokhwa's v4l2-sys-mit runs bindgen; point it at the aarch64 target so the generated V4L2 struct | |
| # layouts match the cross target rather than the x86_64 host. | |
| BINDGEN_EXTRA_CLANG_ARGS: "--target=aarch64-linux-gnu" | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install aarch64 cross-compilers | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu clang libv4l-dev | |
| - name: Install Rust toolchain | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| target: aarch64-unknown-linux-gnu | |
| - name: Cache Cargo dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-cargo- | |
| - name: Build | |
| run: cargo build --release --target aarch64-unknown-linux-gnu | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-linux-aarch64 | |
| path: ./rust/target/aarch64-unknown-linux-gnu/release/libjavah264.so | |
| build-macos-x86-64: | |
| # macos-14 is arm64, so the x86_64 dylib must be cross-compiled (a plain `cargo build` here would | |
| # produce an arm64 binary mislabelled as x86_64). nasm assembles openh264's x86 SIMD. | |
| runs-on: macos-14 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install nasm | |
| run: brew install nasm | |
| - name: Add x86_64 target | |
| run: rustup target add x86_64-apple-darwin | |
| - name: Cargo build | |
| run: MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --lib --target x86_64-apple-darwin | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-macos-x86-64 | |
| path: ./rust/target/x86_64-apple-darwin/release/libjavah264.dylib | |
| build-macos-aarch64: | |
| # macos-14 is an Apple-Silicon (arm64) runner, so the aarch64 dylib builds natively. | |
| runs-on: macos-14 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cargo build | |
| run: MACOSX_DEPLOYMENT_TARGET=11.0 cargo build --release --lib | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-macos-aarch64 | |
| path: ./rust/target/release/libjavah264.dylib | |
| build-windows-x86-64: | |
| runs-on: windows-2025 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cargo build | |
| run: | | |
| cargo build --release --lib | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-windows-x86-64 | |
| path: ./rust/target/release/javah264.dll | |
| build-windows-x86: | |
| runs-on: windows-2025 | |
| defaults: | |
| run: | |
| working-directory: ./rust | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Cargo build | |
| run: | | |
| rustup target add i686-pc-windows-msvc | |
| cargo build --target=i686-pc-windows-msvc --release --lib | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: javah264-windows-x86 | |
| path: ./rust/target/i686-pc-windows-msvc/release/javah264.dll | |
| build-java-library: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| needs: [build-linux-x86-64, build-linux-x86, build-linux-aarch64, build-macos-x86-64, build-macos-aarch64, build-windows-x86-64, build-windows-x86] | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Java 8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '8' | |
| - name: Download linux-x86-64 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-linux-x86-64 | |
| path: ./src/main/resources/natives/linux-x64/ | |
| - name: Download linux-x86 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-linux-x86 | |
| path: ./src/main/resources/natives/linux-x86/ | |
| - name: Download linux-aarch64 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-linux-aarch64 | |
| path: ./src/main/resources/natives/linux-aarch64/ | |
| - name: Download macos-x86-64 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-macos-x86-64 | |
| path: ./src/main/resources/natives/mac-x64/ | |
| - name: Download macos-aarch64 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-macos-aarch64 | |
| path: ./src/main/resources/natives/mac-aarch64/ | |
| - name: Download windows-x86-64 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-windows-x86-64 | |
| path: ./src/main/resources/natives/windows-x64/ | |
| - name: Download windows-x86 | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: javah264-windows-x86 | |
| path: ./src/main/resources/natives/windows-x86/ | |
| - name: Grant execute permission for gradlew | |
| run: chmod +x gradlew | |
| - name: Build with Gradle | |
| run: ./gradlew clean build | |
| - name: Publish to GitHub Packages | |
| env: | |
| GITHUB_ACTOR: ${{ github.actor }} | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: ./gradlew publish | |
| - name: Upload all JARs to Release Assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: ./build/libs/* | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |