Refactor Milkdrop preset loading pipeline for hitch-free transitions #24
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: Windows | |
| on: | |
| push: | |
| branches: | |
| - "*" | |
| tags: | |
| - "*" | |
| pull_request: | |
| branches: | |
| - "*" | |
| jobs: | |
| build-shared: | |
| name: "Libs: ${{ matrix.libs }}, FS Lib: ${{ matrix.fslib }}, Arch: ${{ matrix.arch }}, Build OS: ${{ matrix.runs-on }}" | |
| runs-on: ${{ matrix.runs-on }} | |
| env: | |
| USERNAME: projectM-visualizer | |
| VCPKG_EXE: ${{ github.workspace }}/vcpkg/vcpkg | |
| FEED_URL: https://nuget.pkg.github.com/projectM-visualizer/index.json | |
| VCPKG_BINARY_SOURCES: "clear;nuget,https://nuget.pkg.github.com/projectM-visualizer/index.json,readwrite" | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| libs: ['shared', 'static'] | |
| fslib: ['stl', 'boost'] | |
| arch: ['X64', 'Win32'] | |
| runs-on: ['windows-2022'] | |
| steps: | |
| - name: Checkout vcpkg | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: microsoft/vcpkg | |
| path: vcpkg | |
| submodules: recursive | |
| - name: Bootstrap vcpkg | |
| shell: pwsh | |
| run: | | |
| ${{ github.workspace }}/vcpkg/bootstrap-vcpkg.bat | |
| ${{ env.VCPKG_EXE }} fetch nuget | |
| - name: Add NuGet sources | |
| shell: pwsh | |
| run: | | |
| .$(${{ env.VCPKG_EXE }} fetch nuget) ` | |
| sources add ` | |
| -Source "${{ env.FEED_URL }}" ` | |
| -StorePasswordInClearText ` | |
| -Name GitHubPackages ` | |
| -UserName "${{ env.USERNAME }}" ` | |
| -Password "${{ secrets.VCPKG_PACKAGES_TOKEN }}" | |
| .$(${{ env.VCPKG_EXE }} fetch nuget) ` | |
| setapikey "${{ secrets.VCPKG_PACKAGES_TOKEN }}" ` | |
| -Source "${{ env.FEED_URL }}" | |
| - name: Checkout libprojectM | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: 'recursive' | |
| clean: false | |
| - name: Configure Build | |
| run: | | |
| if("${{ matrix.libs }}" -eq "shared") { | |
| $shared_libs = "ON" | |
| $applocal_deps = "ON" | |
| } else { | |
| $shared_libs = "OFF" | |
| # Static triplets link everything (incl. CRT) statically, so there are no DLLs to deploy. | |
| # Disabling applocal removes a proven file-lock race (MSB3073, exit 32) with zero benefit lost. | |
| $applocal_deps = "OFF" | |
| } | |
| if("${{ matrix.fslib }}" -eq "boost") { | |
| $use_boost = "ON" | |
| } else { | |
| $use_boost = "OFF" | |
| } | |
| if("${{ matrix.arch }}" -eq "X64") { | |
| $triplet = "x64-windows" | |
| } else { | |
| $triplet = "x86-windows" | |
| } | |
| if("${{ matrix.libs }}" -eq "shared") { | |
| $runtime = "DLL" | |
| } else { | |
| $runtime = "" | |
| $triplet = $triplet + "-static" | |
| } | |
| if("${{ matrix.runs-on }}" -eq "windows-2022") { | |
| $generator = "Visual Studio 17 2022" | |
| } else { | |
| $generator = "Visual Studio 18 2026" | |
| } | |
| cmake -G "$($generator)" ` | |
| -A "${{ matrix.arch }}" ` | |
| -S "${{ github.workspace }}" ` | |
| -B "${{ github.workspace }}/cmake-build" ` | |
| -DCMAKE_TOOLCHAIN_FILE="${Env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ` | |
| -DVCPKG_TARGET_TRIPLET="$($triplet)" ` | |
| -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/install" ` | |
| -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>$($runtime)" ` | |
| -DCMAKE_VERBOSE_MAKEFILE=YES ` | |
| -DBUILD_SHARED_LIBS="$($shared_libs)" ` | |
| -DVCPKG_APPLOCAL_DEPS="$($applocal_deps)" ` | |
| -DENABLE_BOOST_FILESYSTEM="$($use_boost)" ` | |
| -DENABLE_CXX_INTERFACE=YES ` | |
| -DBUILD_TESTING=YES ` | |
| -DCMAKE_VERBOSE_MAKEFILE=ON | |
| - name: Build Debug | |
| run: cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --parallel | |
| - name: Run Unit Tests | |
| run: ctest --test-dir "${{ github.workspace }}/cmake-build" --verbose --build-config "Debug" | |
| - name: Build Release | |
| run: cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --parallel | |
| - name: Install | |
| run: | | |
| cmake --build "${{ github.workspace }}/cmake-build" --config "Debug" --target INSTALL | |
| cmake --build "${{ github.workspace }}/cmake-build" --config "Release" --target INSTALL | |
| - name: Test C++ Interface | |
| run: | | |
| if("${{ matrix.fslib }}" -eq "boost") { | |
| $use_boost = "ON" | |
| } else { | |
| $use_boost = "OFF" | |
| } | |
| if("${{ matrix.arch }}" -eq "X64") { | |
| $triplet = "x64-windows" | |
| } else { | |
| $triplet = "x86-windows" | |
| } | |
| if("${{ matrix.libs }}" -eq "shared") { | |
| $runtime = "DLL" | |
| $applocal_deps = "ON" | |
| } else { | |
| $runtime = "" | |
| $triplet = $triplet + "-static" | |
| # Same as above: nothing to deploy for static builds, only file-lock risk. | |
| $applocal_deps = "OFF" | |
| } | |
| if("${{ matrix.runs-on }}" -eq "windows-2022") { | |
| $generator = "Visual Studio 17 2022" | |
| } else { | |
| $generator = "Visual Studio 18 2026" | |
| } | |
| cmake -G "$($generator)" ` | |
| -A "${{ matrix.arch }}" ` | |
| -S "${{ github.workspace }}/tests/cxx-interface" ` | |
| -B "${{ github.workspace }}/cmake-build-cxx-api" ` | |
| -DCMAKE_PREFIX_PATH="${{ github.workspace }}/install" ` | |
| -DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded$<$<CONFIG:Debug>:Debug>$($runtime)" ` | |
| -DCMAKE_TOOLCHAIN_FILE="${Env:VCPKG_INSTALLATION_ROOT}/scripts/buildsystems/vcpkg.cmake" ` | |
| -DVCPKG_TARGET_TRIPLET="$($triplet)" ` | |
| -DVCPKG_APPLOCAL_DEPS="$($applocal_deps)" ` | |
| -DENABLE_BOOST_FILESYSTEM="$($use_boost)" ` | |
| -DCMAKE_VERBOSE_MAKEFILE=ON | |
| cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Debug" | |
| cmake --build "${{ github.workspace }}/cmake-build-cxx-api" --config "Release" | |
| - name: Verify DLL and LIB existence and PE architecture | |
| shell: pwsh | |
| run: | | |
| if ("${{ matrix.libs }}" -eq "shared") { | |
| $dllFile = Get-ChildItem -Path "${{ github.workspace }}" -Recurse -Filter "projectM-4.dll" | Select-Object -First 1 | |
| $libFile = Get-ChildItem -Path "${{ github.workspace }}" -Recurse -Filter "projectM-4.lib" | Select-Object -First 1 | |
| if (-not $dllFile) { | |
| Write-Error "CRITICAL FAILURE: projectM-4.dll was not found after build!" | |
| exit 1 | |
| } | |
| if (-not $libFile) { | |
| Write-Error "CRITICAL FAILURE: projectM-4.lib was not found after build!" | |
| exit 1 | |
| } | |
| $dllPath = $dllFile.FullName | |
| $libPath = $libFile.FullName | |
| Write-Host "Found DLL: $dllPath" | |
| Write-Host "Found LIB: $libPath" | |
| # Inspect PE machine header | |
| $bytes = [System.IO.File]::ReadAllBytes($dllPath) | |
| $peOffset = [System.BitConverter]::ToInt32($bytes, 0x3C) | |
| $machine = [System.BitConverter]::ToUInt16($bytes, $peOffset + 4) | |
| Write-Host ("PE Machine Type: 0x{0:X4}" -f $machine) | |
| if ("${{ matrix.arch }}" -eq "X64") { | |
| if ($machine -ne 0x8664) { | |
| Write-Error ("CRITICAL FAILURE: Expected x64 (0x8664 / IMAGE_FILE_MACHINE_AMD64) but found 0x{0:X4}" -f $machine) | |
| exit 1 | |
| } | |
| Write-Host "DLL architecture successfully verified: x64 (IMAGE_FILE_MACHINE_AMD64 / 0x8664)" | |
| } else { | |
| if ($machine -ne 0x014C) { | |
| Write-Error ("CRITICAL FAILURE: Expected x86 (0x014C / IMAGE_FILE_MACHINE_I386) but found 0x{0:X4}" -f $machine) | |
| exit 1 | |
| } | |
| Write-Host "DLL architecture successfully verified: x86 (IMAGE_FILE_MACHINE_I386 / 0x014C)" | |
| } | |
| } else { | |
| Write-Host "Static build matrix entry - skipping shared DLL verification." | |
| } | |
| - name: Package Windows ZIP Artifact | |
| if: matrix.libs == 'shared' && matrix.fslib == 'stl' && matrix.runs-on == 'windows-2022' | |
| shell: pwsh | |
| run: | | |
| if ("${{ matrix.arch }}" -eq "X64") { | |
| $archName = "x64" | |
| } else { | |
| $archName = "x86" | |
| } | |
| $zipName = "projectM-windows-$archName.zip" | |
| $packageDir = "${{ github.workspace }}/package-$archName" | |
| New-Item -ItemType Directory -Force -Path $packageDir | Out-Null | |
| Copy-Item -Path "${{ github.workspace }}/install/*" -Destination $packageDir -Recurse -Force | |
| Compress-Archive -Path "$packageDir/*" -DestinationPath "${{ github.workspace }}/$zipName" -Force | |
| Write-Host "Created release package ZIP: $zipName" | |
| Get-FileHash -Algorithm SHA256 "${{ github.workspace }}/$zipName" | Format-List | |
| - name: Upload Artifact Zip | |
| if: matrix.libs == 'shared' && matrix.fslib == 'stl' && matrix.runs-on == 'windows-2022' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: projectM-windows-${{ matrix.arch == 'X64' && 'x64' || 'x86' }} | |
| path: ${{ github.workspace }}/projectM-windows-*.zip | |
| - name: Upload Full Install Artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: projectm-windows-${{ matrix.libs }}-${{ matrix.fslib }}-${{ matrix.arch }}-${{ matrix.runs-on }} | |
| path: install/* |