1+ param (
2+ [Parameter (Mandatory = $true )]
3+ [string ]$Version ,
4+
5+ [Parameter (Mandatory = $true )]
6+ [ValidateSet (" amd64" , " arm64" )]
7+ [string ]$Arch ,
8+
9+ [Parameter (Mandatory = $false )]
10+ [string ]$BinaryPath = " " ,
11+
12+ [Parameter (Mandatory = $false )]
13+ [string ]$OutputDir = " packaging"
14+ )
15+
16+ $ErrorActionPreference = " Stop"
17+
18+ $PackageName = " cordium"
19+ $DisplayName = " Cordium"
20+ $Manufacturer = " Octelium Labs, LLC"
21+ $Description = " Cordium - open-source sandbox platform with identity-based, secretless infrastructure access"
22+
23+ $WixPlatform = switch ($Arch ) {
24+ " amd64" { " x64" }
25+ " arm64" { " ARM64" }
26+ }
27+
28+ $UpgradeCode = " 8D67D17B-6F9E-4B8C-9B0F-6E4B63B6E8B1"
29+ $ComponentGuid = " 1E3D7469-35D6-4C7E-9D2C-4C0305165791"
30+ $PathGuid = " 84286B9D-79F2-4E6F-A6C1-20D28E61F5B3"
31+
32+ if ([string ]::IsNullOrWhiteSpace($BinaryPath )) {
33+ $candidates = @ (
34+ " bin\cordium.exe" ,
35+ " dist\cordium-windows-$Arch \cordium.exe" ,
36+ " cordium.exe"
37+ )
38+
39+ foreach ($candidate in $candidates ) {
40+ if (Test-Path $candidate ) {
41+ $BinaryPath = $candidate
42+ break
43+ }
44+ }
45+ }
46+
47+ if ([string ]::IsNullOrWhiteSpace($BinaryPath ) -or -not (Test-Path $BinaryPath )) {
48+ Write-Host " Could not find cordium.exe."
49+ Write-Host " Expected one of:"
50+ Write-Host " bin\cordium.exe"
51+ Write-Host " dist\cordium-windows-$Arch \cordium.exe"
52+ Write-Host " cordium.exe"
53+ Write-Host " "
54+ Write-Host " Existing cordium-like files:"
55+ Get-ChildItem - Recurse - File - Filter " cordium*" - ErrorAction SilentlyContinue |
56+ Select-Object - ExpandProperty FullName
57+
58+ throw " Binary file not found"
59+ }
60+
61+ $templatePath = " .github\scripts\windows\template.wxs"
62+
63+ if (-not (Test-Path $templatePath )) {
64+ throw " Template file not found: $templatePath "
65+ }
66+
67+ New-Item - ItemType Directory - Force - Path " packaging\msi" | Out-Null
68+ New-Item - ItemType Directory - Force - Path $OutputDir | Out-Null
69+
70+ $resolvedBinaryPath = (Resolve-Path $BinaryPath ).Path
71+
72+ Write-Host " Building MSI for Cordium"
73+ Write-Host " Version: $Version "
74+ Write-Host " Arch: $Arch "
75+ Write-Host " WiX Platform: $WixPlatform "
76+ Write-Host " Binary: $resolvedBinaryPath "
77+
78+ $wxsContent = Get-Content $templatePath - Raw
79+ $wxsContent = $wxsContent -replace ' \$\{VERSION\}' , $Version
80+ $wxsContent = $wxsContent -replace ' \$\{UPGRADE_CODE\}' , $UpgradeCode
81+ $wxsContent = $wxsContent -replace ' \$\{DESCRIPTION\}' , $Description
82+ $wxsContent = $wxsContent -replace ' \$\{COMPONENT_GUID\}' , $ComponentGuid
83+ $wxsContent = $wxsContent -replace ' \$\{PATH_GUID\}' , $PathGuid
84+ $wxsContent = $wxsContent -replace ' \$\{BINARY_PATH\}' , ($resolvedBinaryPath -replace ' \\' , ' \\' )
85+
86+ $wxsPath = " packaging\msi\cordium.wxs"
87+ $wxsContent | Out-File - FilePath $wxsPath - Encoding UTF8
88+
89+ Write-Host " Generated WXS file: $wxsPath "
90+
91+ $msiPath = Join-Path $OutputDir " cordium-$Version -$Arch .msi"
92+
93+ Write-Host " Building MSI: $msiPath "
94+
95+ wix build `
96+ - arch $WixPlatform `
97+ - o $msiPath `
98+ $wxsPath
99+
100+ if ($LASTEXITCODE -ne 0 ) {
101+ throw " WiX build failed with exit code $LASTEXITCODE "
102+ }
103+
104+ Write-Host " Successfully created: $msiPath "
0 commit comments