Files
Shortcut_Sync_PotPlayer/.github/workflows/build-exe.yml
Hsdi c099ce7957
Some checks failed
Build Windows EXE / build (push) Failing after 5s
feat: Add GitHub Actions workflow to automatically build a Windows executable.
2026-03-15 02:16:01 +08:00

67 lines
2.1 KiB
YAML

name: Build Windows EXE
on:
workflow_dispatch:
push:
branches:
- main
jobs:
build:
runs-on: windows
steps:
- name: Show workspace
shell: powershell
run: |
Write-Host "Workspace: $pwd"
Get-ChildItem
- name: Locate project files
shell: powershell
run: |
$mainFile = Get-ChildItem -Path $pwd -Recurse -Filter main.py -File | Select-Object -First 1
if (-not $mainFile) {
Write-Error "Could not find main.py in workspace."
}
$projectDir = $mainFile.Directory.FullName
"PROJECT_DIR=$projectDir" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
Write-Host "Project directory: $projectDir"
Get-ChildItem $projectDir
- name: Detect Python
shell: powershell
run: |
if (Get-Command py -ErrorAction SilentlyContinue) {
"PY_CMD=py" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
py --version
}
elseif (Get-Command python -ErrorAction SilentlyContinue) {
"PY_CMD=python" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
python --version
}
else {
Write-Error "Python is not installed or not available in PATH. Install Python on the runner, or add py/python to PATH."
}
- name: Install dependencies
shell: powershell
run: |
& $env:PY_CMD -m pip --version
& $env:PY_CMD -m pip install --upgrade pip
& $env:PY_CMD -m pip install pyinstaller keyboard pywin32
- name: Build executable
shell: powershell
working-directory: ${{ env.PROJECT_DIR }}
run: |
& $env:PY_CMD -m PyInstaller --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py
- name: Collect build output
shell: powershell
run: |
New-Item -ItemType Directory -Force output | Out-Null
Copy-Item "$env:PROJECT_DIR\\dist\\Shortcut_Sync_PotPlayer.exe" output/Shortcut_Sync_PotPlayer.exe -Force
Get-ChildItem output