fix(spec): add backend to pathex and Analysis scripts so PyInstaller … #14
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Windows MSI | |
| on: | |
| push: | |
| branches: | |
| - windows-app | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build-msi: | |
| name: PyInstaller + WiX MSI | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| cache: 'pip' | |
| - name: Install Python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r backend/requirements.txt | |
| pip install -r requirements-desktop.txt | |
| - name: Build EXE with PyInstaller | |
| run: pyinstaller trishul.spec --clean --noconfirm | |
| - name: Verify EXE exists | |
| run: | | |
| if (-not (Test-Path "dist\TrishulSNMP\TrishulSNMP.exe")) { | |
| Write-Error "TrishulSNMP.exe not found." | |
| exit 1 | |
| } | |
| Write-Host "EXE size: $([math]::Round((Get-Item dist\TrishulSNMP\TrishulSNMP.exe).Length/1MB,1)) MB" | |
| - name: Install WiX v4.0.5 | |
| run: | | |
| dotnet tool install --global wix --version 4.0.5 | |
| wix extension add WixToolset.UI.wixext/4.0.5 | |
| - name: Generate harvested.wxs from PyInstaller output | |
| run: | | |
| $distDir = (Resolve-Path "dist\TrishulSNMP").Path | |
| $out = "installer\harvested.wxs" | |
| $id = 0 | |
| $xml = [System.Collections.Generic.List[string]]::new() | |
| $xml.Add('<?xml version="1.0" encoding="UTF-8"?>') | |
| $xml.Add('<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">') | |
| $xml.Add(' <Fragment>') | |
| $xml.Add(' <ComponentGroup Id="AppFiles" Directory="INSTALLFOLDER">') | |
| Get-ChildItem -Path $distDir -Recurse -File | ForEach-Object { | |
| $id++ | |
| $rel = $_.FullName.Substring($distDir.Length + 1) | |
| $sub = Split-Path $rel -Parent | |
| $subAttr = if ($sub) { " Subdirectory=`"$sub`"" } else { "" } | |
| $src = "`$(var.SourceDir)\$rel" | |
| $xml.Add(" <Component Id=`"c$id`" Guid=`"*`"$subAttr>") | |
| $xml.Add(" <File Source=`"$src`" />") | |
| $xml.Add(" </Component>") | |
| } | |
| $xml.Add(' </ComponentGroup>') | |
| $xml.Add(' </Fragment>') | |
| $xml.Add('</Wix>') | |
| [System.IO.File]::WriteAllLines( | |
| $out, $xml, | |
| [System.Text.UTF8Encoding]::new($false) | |
| ) | |
| Write-Host "Harvested $id files -> $out" | |
| - name: Build MSI with WiX | |
| run: | | |
| $srcAbs = (Resolve-Path "dist\TrishulSNMP").Path | |
| New-Item -ItemType Directory -Force -Path dist | Out-Null | |
| wix build ` | |
| installer\trishul.wxs ` | |
| installer\harvested.wxs ` | |
| -arch x64 ` | |
| -ext WixToolset.UI.wixext ` | |
| -d "SourceDir=$srcAbs" ` | |
| -o dist\TrishulSNMP-Setup.msi | |
| - name: Upload MSI as build artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: TrishulSNMP-Setup-MSI | |
| path: dist\TrishulSNMP-Setup.msi | |
| retention-days: 30 | |
| if-no-files-found: error | |
| - name: Attach MSI to GitHub Release | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: dist\TrishulSNMP-Setup.msi | |
| generate_release_notes: true |