|
| 1 | +name: Build Windows And Deb Packages |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: [ "main" ] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +jobs: |
| 13 | + build-windows: |
| 14 | + name: Windows (${{ matrix.label }}) |
| 15 | + runs-on: ${{ matrix.runner }} |
| 16 | + strategy: |
| 17 | + fail-fast: false |
| 18 | + matrix: |
| 19 | + include: |
| 20 | + - runner: windows-latest |
| 21 | + arch: x64 |
| 22 | + label: x64-x86_64 |
| 23 | + - runner: windows-11-arm |
| 24 | + arch: arm64 |
| 25 | + label: arm64 |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Setup Python |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: "3.11" |
| 35 | + architecture: ${{ matrix.arch }} |
| 36 | + |
| 37 | + - name: Install build deps |
| 38 | + shell: pwsh |
| 39 | + run: | |
| 40 | + python -m pip install --upgrade pip |
| 41 | + pip install pyqt5 pyinstaller pillow |
| 42 | +
|
| 43 | + - name: Convert icon.png to ico |
| 44 | + shell: pwsh |
| 45 | + run: | |
| 46 | + if (-Not (Test-Path "icon.png")) { |
| 47 | + throw "icon.png not found in repository root." |
| 48 | + } |
| 49 | + python - <<'PY' |
| 50 | + from PIL import Image |
| 51 | + img = Image.open("icon.png").convert("RGBA") |
| 52 | + img.save("icon.ico", format="ICO", sizes=[(16,16),(24,24),(32,32),(48,48),(64,64),(128,128),(256,256)]) |
| 53 | + PY |
| 54 | +
|
| 55 | + - name: Build Windows app bundle |
| 56 | + shell: pwsh |
| 57 | + run: | |
| 58 | + $ErrorActionPreference = "Stop" |
| 59 | + pyinstaller --noconfirm --clean --windowed --onedir --name HomeworkIsland ` |
| 60 | + --icon "icon.ico" ` |
| 61 | + --add-data "qml;qml" ` |
| 62 | + --add-data "view;view" ` |
| 63 | + --add-data "about.html;." ` |
| 64 | + --add-data "icon.png;." ` |
| 65 | + main.py |
| 66 | +
|
| 67 | + New-Item -ItemType Directory -Force -Path "dist\HomeworkIsland\project" | Out-Null |
| 68 | + robocopy . "dist\HomeworkIsland\project" /E /XD .git .github .venv build dist __pycache__ /XF *.pyc |
| 69 | + if ($LASTEXITCODE -gt 7) { exit $LASTEXITCODE } |
| 70 | +
|
| 71 | + - name: Package artifact |
| 72 | + shell: pwsh |
| 73 | + run: | |
| 74 | + $pkg = "HomeworkIsland-windows-${{ matrix.label }}" |
| 75 | + Compress-Archive -Path "dist\HomeworkIsland\*" -DestinationPath "$pkg.zip" -Force |
| 76 | +
|
| 77 | + - name: Upload artifact |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: HomeworkIsland-windows-${{ matrix.label }} |
| 81 | + path: HomeworkIsland-windows-${{ matrix.label }}.zip |
| 82 | + |
| 83 | + build-deb: |
| 84 | + name: Debian (${{ matrix.deb_arch }}) |
| 85 | + runs-on: ${{ matrix.runner }} |
| 86 | + strategy: |
| 87 | + fail-fast: false |
| 88 | + matrix: |
| 89 | + include: |
| 90 | + - runner: ubuntu-latest |
| 91 | + deb_arch: amd64 |
| 92 | + - runner: ubuntu-24.04-arm |
| 93 | + deb_arch: arm64 |
| 94 | + |
| 95 | + steps: |
| 96 | + - name: Checkout |
| 97 | + uses: actions/checkout@v4 |
| 98 | + |
| 99 | + - name: Build deb package |
| 100 | + shell: bash |
| 101 | + run: | |
| 102 | + set -euxo pipefail |
| 103 | +
|
| 104 | + APP_NAME="homework-island" |
| 105 | + APP_VER="0.1.${GITHUB_RUN_NUMBER}" |
| 106 | + PKG_ROOT="$PWD/pkgroot" |
| 107 | + INSTALL_DIR="$PKG_ROOT/opt/$APP_NAME" |
| 108 | +
|
| 109 | + mkdir -p "$INSTALL_DIR" |
| 110 | + rsync -a ./ "$INSTALL_DIR/" --exclude .git --exclude .github --exclude .venv --exclude build --exclude dist --exclude __pycache__ |
| 111 | +
|
| 112 | + mkdir -p "$PKG_ROOT/usr/bin" |
| 113 | + cat > "$PKG_ROOT/usr/bin/$APP_NAME" <<'EOF' |
| 114 | + #!/usr/bin/env bash |
| 115 | + set -e |
| 116 | + cd /opt/homework-island |
| 117 | + exec python3 /opt/homework-island/main.py |
| 118 | + EOF |
| 119 | + chmod +x "$PKG_ROOT/usr/bin/$APP_NAME" |
| 120 | +
|
| 121 | + mkdir -p "$PKG_ROOT/usr/share/applications" |
| 122 | + cat > "$PKG_ROOT/usr/share/applications/$APP_NAME.desktop" <<EOF |
| 123 | + [Desktop Entry] |
| 124 | + Name=HomeworkIsland |
| 125 | + Comment=Homework board app |
| 126 | + Exec=/usr/bin/$APP_NAME |
| 127 | + Icon=$APP_NAME |
| 128 | + Terminal=false |
| 129 | + Type=Application |
| 130 | + Categories=Education;Utility; |
| 131 | + EOF |
| 132 | +
|
| 133 | + mkdir -p "$PKG_ROOT/usr/share/icons/hicolor/256x256/apps" |
| 134 | + cp "$INSTALL_DIR/icon.png" "$PKG_ROOT/usr/share/icons/hicolor/256x256/apps/$APP_NAME.png" |
| 135 | +
|
| 136 | + mkdir -p "$PKG_ROOT/DEBIAN" |
| 137 | + cat > "$PKG_ROOT/DEBIAN/control" <<EOF |
| 138 | + Package: $APP_NAME |
| 139 | + Version: $APP_VER |
| 140 | + Section: utils |
| 141 | + Priority: optional |
| 142 | + Architecture: ${{ matrix.deb_arch }} |
| 143 | + Maintainer: HomeworkIsland Builder <builder@example.com> |
| 144 | + Depends: python3, python3-pyqt5 |
| 145 | + Description: Homework board app (PyQt + Qt Quick) |
| 146 | + Includes project files and runs main.py from /opt/homework-island. |
| 147 | + EOF |
| 148 | +
|
| 149 | + dpkg-deb --build "$PKG_ROOT" "${APP_NAME}_${APP_VER}_${{ matrix.deb_arch }}.deb" |
| 150 | +
|
| 151 | + - name: Upload artifact |
| 152 | + uses: actions/upload-artifact@v4 |
| 153 | + with: |
| 154 | + name: HomeworkIsland-deb-${{ matrix.deb_arch }} |
| 155 | + path: "*.deb" |
0 commit comments