name: FFmpeg Preflight and Build on: push: branches: [ main, master ] pull_request: branches: [ main, master ] jobs: preflight: runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, windows-latest, macos-latest] env: # Provide a fallback URL via repository secret `FFMPEG_URL_{OS}` or `FFMPEG_URL`. FFMPEG_URL: ${{ secrets.FFMPEG_URL }} steps: - name: Checkout uses: actions/checkout@v4 - name: Set up Node.js uses: actions/setup-node@v4 with: node-version: '18' - name: Set up Rust uses: dtolnay/gh-actions-rs@stable - name: Determine OS-specific ffmpeg URL id: ffmpeg-url shell: bash run: | echo "RUNNER_OS=${RUNNER_OS}" if [[ "${RUNNER_OS}" == "Windows" ]]; then echo "url=${{ secrets.FFMPEG_URL_WINDOWS || secrets.FFMPEG_URL }}" >> $GITHUB_OUTPUT elif [[ "${RUNNER_OS}" == "macOS" ]]; then echo "url=${{ secrets.FFMPEG_URL_MACOS || secrets.FFMPEG_URL }}" >> $GITHUB_OUTPUT else echo "url=${{ secrets.FFMPEG_URL_LINUX || secrets.FFMPEG_URL }}" >> $GITHUB_OUTPUT fi - name: Create resources dir run: mkdir -p src-tauri/resources - name: Download and install FFmpeg into resources if: steps.ffmpeg-url.outputs.url != '' shell: bash run: | set -euo pipefail URL="${{ steps.ffmpeg-url.outputs.url }}" echo "Downloading ffmpeg from: $URL" FNAME="${RUNNER_TEMP}/ffmpeg_bundle" if [[ "${RUNNER_OS}" == "Windows" ]]; then powershell -Command "(New-Object Net.WebClient).DownloadFile('$URL', '$FNAME.zip')" powershell -Command "Expand-Archive -Path '$FNAME.zip' -DestinationPath '${{ github.workspace }}\\src-tauri\\resources'" else curl -sL "$URL" -o "$FNAME" # Attempt to extract common archive formats if file "$FNAME" | grep -q 'Zip archive'; then unzip -q "$FNAME" -d src-tauri/resources elif file "$FNAME" | grep -q 'gzip compressed data'; then tar -xzf "$FNAME" -C src-tauri/resources elif file "$FNAME" | grep -q 'XZ compressed'; then tar -xJf "$FNAME" -C src-tauri/resources else # Assume raw binary mv "$FNAME" src-tauri/resources/ffmpeg chmod +x src-tauri/resources/ffmpeg fi fi - name: List resources run: ls -la src-tauri/resources || true - name: Locate ffmpeg binary (Linux/macOS) if: runner.os != 'Windows' shell: bash run: | set -euo pipefail # Try to find an ffmpeg executable anywhere under resources BINPATH=$(find src-tauri/resources -type f -iname ffmpeg -print -quit || true) if [ -z "$BINPATH" ]; then BINPATH=$(find src-tauri/resources -type f -iname 'ffmpeg*' -print -quit || true) fi if [ -n "$BINPATH" ]; then echo "Found ffmpeg at $BINPATH" cp "$BINPATH" src-tauri/resources/ffmpeg chmod +x src-tauri/resources/ffmpeg else echo "ffmpeg binary not found in resources" ls -R src-tauri/resources || true exit 1 fi - name: Locate ffmpeg binary (Windows) if: runner.os == 'Windows' shell: pwsh run: | $found = Get-ChildItem -Path src-tauri/resources -Recurse -Filter ffmpeg.exe -ErrorAction SilentlyContinue | Select-Object -First 1 if (-not $found) { $found = Get-ChildItem -Path src-tauri/resources -Recurse -Filter '*ffmpeg*' -ErrorAction SilentlyContinue | Select-Object -First 1 } if ($found) { Write-Host "Found ffmpeg at $($found.FullName)" Copy-Item $found.FullName -Destination 'src-tauri\resources\ffmpeg.exe' -Force } else { Write-Host "ffmpeg not found in src-tauri/resources" Get-ChildItem src-tauri\resources -Recurse | Format-List exit 1 } - name: Install npm deps run: npm ci - name: Copy project FFmpeg helpers run: node tools/copy-ffmpeg.js || true - name: Build Rust and run ffmpeg preflight check working-directory: src-tauri run: | set -e cargo build --release cargo run --release --bin check_ffmpeg - name: Optional frontend build run: npm run build --if-present || true