2023-01-01 21:46:21 +00:00
|
|
|
name: Releases
|
2021-12-29 09:00:30 +00:00
|
|
|
|
2023-01-01 21:46:21 +00:00
|
|
|
# Trigger on releases.
|
2021-12-29 09:00:30 +00:00
|
|
|
on:
|
|
|
|
release:
|
|
|
|
types:
|
|
|
|
- published
|
|
|
|
- edited
|
|
|
|
|
2020-07-30 23:36:58 +00:00
|
|
|
permissions:
|
2022-07-23 08:44:06 +00:00
|
|
|
contents: write
|
2020-07-30 23:36:58 +00:00
|
|
|
packages: write
|
2023-01-01 21:46:21 +00:00
|
|
|
|
2022-02-08 07:15:03 +00:00
|
|
|
env:
|
2023-03-25 09:32:18 +00:00
|
|
|
PROMU_VER: '0.14.0'
|
2022-02-08 07:15:03 +00:00
|
|
|
|
2021-12-29 09:00:30 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2020-07-30 23:36:58 +00:00
|
|
|
runs-on: windows-2022
|
2021-12-29 09:00:30 +00:00
|
|
|
steps:
|
2023-01-05 12:10:44 +00:00
|
|
|
- uses: actions/checkout@v3
|
2021-12-29 09:00:30 +00:00
|
|
|
with:
|
|
|
|
# fetch-depth required for gitversion in `Build` step
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2023-01-05 12:10:44 +00:00
|
|
|
- uses: actions/setup-go@v3
|
2021-12-29 09:00:30 +00:00
|
|
|
with:
|
2023-11-12 12:41:14 +00:00
|
|
|
go-version-file: 'go.mod'
|
2021-12-29 09:00:30 +00:00
|
|
|
|
2023-11-17 20:53:54 +00:00
|
|
|
- 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
|
|
|
|
|
2021-12-29 09:00:30 +00:00
|
|
|
- name: Install Build deps
|
|
|
|
run: |
|
2020-07-30 23:36:58 +00:00
|
|
|
dotnet tool install --global GitVersion.Tool --version 5.*
|
2023-01-05 21:14:13 +00:00
|
|
|
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:PROMU_VER)/promu-$($Env:PROMU_VER).windows-amd64.zip -OutFile promu-$($Env:PROMU_VER).windows-amd64.zip
|
2023-01-01 22:35:14 +00:00
|
|
|
Expand-Archive -Path promu-$($Env:PROMU_VER).windows-amd64.zip -DestinationPath .
|
|
|
|
Copy-Item -Path promu-$($Env:PROMU_VER).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
|
|
|
|
|
|
|
# No binaries available so build from source
|
2022-04-06 22:23:28 +00:00
|
|
|
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0
|
2021-12-29 09:00:30 +00:00
|
|
|
# GOPATH\bin dir must be added to PATH else the `promu` and `goversioninfo` commands won't be found
|
|
|
|
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
2020-07-30 23:36:58 +00:00
|
|
|
dotnet-gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
|
2021-12-29 09:00:30 +00:00
|
|
|
$Version = Get-Content VERSION
|
|
|
|
# Windows versioninfo resources need the file version by parts (but product version is free text)
|
|
|
|
$VersionParts = ($Version -replace '^v?([0-9\.]+).*$','$1').Split(".")
|
|
|
|
goversioninfo.exe -ver-major $VersionParts[0] -ver-minor $VersionParts[1] -ver-patch $VersionParts[2] -product-version $Version -platform-specific
|
|
|
|
|
|
|
|
make crossbuild
|
2022-02-27 06:22:32 +00:00
|
|
|
# '+' symbols are invalid characters in image tags
|
|
|
|
(Get-Content -Path VERSION) -replace '\+', '_' | Set-Content -Path VERSION
|
2020-07-30 23:36:58 +00:00
|
|
|
make build-all
|
2021-12-29 09:00:30 +00:00
|
|
|
# GH requires all files to have different names, so add version/arch to differentiate
|
2024-01-08 18:59:15 +00:00
|
|
|
foreach($Arch in "amd64", "arm64") {
|
2021-12-29 09:00:30 +00:00
|
|
|
Move-Item output\$Arch\windows_exporter.exe output\windows_exporter-$Version-$Arch.exe
|
|
|
|
}
|
|
|
|
|
|
|
|
- name: Upload Artifacts
|
2023-03-26 21:02:19 +00:00
|
|
|
uses: actions/upload-artifact@v3
|
2021-12-29 09:00:30 +00:00
|
|
|
with:
|
|
|
|
name: windows_exporter_binaries
|
|
|
|
path: output\windows_exporter-*.exe
|
|
|
|
|
|
|
|
- name: Build Release Artifacts
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
run: |
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$BuildVersion = Get-Content VERSION
|
|
|
|
$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'
|
2024-01-08 18:59:15 +00:00
|
|
|
foreach($Arch in "amd64", "arm64") {
|
2021-12-29 09:00:30 +00:00
|
|
|
Write-Verbose "Building windows_exporter $MSIVersion msi for $Arch"
|
|
|
|
.\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$BuildVersion-$Arch.exe -Version $MSIVersion -Arch "$Arch"
|
2023-11-17 20:53:54 +00:00
|
|
|
Move-Item installer\windows_exporter-$MSIVersion-$Arch.msi output\
|
2021-12-29 09:00:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
promu checksum output\
|
|
|
|
|
2020-07-30 23:36:58 +00:00
|
|
|
- name: Login to GitHub container registry
|
2022-02-18 12:29:34 +00:00
|
|
|
if: ${{ github.event_name != 'pull_request' }}
|
2023-03-26 21:02:19 +00:00
|
|
|
uses: docker/login-action@v2
|
2020-07-30 23:36:58 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Push Latest image
|
|
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
2022-02-27 07:02:05 +00:00
|
|
|
$Env:VERSION = 'latest'
|
|
|
|
make push-all
|
2020-07-30 23:36:58 +00:00
|
|
|
|
2021-12-29 09:00:30 +00:00
|
|
|
- name: Release
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
|
|
|
$TagName = $env:GITHUB_REF -replace 'refs/tags/', ''
|
|
|
|
Get-ChildItem -Path output\* -Include @('windows_exporter*.msi', 'windows_exporter*.exe', 'sha256sums.txt') | Foreach-Object {gh release upload $TagName $_}
|
2020-07-30 23:36:58 +00:00
|
|
|
make push-all
|