|
| 1 | +name: Build CLI on Code Changes |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + paths: |
| 7 | + - "cli/**" |
| 8 | + - "core/**" |
| 9 | + - "wasm/**" |
| 10 | + - "Cargo.toml" |
| 11 | + - ".github/workflows/release-cli.yml" |
| 12 | + |
| 13 | +jobs: |
| 14 | + build: |
| 15 | + name: Build - ${{ matrix.platform.os_name }} (${{ matrix.build_type.name }}) |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + platform: |
| 20 | + - os_name: Linux-x86_64 |
| 21 | + os: ubuntu-24.04 |
| 22 | + target: x86_64-unknown-linux-gnu |
| 23 | + |
| 24 | + - os_name: Linux-aarch64 |
| 25 | + os: ubuntu-24.04 |
| 26 | + target: aarch64-unknown-linux-gnu |
| 27 | + |
| 28 | + - os_name: Linux-riscv64 |
| 29 | + os: ubuntu-24.04 |
| 30 | + target: riscv64gc-unknown-linux-gnu |
| 31 | + |
| 32 | + - os_name: Windows-x86_64 |
| 33 | + os: windows-latest |
| 34 | + target: x86_64-pc-windows-msvc |
| 35 | + |
| 36 | + - os_name: Windows-aarch64 |
| 37 | + os: windows-latest |
| 38 | + target: aarch64-pc-windows-msvc |
| 39 | + |
| 40 | + - os_name: macOS-x86_64 |
| 41 | + os: macos-13 |
| 42 | + target: x86_64-apple-darwin |
| 43 | + |
| 44 | + - os_name: macOS-aarch64 |
| 45 | + os: macos-15 |
| 46 | + target: aarch64-apple-darwin |
| 47 | + |
| 48 | + build_type: |
| 49 | + - name: none |
| 50 | + features: "--no-default-features" |
| 51 | + suffix: "" |
| 52 | + - name: video |
| 53 | + features: "--no-default-features --features video" |
| 54 | + suffix: "-video" |
| 55 | + - name: gpu |
| 56 | + features: "--no-default-features --features gpu" |
| 57 | + suffix: "-gpu" |
| 58 | + - name: video-gpu |
| 59 | + features: "--no-default-features --features video,gpu" |
| 60 | + suffix: "-video-gpu" |
| 61 | + exclude: |
| 62 | + - platform: |
| 63 | + target: riscv64gc-unknown-linux-gnu |
| 64 | + build_type: |
| 65 | + name: video |
| 66 | + - platform: |
| 67 | + target: riscv64gc-unknown-linux-gnu |
| 68 | + build_type: |
| 69 | + name: video-gpu |
| 70 | + |
| 71 | + runs-on: ${{ matrix.platform.os }} |
| 72 | + steps: |
| 73 | + - name: Checkout |
| 74 | + uses: actions/checkout@v4 |
| 75 | + |
| 76 | + - name: Install FFmpeg (Ubuntu) |
| 77 | + if: runner.os == 'Linux' && contains(matrix.build_type.name, 'video') |
| 78 | + run: | |
| 79 | + sudo apt-get update |
| 80 | + sudo apt-get install -y \ |
| 81 | + libavutil-dev libavcodec-dev libavformat-dev \ |
| 82 | + libavdevice-dev libswscale-dev libswresample-dev \ |
| 83 | + libpostproc-dev |
| 84 | +
|
| 85 | + - name: Install FFmpeg (macOS) |
| 86 | + if: runner.os == 'macOS' && contains(matrix.build_type.name, 'video') |
| 87 | + run: | |
| 88 | + brew update |
| 89 | + brew install ffmpeg |
| 90 | +
|
| 91 | + - name: Set up MSBuild (Windows) |
| 92 | + if: runner.os == 'Windows' && contains(matrix.build_type.name, 'video') |
| 93 | + uses: microsoft/setup-msbuild@v2 |
| 94 | + |
| 95 | + - name: Download & extract FFmpeg (Windows) |
| 96 | + if: runner.os == 'Windows' && contains(matrix.build_type.name, 'video') |
| 97 | + shell: powershell |
| 98 | + run: | |
| 99 | + $target = "${{ matrix.platform.target }}" |
| 100 | + $ffmpegUrl = "" |
| 101 | + $ffmpegArchiveName = "" |
| 102 | +
|
| 103 | + if ($target -eq "x86_64-pc-windows-msvc") { |
| 104 | + $ffmpegUrl = 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-07-20-14-02/ffmpeg-n7.1.1-56-gc2184b65d2-win64-gpl-shared-7.1.zip' |
| 105 | + $ffmpegArchiveName = 'ffmpeg-x64.zip' |
| 106 | + Write-Host "Downloading x64 FFmpeg..." |
| 107 | + } elseif ($target -eq "aarch64-pc-windows-msvc") { |
| 108 | + $ffmpegUrl = 'https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2025-07-20-14-02/ffmpeg-n7.1.1-56-gc2184b65d2-winarm64-gpl-shared-7.1.zip' |
| 109 | + $ffmpegArchiveName = 'ffmpeg-arm64.zip' |
| 110 | + Write-Host "Downloading ARM64 FFmpeg..." |
| 111 | + } else { |
| 112 | + Write-Error "Unsupported Windows target: $target" |
| 113 | + exit 1 |
| 114 | + } |
| 115 | +
|
| 116 | + $archive = Join-Path $Env:USERPROFILE $ffmpegArchiveName |
| 117 | + $dest = Join-Path $Env:USERPROFILE 'ffmpeg' |
| 118 | +
|
| 119 | + Invoke-WebRequest $ffmpegUrl -OutFile $archive -MaximumRedirection 5 |
| 120 | + & (Join-Path $env:ProgramFiles '7-Zip\7z.exe') x $archive "-o$dest" -y |
| 121 | + Remove-Item $archive |
| 122 | +
|
| 123 | + $dirs = Get-ChildItem $dest | Where-Object PSIsContainer |
| 124 | + if ($dirs.Count -eq 1) { |
| 125 | + Get-ChildItem $dirs[0].FullName | Move-Item -Destination $dest -Force |
| 126 | + Remove-Item $dirs[0].FullName -Recurse -Force |
| 127 | + } |
| 128 | +
|
| 129 | + Add-Content -Path $Env:GITHUB_ENV -Value "FFMPEG_DIR=$dest" |
| 130 | + Add-Content -Path $Env:GITHUB_ENV -Value "INCLUDE=$dest\include;$Env:INCLUDE" |
| 131 | + Add-Content -Path $Env:GITHUB_ENV -Value "LIB=$dest\lib;$Env:LIB" |
| 132 | + Add-Content -Path $Env:GITHUB_ENV -Value "PATH=$dest\bin;$Env:PATH" |
| 133 | +
|
| 134 | + - name: Configure MSVC Environment via vcvarsall (Windows) |
| 135 | + if: | |
| 136 | + runner.os == 'Windows' && |
| 137 | + contains(matrix.build_type.name, 'video') && |
| 138 | + (matrix.platform.target == 'x86_64-pc-windows-msvc' || |
| 139 | + matrix.platform.target == 'aarch64-pc-windows-msvc') |
| 140 | + shell: powershell |
| 141 | + run: | |
| 142 | + $target = "${{ matrix.platform.target }}" |
| 143 | + $vcvars_arch = "" |
| 144 | +
|
| 145 | + if ($target -eq "x86_64-pc-windows-msvc") { |
| 146 | + $vcvars_arch = "x64" |
| 147 | + Write-Host "Running vcvarsall.bat x64 for x86_64 target..." |
| 148 | + } elseif ($target -eq "aarch64-pc-windows-msvc") { |
| 149 | + $vcvars_arch = "x64_arm64" |
| 150 | + Write-Host "Running vcvarsall.bat x64_arm64 for aarch64 target..." |
| 151 | + } else { |
| 152 | + Write-Error "Unsupported Windows target for vcvarsall.bat: $target" |
| 153 | + exit 1 |
| 154 | + } |
| 155 | +
|
| 156 | + $scriptContent = @" |
| 157 | + @echo off |
| 158 | + call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" $vcvars_arch >nul |
| 159 | + set |
| 160 | + "@ |
| 161 | +
|
| 162 | + $tempScriptPath = Join-Path $env:TEMP "run_vcvars.bat" |
| 163 | + $scriptContent | Out-File $tempScriptPath -Encoding UTF8 |
| 164 | +
|
| 165 | + $vcvarsOutput = cmd.exe /c $tempScriptPath |
| 166 | +
|
| 167 | + foreach ($line in $vcvarsOutput) { |
| 168 | + if ($line -match "^(.+?)=(.*)$") { |
| 169 | + $varName = $matches[1] |
| 170 | + $varValue = $matches[2] |
| 171 | + Add-Content -Path $Env:GITHUB_ENV -Value "$varName=$varValue" |
| 172 | + } |
| 173 | + } |
| 174 | + Remove-Item $tempScriptPath |
| 175 | +
|
| 176 | + - name: Build palettum-cli |
| 177 | + uses: houseabsolute/actions-rust-cross@v1 |
| 178 | + with: |
| 179 | + command: build |
| 180 | + target: ${{ matrix.platform.target }} |
| 181 | + args: "--release -p cli ${{ matrix.build_type.features }}" |
| 182 | + strip: true |
| 183 | + |
| 184 | + - name: Upload CLI artifacts |
| 185 | + uses: actions/upload-artifact@v4 |
| 186 | + with: |
| 187 | + name: palettum-${{ matrix.platform.target }}${{ matrix.build_type.suffix }} |
| 188 | + path: | |
| 189 | + target/${{ matrix.platform.target }}/release/palettum* |
0 commit comments