|
| 1 | +name: Build & Release Windows Fixer |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + tags: [ "v*.*.*" ] |
| 7 | + workflow_dispatch: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + build: |
| 14 | + runs-on: windows-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Set up Python |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: "3.11" |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + python -m pip install --upgrade pip |
| 28 | + pip install pillow pyinstaller |
| 29 | +
|
| 30 | + - name: Build EXE |
| 31 | + shell: pwsh |
| 32 | + run: | |
| 33 | + $tag = "${{ github.ref_name }}" |
| 34 | + if ($tag -eq "main") { $tag = "dev" } |
| 35 | +
|
| 36 | + $args = @("--onefile","--noconsole","--name","windows_fixer") |
| 37 | +
|
| 38 | + if (Test-Path "icon.ico") { $args += @("--icon","icon.ico") } |
| 39 | + if (Test-Path "Success.wav") { $args += @("--add-data","Success.wav;.") } |
| 40 | + if (Test-Path "kuwait.png") { $args += @("--add-data","kuwait.png;.") } |
| 41 | +
|
| 42 | + pyinstaller @args windows_fixer.py |
| 43 | +
|
| 44 | + New-Item -ItemType Directory -Force -Path release_out | Out-Null |
| 45 | +
|
| 46 | + # Name the exe nicely for release |
| 47 | + if ("${{ github.ref }}".StartsWith("refs/tags/")) { |
| 48 | + Copy-Item "dist\windows_fixer.exe" "release_out\WindowsFixer_${{ github.ref_name }}.exe" -Force |
| 49 | + } else { |
| 50 | + Copy-Item "dist\windows_fixer.exe" "release_out\WindowsFixer_dev.exe" -Force |
| 51 | + } |
| 52 | +
|
| 53 | + - name: Create SHA256 |
| 54 | + shell: pwsh |
| 55 | + run: | |
| 56 | + $files = Get-ChildItem "release_out\*.exe" |
| 57 | + foreach ($f in $files) { |
| 58 | + $hash = (Get-FileHash $f.FullName -Algorithm SHA256).Hash.ToLower() |
| 59 | + "$hash $($f.Name)" | Out-File "release_out\SHA256SUMS.txt" -Append -Encoding ascii |
| 60 | + } |
| 61 | +
|
| 62 | + - name: Zip bundle |
| 63 | + shell: pwsh |
| 64 | + run: | |
| 65 | + if ("${{ github.ref }}".StartsWith("refs/tags/")) { |
| 66 | + $zip = "WindowsFixer_${{ github.ref_name }}_Windows_x64.zip" |
| 67 | + } else { |
| 68 | + $zip = "WindowsFixer_dev_Windows_x64.zip" |
| 69 | + } |
| 70 | +
|
| 71 | + if (Test-Path $zip) { Remove-Item $zip -Force } |
| 72 | + Compress-Archive -Path "release_out\*" -DestinationPath $zip -Force |
| 73 | +
|
| 74 | + echo "ZIP_NAME=$zip" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding ascii |
| 75 | +
|
| 76 | + # Always upload artifact (so you can download it from Actions even without a tag) |
| 77 | + - name: Upload artifact |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: Windows_Fixer_Build |
| 81 | + path: ${{ env.ZIP_NAME }} |
| 82 | + |
| 83 | + # Only when pushing a tag: attach zip to GitHub Release |
| 84 | + - name: Upload to GitHub Release (tags only) |
| 85 | + if: startsWith(github.ref, 'refs/tags/') |
| 86 | + uses: softprops/action-gh-release@v2 |
| 87 | + with: |
| 88 | + files: ${{ env.ZIP_NAME }} |
| 89 | + generate_release_notes: true |
0 commit comments