From f1b2b319f56fd1048ec8b6f8b3edd476ddb3b694 Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Sat, 18 Nov 2023 06:53:54 +1000 Subject: [PATCH 1/3] 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 a5f277885..8cf772e76 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 46fb1c17c..808305c15 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 50e7fe767..65eff9e83 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 @@ - + + + + + + + From d4b48e52e6d2dc4d02c3c35ce8057cbb8d23e1d2 Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Sun, 19 Nov 2023 13:29:47 +1000 Subject: [PATCH 2/3] feat: Add ARM64 MSI builds Signed-off-by: Ben Reedy --- installer/build.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/installer/build.ps1 b/installer/build.ps1 index 808305c15..2b258392d 100644 --- a/installer/build.ps1 +++ b/installer/build.ps1 @@ -5,7 +5,7 @@ Param ( [Parameter(Mandatory = $true)] [String] $Version, [Parameter(Mandatory = $false)] - [ValidateSet("amd64", "386")] + [ValidateSet("amd64", "arm64", "386")] [String] $Arch = "amd64" ) $ErrorActionPreference = "Stop" @@ -23,7 +23,7 @@ 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] +$wixArch = @{"amd64" = "x64"; "arm64" = "arm64"; "386" = "x86"}[$Arch] $wixOpts = "-ext WixFirewallExtension -ext WixUtilExtension" 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" From 7feafc123807b7c4743964995852a810721fd8db Mon Sep 17 00:00:00 2001 From: Ben Reedy Date: Mon, 20 Nov 2023 06:11:22 +1000 Subject: [PATCH 3/3] fix: Set default values for MSI web.listen-address This prevents the exporter HTTP port from being omitted from the firewall rule DisplayName. I've tested this in the following four scenarios, and web.listen-address is set correctly for each: * Nothing set: 0.0.0.0:9182 * LISTEN_PORT=9184: 0.0.0.0:9184 * LISTEN_ADDR=127.0.0.1: 127.0.0.1:9182 * LISTEN_PORT=9184 LISTEN_ADDR=127.0.0.1: 127.0.0.1:9184 Signed-off-by: Ben Reedy --- installer/windows_exporter.wxs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/installer/windows_exporter.wxs b/installer/windows_exporter.wxs index 65eff9e83..857627817 100644 --- a/installer/windows_exporter.wxs +++ b/installer/windows_exporter.wxs @@ -15,11 +15,8 @@ - - - - - + + @@ -39,7 +36,7 @@ - +