GitHub Actions winget install
WinGet can be used on Windows GitHub Actions runners where a Windows program needs to be installed. In this example, environment variable FFMPEG_ROOT tells Python where to find the ffmpeg.exe program. One could more generally append to the GITHUB_PATH environment variable.
jobs:
windows:
runs-on: windows-2025
steps:
- name: install prereqs (Windows)
if: runner.os == 'Windows'
run: winget install ffmpeg --disable-interactivity --accept-source-agreements --accept-package-agreements
- name: FFMPEG_ROOT Windows
if: runner.os == 'Windows'
run: echo "FFMPEG_ROOT=$env:LOCALAPPDATA/Microsoft/WinGet/Links/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: PyTest
run: pytest
import functools
import shutil
import os
@functools.cache
def get_exe(name: str) -> str:
for p in (os.environ.get("FFMPEG_ROOT"), None):
if exe := shutil.which(name, path=p):
return exe
raise FileNotFoundError(name)