|
| 1 | +name: Build Windows Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'V*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write # required to create releases and upload assets |
| 10 | + |
| 11 | +jobs: |
| 12 | + build-windows: |
| 13 | + runs-on: windows-latest |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v4 |
| 22 | + with: |
| 23 | + python-version: '3.11' |
| 24 | + |
| 25 | + - name: Install build dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install pyinstaller==5.13.0 PyQt6 |
| 29 | +
|
| 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. |
| 33 | + run: | |
| 34 | + ls -la |
| 35 | + echo "Expecting ./res/icon.ico and any resource files inside ./res/" |
| 36 | +
|
| 37 | + - name: Build Windows executable with PyInstaller |
| 38 | + 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%" |
| 54 | +
|
| 55 | + - name: Create GitHub Release |
| 56 | + id: create_release |
| 57 | + uses: softprops/action-gh-release@v1 |
| 58 | + with: |
| 59 | + tag_name: ${{ github.ref_name }} |
| 60 | + name: Release ${{ github.ref_name }} |
| 61 | + draft: false |
| 62 | + prerelease: false |
| 63 | + env: |
| 64 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 65 | + |
| 66 | + - name: Upload Windows binary to Release |
| 67 | + uses: softprops/action-gh-release@v1 |
| 68 | + with: |
| 69 | + files: dist/mtkclient_installer_windows.exe |
| 70 | + env: |
| 71 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments