From dd801fdd9af752c99c32a2356d2ebdf1ebb7ebaa Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 12 Jul 2025 14:30:40 +0200
Subject: [PATCH] ci: use setup-yasm action
The pre-built binaries of yasm/yasm are built with an Visual Studio 2010,
requiring MSVCR100.DLL. This runtime is no longer installed by default
on current GitHub Actions images, so build yasm instead.
---
.github/actions/setup-yasm/action.yml | 60 +++++++++++++++++++++++++++
.github/fetch_yasm.ps1 | 33 ---------------
.github/workflows/main.yml | 7 +---
3 files changed, 62 insertions(+), 38 deletions(-)
create mode 100644 .github/actions/setup-yasm/action.yml
delete mode 100644 .github/fetch_yasm.ps1
diff --git a/.github/actions/setup-yasm/action.yml b/.github/actions/setup-yasm/action.yml
new file mode 100644
index 000000000..a962d3c04
--- /dev/null
+++ b/.github/actions/setup-yasm/action.yml
@@ -0,0 +1,60 @@
+# The pre-built yasm binaries are built with an older MSVCRT,
+# which is no longer installed on current Windows images.
+
+name: 'Setup yasm'
+description: 'Build yasm and add it to the PATH environment variable'
+runs:
+ using: 'composite'
+ steps:
+ - name: 'Calculate variables'
+ id: calc
+ shell: sh
+ run: |
+ echo "cache-key=yasm-${{ runner.os }}-${{ runner.arch }}" >> ${GITHUB_OUTPUT}
+ - name: 'Restore yasm'
+ id: restore-yasm
+ uses: actions/cache/restore@v4
+ with:
+ path: |
+ ${{ github.workspace }}/yasm
+ key: ${{ steps.calc.outputs.cache-key }}
+ - name: 'Verify cached yasm'
+ if: ${{ steps.restore-yasm.outputs.cache-hit }}
+ shell: pwsh
+ run: |
+ ${{ github.workspace }}\yasm\bin\yasm --help
+ - name: 'Download yasm sources'
+ if: ${{ !steps.restore-yasm.outputs.cache-hit }}
+ uses: actions/checkout@v4
+ with:
+ repository: yasm/yasm
+ path: yasm-src
+ - name: 'Configure, build and install yasm'
+ if: ${{ !steps.restore-yasm.outputs.cache-hit }}
+ shell: pwsh
+ run: |
+ cmake -S yasm-src -B yasm-build -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/yasm -DCMAKE_INSTALL_LIBDIR=bin -DCMAKE_INSTALL_BINDIR=bin -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded
+ cmake --build yasm-build --parallel
+ cmake --install yasm-build
+ - name: 'Verify built yasm'
+ if: ${{ !steps.restore-yasm.outputs.cache-hit }}
+ shell: sh
+ run: |
+ set -e
+ if [ ! -f "yasm/bin/yasm.exe" -a -f "yasm/bin/vsyasm.exe" ]; then
+ cp "yasm/bin/vsyasm.exe" "yasm/bin/yasm.exe"
+ fi
+ yasm/bin/yasm --help
+ - name: 'Cache yasm'
+ if: ${{ !steps.restore-yasm.outputs.cache-hit }}
+ uses: actions/cache/save@v4
+ with:
+ path: |
+ ${{ github.workspace }}/yasm
+ key: ${{ steps.calc.outputs.cache-key }}
+ enableCrossOsArchive: true
+ - name: 'Set output variables'
+ id: final
+ shell: pwsh
+ run: |
+ echo "${{ github.workspace }}/yasm/bin" >> $env:GITHUB_PATH
diff --git a/.github/fetch_yasm.ps1 b/.github/fetch_yasm.ps1
deleted file mode 100644
index 5353e46fd..000000000
--- a/.github/fetch_yasm.ps1
+++ /dev/null
@@ -1,33 +0,0 @@
-$ErrorActionPreference = "Stop"
-
-$project_root = "$psScriptRoot\.."
-Write-Output "project_root: $project_root"
-
-$yasm_version = "1.3.0"
-$yasm_dlexe = "yasm-$yasm_version-win64.exe"
-
-$yasm_url = "https://github.com/yasm/yasm/releases/download/v$yasm_version/$yasm_dlexe"
-$yasm_exename = "yasm.exe"
-$yasm_exepath = "$project_root/yasm.exe"
-
-$yasm_dlpath = "$project_root\$yasm_dlexe"
-
-echo "yasm_dlpath: $yasm_dlpath"
-echo "yasm_exename: $yasm_exename"
-echo "yasm_exepath: $yasm_exepath"
-
-echo "Cleaning previous artifacts"
-if (Test-Path $yasm_dlpath) {
- Remove-Item $yasm_dlpath -Force
-}
-if (Test-Path $yasm_exepath) {
- Remove-Item $yasm_exepath -Force
-}
-
-Write-Output "Downloading $yasm_dlexe ($yasm_url)"
-Invoke-WebRequest -Uri $yasm_url -OutFile $yasm_dlpath
-
-Write-Output "Moving $yasm_dlexe to $yasm_exename"
-Rename-Item $yasm_dlpath $yasm_exename
-
-Write-Output "Done"
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index a3e6986be..2103b71d8 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -99,12 +99,9 @@ jobs:
if: ${{ runner.os == 'Linux' }}
run: ./build-scripts/test-versioning.sh
- - name: Set up yasm for mpg123
+ - name: Set up yasm for mpg123 (MSVC only)
+ uses: ./.github/actions/setup-yasm
if: ${{ matrix.platform.msvc }}
- shell: pwsh
- run: |
- .github/fetch_yasm.ps1
- echo "${{ github.workspace }}" >> $Env:GITHUB_PATH
- name: Configure (CMake)
run: |