From f1b2b319f56fd1048ec8b6f8b3edd476ddb3b694 Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Sat, 18 Nov 2023 06:53:54 +1000 Subject: [PATCH] feat: Update WiX from v3 to v4 This change updates WiX to the latest major upstream version, which is a prerequisite for ARM64 MSI builds. Signed-off-by: Ben Reedy --- .github/workflows/release.yml | 12 +++++-- installer/build.ps1 | 33 ++----------------- installer/windows_exporter.wxs | 59 +++++++++++++++------------------- 3 files changed, 38 insertions(+), 66 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5f27788..8cf772e7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,6 +27,14 @@ jobs: with: go-version-file: 'go.mod' + - name: Install WiX + run: dotnet tool install --global wix + + - name: Install WiX extensions + run: | + wix extension add -g WixToolset.Util.wixext + wix extension add -g WixToolset.Firewall.wixext + - name: Install Build deps run: | dotnet tool install --global GitVersion.Tool --version 5.* @@ -72,10 +80,10 @@ jobs: $TagName = $env:GITHUB_REF -replace 'refs/tags/', '' # The MSI version is not semver compliant, so just take the numerical parts $MSIVersion = $TagName -replace '^v?([0-9\.]+).*$','$1' - foreach($Arch in "amd64", "386") { + foreach($Arch in "amd64", "arm64", "386") { Write-Verbose "Building windows_exporter $MSIVersion msi for $Arch" .\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$BuildVersion-$Arch.exe -Version $MSIVersion -Arch "$Arch" - Move-Item installer\Output\windows_exporter-$MSIVersion-$Arch.msi output\ + Move-Item installer\windows_exporter-$MSIVersion-$Arch.msi output\ } promu checksum output\ diff --git a/installer/build.ps1 b/installer/build.ps1 index 46fb1c17..808305c1 100644 --- a/installer/build.ps1 +++ b/installer/build.ps1 @@ -19,42 +19,13 @@ Trap { Pop-Location } -if ($PSVersionTable.PSVersion.Major -lt 5) { - Write-Error "Powershell version 5 required" - exit 1 -} - -$wc = New-Object System.Net.WebClient -function Get-FileIfNotExists { - Param ( - $Url, - $Destination - ) - if (-not (Test-Path $Destination)) { - Write-Verbose "Downloading $Url" - $wc.DownloadFile($Url, $Destination) - } - else { - Write-Verbose "${Destination} already exists. Skipping." - } -} - -$sourceDir = mkdir -Force Source -mkdir -Force Work, Output | Out-Null - -Write-Verbose "Downloading WiX..." -[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -Get-FileIfNotExists "https://github.com/wixtoolset/wix3/releases/download/wix311rtm/wix311-binaries.zip" "$sourceDir\wix-binaries.zip" -mkdir -Force WiX | Out-Null -Expand-Archive -Path "${sourceDir}\wix-binaries.zip" -DestinationPath WiX -Force - +mkdir -Force Work | Out-Null Copy-Item -Force $PathToExecutable Work/windows_exporter.exe Write-Verbose "Creating windows_exporter-${Version}-${Arch}.msi" $wixArch = @{"amd64" = "x64"; "386" = "x86"}[$Arch] $wixOpts = "-ext WixFirewallExtension -ext WixUtilExtension" -Invoke-Expression "WiX\candle.exe -nologo -arch $wixArch $wixOpts -out Work\windows_exporter.wixobj -dVersion=`"$Version`" windows_exporter.wxs" -Invoke-Expression "WiX\light.exe -nologo -spdb $wixOpts -out `"Output\windows_exporter-${Version}-${Arch}.msi`" Work\windows_exporter.wixobj" +Invoke-Expression "wix build -arch $wixArch -o .\windows_exporter-$($Version)-$($Arch).msi .\windows_exporter.wxs -d Version=$($Version) -ext WixToolset.Firewall.wixext -ext WixToolset.Util.wixext" Write-Verbose "Done!" Pop-Location diff --git a/installer/windows_exporter.wxs b/installer/windows_exporter.wxs index 50e7fe76..65eff9e8 100644 --- a/installer/windows_exporter.wxs +++ b/installer/windows_exporter.wxs @@ -1,55 +1,42 @@ - - + - + - + - - - + + - - ENABLED_COLLECTORS + + - - EXTRA_FLAGS + + - LISTEN_ADDR AND LISTEN_PORT - LISTEN_ADDR AND (NOT LISTEN_PORT) - LISTEN_PORT AND (NOT LISTEN_ADDR) + + + - - METRICS_PATH + + - REMOTE_ADDR + - - - - - - - + - - TEXTFILE_DIR + + - [REMOTE_ADDR] + @@ -67,5 +54,11 @@ - + + + + + + +