Skip to content

Commit 656268e

Browse files
committed
workflow fix
1 parent a93490c commit 656268e

1 file changed

Lines changed: 37 additions & 20 deletions

File tree

.github/workflows/build.yml

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,51 @@ jobs:
2323
python-version: '3.11'
2424

2525
- name: Install build dependencies
26+
shell: pwsh
2627
run: |
2728
python -m pip install --upgrade pip
2829
pip install pyinstaller==5.13.0 PyQt6
2930
30-
- name: Prepare resource folder
31-
# ensure res/ exists in the workspace; if your resources are in a different path,
32-
# copy/move them here or update --add-data below accordingly.
31+
- name: Prepare resource folder (verify)
32+
shell: pwsh
3333
run: |
34-
ls -la
35-
echo "Expecting ./res/icon.ico and any resource files inside ./res/"
34+
Write-Host "Workspace contents:"
35+
Get-ChildItem -Force
36+
Write-Host "Expecting ./res/icon.ico and any resource files inside ./res/"
37+
if (-not (Test-Path -Path "./res/icon.ico")) {
38+
Write-Warning "res/icon.ico not found in repository workspace."
39+
# Do not exit here; fail later if missing during build.
40+
} else {
41+
Write-Host "res/icon.ico exists."
42+
}
3643
3744
- name: Build Windows executable with PyInstaller
45+
shell: pwsh
46+
env:
47+
DIST_NAME: mtkclient_installer_windows.exe
3848
run: |
39-
set DIST_NAME=mtkclient_installer_windows.exe
40-
REM PyInstaller flags:
41-
REM --onefile : single EXE
42-
REM --uac-admin : request admin elevation on start
43-
REM --hide-console hide-early : hide console early
44-
REM -i res/icon.ico : use repo icon
45-
REM --add-data "res;res" : bundle res/ into the exe (Windows path separator ;)
46-
pyinstaller --onefile --uac-admin --hide-console hide-early -i res/icon.ico --add-data "res;res" --clean --name mtkclient_installer mtkclient_installer.py
47-
IF ERRORLEVEL 1 (
48-
echo "PyInstaller build failed"
49-
exit /b 1
50-
)
51-
mkdir -p dist
52-
move /Y "dist\mtkclient_installer.exe" "dist\%DIST_NAME%"
53-
echo "Built: dist\%DIST_NAME%"
49+
$ErrorActionPreference = 'Stop'
50+
Write-Host "Starting PyInstaller build..."
51+
# Ensure dist folder removed from previous runs
52+
Remove-Item -Recurse -Force -ErrorAction SilentlyContinue dist, build, *.spec
53+
54+
# PyInstaller invocation:
55+
# --onefile -> single EXE
56+
# --uac-admin -> request admin elevation on start
57+
# --hide-console hide-early -> hide console early
58+
# -i res/icon.ico -> icon file inside repo
59+
# --add-data 'res;res' -> bundle res/ into exe (Windows uses ';' separator)
60+
pyinstaller --onefile --uac-admin --hide-console hide-early -i 'res/icon.ico' --add-data 'res;res' --clean --name mtkclient_installer mtkclient_installer.py
61+
62+
if (-not (Test-Path -Path "dist\mtkclient_installer.exe")) {
63+
Write-Error "PyInstaller build failed: dist\mtkclient_installer.exe not created"
64+
exit 1
65+
}
66+
67+
New-Item -ItemType Directory -Force -Path dist | Out-Null
68+
Move-Item -Force -Path 'dist\mtkclient_installer.exe' -Destination "dist\$env:DIST_NAME"
69+
70+
Write-Host "Built: dist\$env:DIST_NAME"
5471
5572
- name: Create GitHub Release
5673
id: create_release

0 commit comments

Comments
 (0)