-
-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (90 loc) · 3.33 KB
/
Copy pathbuild-windows-msi.yml
File metadata and controls
107 lines (90 loc) · 3.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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