mirror of
https://github.com/prometheus-community/windows_exporter
synced 2025-01-04 05:22:10 +00:00
20d7048478
checkout@v2 and go-setup@v2 both used a deprecated Node.js version (12) See https://github.blog/changelog/2022-09-22-github-actions-all-actions-will-begin-running-on-node16-instead-of-node12/ for context Signed-off-by: Ben Reedy <breed808@breed808.com>
107 lines
4.1 KiB
YAML
107 lines
4.1 KiB
YAML
name: Releases
|
|
|
|
# Trigger on releases.
|
|
on:
|
|
release:
|
|
types:
|
|
- published
|
|
- edited
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
env:
|
|
PROMU_VER: '0.13.0'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: windows-2022
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
# fetch-depth required for gitversion in `Build` step
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-go@v3
|
|
with:
|
|
go-version: '^1.17.5'
|
|
|
|
- name: Install Build deps
|
|
run: |
|
|
dotnet tool install --global GitVersion.Tool --version 5.*
|
|
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/$($Env:PROMU_VER)/promu-v$($Env:PROMU_VER).windows-amd64.zip -OutFile promu-$($Env:PROMU_VER).windows-amd64.zip
|
|
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
|
|
go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@v1.4.0
|
|
# 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"
|
|
|
|
dotnet-gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
|
|
$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
|
|
# '+' symbols are invalid characters in image tags
|
|
(Get-Content -Path VERSION) -replace '\+', '_' | Set-Content -Path VERSION
|
|
make build-all
|
|
# GH requires all files to have different names, so add version/arch to differentiate
|
|
foreach($Arch in "amd64", "arm64","386") {
|
|
Move-Item output\$Arch\windows_exporter.exe output\windows_exporter-$Version-$Arch.exe
|
|
}
|
|
|
|
- name: Upload Artifacts
|
|
uses: actions/upload-artifact@v2
|
|
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'
|
|
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\
|
|
}
|
|
|
|
promu checksum output\
|
|
|
|
- name: Login to GitHub container registry
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
uses: docker/login-action@v1
|
|
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: |
|
|
$Env:VERSION = 'latest'
|
|
make push-all
|
|
|
|
- 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 $_}
|
|
make push-all
|