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.
- name: Install winget
if: runner.os == 'Windows'
uses: Cyberboss/install-winget@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: install prereqs (Windows)
if: runner.os == 'Windows'
run: winget install ffmpeg --disable-interactivity --accept-source-agreements
- name: FFMPEG_ROOT Windows
run: echo "FFMPEG_ROOT=$env:LOCALAPPDATA/Microsoft/WinGet/Links/" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
if: runner.os == 'Windows'
- 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)