forked from Xingshu/Shortcut_Sync_PotPlayer
feat: Add GitHub Actions workflow to automatically build a Windows executable.
This commit is contained in:
36
.github/workflows/build-exe.yml
vendored
36
.github/workflows/build-exe.yml
vendored
@@ -17,26 +17,50 @@ jobs:
|
|||||||
Write-Host "Workspace: $pwd"
|
Write-Host "Workspace: $pwd"
|
||||||
Get-ChildItem
|
Get-ChildItem
|
||||||
|
|
||||||
- name: Check Python
|
- name: Locate project files
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
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
|
python --version
|
||||||
pip --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
|
- name: Install dependencies
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
& $env:PY_CMD -m pip --version
|
||||||
pip install pyinstaller keyboard pywin32
|
& $env:PY_CMD -m pip install --upgrade pip
|
||||||
|
& $env:PY_CMD -m pip install pyinstaller keyboard pywin32
|
||||||
|
|
||||||
- name: Build executable
|
- name: Build executable
|
||||||
shell: powershell
|
shell: powershell
|
||||||
|
working-directory: ${{ env.PROJECT_DIR }}
|
||||||
run: |
|
run: |
|
||||||
pyinstaller --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py
|
& $env:PY_CMD -m PyInstaller --noconfirm --onefile --windowed --name Shortcut_Sync_PotPlayer main.py
|
||||||
|
|
||||||
- name: Collect build output
|
- name: Collect build output
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
New-Item -ItemType Directory -Force output | Out-Null
|
New-Item -ItemType Directory -Force output | Out-Null
|
||||||
Copy-Item dist/Shortcut_Sync_PotPlayer.exe output/Shortcut_Sync_PotPlayer.exe -Force
|
Copy-Item "$env:PROJECT_DIR\\dist\\Shortcut_Sync_PotPlayer.exe" output/Shortcut_Sync_PotPlayer.exe -Force
|
||||||
Get-ChildItem output
|
Get-ChildItem output
|
||||||
|
|||||||
Reference in New Issue
Block a user