Skip to content

Commit 227462d

Browse files
committed
.github/scripts - add windows build-msi
1 parent d2e56c1 commit 227462d

2 files changed

Lines changed: 172 additions & 0 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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"
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
3+
<Package
4+
Name="Cordium"
5+
Version="${VERSION}.0"
6+
Manufacturer="Octelium Labs, LLC"
7+
UpgradeCode="${UPGRADE_CODE}"
8+
Language="1033"
9+
Codepage="1252"
10+
Scope="perMachine">
11+
12+
<SummaryInformation
13+
Description="${DESCRIPTION}"
14+
Manufacturer="Octelium Labs, LLC"
15+
Keywords="Installer, CLI, Cordium, Octelium" />
16+
17+
<MajorUpgrade
18+
DowngradeErrorMessage="A newer version of Cordium is already installed."
19+
AllowSameVersionUpgrades="yes" />
20+
21+
<Media Id="1" Cabinet="cordium.cab" EmbedCab="yes" />
22+
23+
<Feature Id="ProductFeature" Title="Cordium CLI" Level="1">
24+
<ComponentGroupRef Id="ProductComponents" />
25+
<ComponentRef Id="PATH" />
26+
</Feature>
27+
28+
<StandardDirectory Id="ProgramFiles64Folder">
29+
<Directory Id="INSTALLFOLDER" Name="Octelium">
30+
<Directory Id="BIN_FOLDER" Name="Cordium" />
31+
</Directory>
32+
</StandardDirectory>
33+
</Package>
34+
35+
<Fragment>
36+
<ComponentGroup Id="ProductComponents" Directory="BIN_FOLDER">
37+
<Component Id="MainExecutable" Guid="${COMPONENT_GUID}">
38+
<File Id="MainExe" Source="${BINARY_PATH}" Name="cordium.exe" KeyPath="yes" />
39+
<RegistryValue
40+
Root="HKLM"
41+
Key="Software\Octelium\Cordium"
42+
Name="Version"
43+
Type="string"
44+
Value="${VERSION}"
45+
KeyPath="no" />
46+
</Component>
47+
</ComponentGroup>
48+
49+
<Component Id="PATH" Guid="${PATH_GUID}" Directory="BIN_FOLDER">
50+
<Environment
51+
Id="PATH"
52+
Name="PATH"
53+
Value="[BIN_FOLDER]"
54+
Permanent="no"
55+
Part="last"
56+
Action="set"
57+
System="yes" />
58+
59+
<RegistryValue
60+
Root="HKLM"
61+
Key="Software\Octelium\Cordium"
62+
Name="Path"
63+
Type="string"
64+
Value="[BIN_FOLDER]"
65+
KeyPath="yes" />
66+
</Component>
67+
</Fragment>
68+
</Wix>

0 commit comments

Comments
 (0)