diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94e227b..06fdca3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,17 +1,25 @@ + name: build on: workflow_dispatch: inputs: mpv_ref: - description: mpv branch, tag or commit - default: master + description: "mpv branch, tag or commit" + type: string + required: false + default: "master" + push: - tags: ["v*"] + branches: + - main + tags: + - "v*" jobs: windows: runs-on: windows-latest + steps: - uses: actions/checkout@v4 @@ -29,10 +37,26 @@ jobs: - name: Clone mpv shell: pwsh + env: + MPV_REF: ${{ inputs.mpv_ref }} run: | - $ref = "${ github.event.inputs.mpv_ref }}" - if (-not $ref) { $ref = "master" } - git clone --depth 1 --branch $ref https://github.com/mpv-player/mpv.git mpv + $ref = $env:MPV_REF + if ([string]::IsNullOrWhiteSpace($ref)) { + $ref = "master" + } + + git init mpv + git -C mpv remote add origin https://github.com/mpv-player/mpv.git + git -C mpv fetch --depth 1 origin $ref + if ($LASTEXITCODE -ne 0) { + throw "Failed to fetch mpv ref: $ref" + } + + git -C mpv checkout --detach FETCH_HEAD + if ($LASTEXITCODE -ne 0) { + throw "Failed to checkout mpv ref: $ref" + } + git -C mpv log -1 --format='%h %cd %s' --date=short - name: Apply ad_joc @@ -40,41 +64,77 @@ jobs: run: | Copy-Item fork/files/audio/decode/* mpv/audio/decode/ -Force python fork/tools/apply_edits.py mpv + if ($LASTEXITCODE -ne 0) { + throw "Failed to apply ad_joc patches" + } - name: Build joc_core shell: pwsh run: | git clone --depth 1 https://github.com/TheM14/JustOneCacophony.git joc + if ($LASTEXITCODE -ne 0) { + throw "Failed to clone JustOneCacophony" + } + cmake -S joc -B joc/build -A x64 + if ($LASTEXITCODE -ne 0) { + throw "joc_core configuration failed" + } + cmake --build joc/build --config Release - $lib = Get-ChildItem joc/build -Recurse -Filter joc_core.lib | Select-Object -First 1 - if (-not $lib) { throw "joc_core.lib not found" } - "JOC_CORE_DIR=$($lib.DirectoryName)" | Out-File -Append $env:GITHUB_ENV + if ($LASTEXITCODE -ne 0) { + throw "joc_core build failed" + } + + $lib = Get-ChildItem joc/build -Recurse -Filter joc_core.lib | + Select-Object -First 1 + if (-not $lib) { + throw "joc_core.lib not found" + } + + "JOC_CORE_DIR=$($lib.DirectoryName)" | + Out-File -Append $env:GITHUB_ENV - name: Build mpv shell: pwsh run: | $bash = "C:\msys64\usr\bin\bash.exe" - $dir = (Resolve-Path mpv).Path -replace '\\','/' - $core = $env:JOC_CORE_DIR -replace '\\','/' + $dirWin = (Resolve-Path mpv).Path + $dir = (& $bash -lc "cygpath -u '$dirWin'").Trim() + $core = (& $bash -lc "cygpath -u '$env:JOC_CORE_DIR'").Trim() + $lines = @( 'set -e', 'export PATH=/mingw64/bin:/usr/bin:$PATH', 'export MSYSTEM=MINGW64', - "cd $dir", - "meson setup build --buildtype=release -Dgpl=false -Dlua=luajit -Djoc-core-dir=$core", + "cd '$dir'", + "meson setup build --buildtype=release -Dgpl=false -Dlua=luajit -Djoc-core-dir='$core'", 'ninja -C build' ) - ($lines -join [Environment]::NewLine) | & $bash -lc "cat > /tmp/b.sh && bash /tmp/b.sh" + + ($lines -join "`n") | + & $bash -lc 'cat > /tmp/build-mpv.sh && bash /tmp/build-mpv.sh' + + if ($LASTEXITCODE -ne 0) { + throw "mpv build failed" + } - name: Bundle shell: pwsh run: | $bash = "C:\msys64\usr\bin\bash.exe" - $dir = (Resolve-Path mpv).Path -replace '\\','/' - & $bash -lc "$env:GITHUB_WORKSPACE/fork/tools/bundle_dlls.sh '$dir/build'" + $dirWin = (Resolve-Path mpv).Path + $dir = (& $bash -lc "cygpath -u '$dirWin'").Trim() + $workspace = (& $bash -lc "cygpath -u '$env:GITHUB_WORKSPACE'").Trim() + + & $bash -lc "bash '$workspace/fork/tools/bundle_dlls.sh' '$dir/build'" + if ($LASTEXITCODE -ne 0) { + throw "DLL bundling failed" + } + Copy-Item (Join-Path $env:JOC_CORE_DIR "joc_core.dll") mpv/build -Force Copy-Item fork/mpv.conf.example mpv/build -Force + Compress-Archive -Path mpv/build/* -DestinationPath mpv-ad-joc.zip - uses: actions/upload-artifact@v4