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:
|
2024-05-11 21:06:22 +00:00
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
pull_request:
|
2024-11-14 19:01:15 +00:00
|
|
|
workflow_dispatch:
|
2021-12-29 09:00:30 +00:00
|
|
|
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:
|
2024-11-14 19:01:15 +00:00
|
|
|
VERSION_PROMU: '0.17.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:
|
2024-05-09 13:32:26 +00:00
|
|
|
- uses: actions/checkout@v4
|
2024-09-12 13:02:21 +00:00
|
|
|
with:
|
|
|
|
fetch-depth: '0'
|
|
|
|
|
2024-05-09 13:32:26 +00:00
|
|
|
- uses: actions/setup-go@v5
|
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
|
2024-09-06 20:29:50 +00:00
|
|
|
wix extension add -g WixToolset.Ui.wixext
|
2023-11-17 20:53:54 +00:00
|
|
|
wix extension add -g WixToolset.Firewall.wixext
|
|
|
|
|
2021-12-29 09:00:30 +00:00
|
|
|
- name: Install Build deps
|
|
|
|
run: |
|
2024-09-07 18:26:22 +00:00
|
|
|
Invoke-WebRequest -Uri https://github.com/prometheus/promu/releases/download/v$($Env:VERSION_PROMU)/promu-$($Env:VERSION_PROMU).windows-amd64.zip -OutFile promu-$($Env:VERSION_PROMU).windows-amd64.zip
|
|
|
|
Expand-Archive -Path promu-$($Env:VERSION_PROMU).windows-amd64.zip -DestinationPath .
|
|
|
|
Copy-Item -Path promu-$($Env:VERSION_PROMU).windows-amd64\promu.exe -Destination "$(go env GOPATH)\bin"
|
2023-01-01 22:35:14 +00:00
|
|
|
|
2024-05-07 11:23:43 +00:00
|
|
|
# GOPATH\bin dir must be added to PATH else the `promu` commands won't be found
|
2021-12-29 09:00:30 +00:00
|
|
|
echo "$(go env GOPATH)\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
|
|
|
|
|
|
|
- name: Build
|
|
|
|
run: |
|
|
|
|
$ErrorActionPreference = "Stop"
|
2024-10-05 19:33:40 +00:00
|
|
|
|
2024-08-11 11:28:39 +00:00
|
|
|
$Version = git describe --tags --always
|
2024-05-12 10:25:06 +00:00
|
|
|
$Version = $Version -replace 'v', ''
|
2024-05-11 23:46:05 +00:00
|
|
|
# '+' symbols are invalid characters in image tags
|
2024-05-12 10:25:06 +00:00
|
|
|
$Version = $Version -replace '\+', '_'
|
|
|
|
$Version | Set-Content VERSION -PassThru
|
2024-10-05 19:33:40 +00:00
|
|
|
|
2020-07-30 23:36:58 +00:00
|
|
|
make build-all
|
2024-10-05 19:33:40 +00:00
|
|
|
|
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
|
|
|
|
}
|
2024-10-05 19:33:40 +00:00
|
|
|
|
2024-05-12 08:04:33 +00:00
|
|
|
Get-ChildItem -Path output
|
2021-12-29 09:00:30 +00:00
|
|
|
|
|
|
|
- name: Build Release Artifacts
|
|
|
|
run: |
|
|
|
|
$ErrorActionPreference = "Stop"
|
2024-05-12 10:25:06 +00:00
|
|
|
$Version = Get-Content VERSION
|
2024-10-05 19:33:40 +00:00
|
|
|
|
2024-01-08 18:59:15 +00:00
|
|
|
foreach($Arch in "amd64", "arm64") {
|
2024-05-12 10:25:06 +00:00
|
|
|
Write-Host "Building windows_exporter $Version msi for $Arch"
|
|
|
|
.\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$Version-$Arch.exe -Version $Version -Arch "$Arch"
|
2021-12-29 09:00:30 +00:00
|
|
|
}
|
2024-10-05 19:33:40 +00:00
|
|
|
|
2024-05-12 08:04:33 +00:00
|
|
|
Move-Item installer\*.msi output\
|
|
|
|
Get-ChildItem -Path output\
|
2021-12-29 09:00:30 +00:00
|
|
|
|
|
|
|
promu checksum output\
|
|
|
|
|
2024-09-12 13:02:21 +00:00
|
|
|
- name: Upload Artifacts
|
|
|
|
uses: actions/upload-artifact@v4
|
|
|
|
with:
|
|
|
|
name: windows_exporter_binaries
|
|
|
|
path: |
|
|
|
|
output\windows_exporter-*.exe
|
|
|
|
output\windows_exporter-*.msi
|
|
|
|
|
2024-11-14 19:01:15 +00:00
|
|
|
- name: Release
|
|
|
|
if: startsWith(github.ref, 'refs/tags/')
|
2024-05-11 21:06:22 +00:00
|
|
|
env:
|
2024-11-14 19:01:15 +00:00
|
|
|
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 $_}
|
|
|
|
docker:
|
|
|
|
name: Build docker images
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs:
|
|
|
|
- build
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
fetch-depth: '0'
|
|
|
|
|
|
|
|
- name: Download Artifacts
|
|
|
|
uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
name: windows_exporter_binaries
|
2024-05-11 21:06:22 +00:00
|
|
|
|
|
|
|
- name: Login to Docker Hub
|
|
|
|
if: ${{ github.event_name != 'pull_request' }}
|
|
|
|
uses: docker/login-action@v3
|
|
|
|
with:
|
|
|
|
username: ${{ secrets.DOCKER_HUB_LOGIN }}
|
|
|
|
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
|
|
|
|
|
2024-11-14 19:14:30 +00:00
|
|
|
#- name: Login to quay.io
|
|
|
|
# if: ${{ github.event_name != 'pull_request' }}
|
|
|
|
# uses: docker/login-action@v3
|
|
|
|
# with:
|
|
|
|
# registry: quay.io
|
|
|
|
# username: ${{ secrets.QUAY_USER }}
|
|
|
|
# password: ${{ secrets.QUAY_PASS }}
|
2024-05-11 21:06:22 +00:00
|
|
|
|
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' }}
|
2024-05-09 13:32:26 +00:00
|
|
|
uses: docker/login-action@v3
|
2020-07-30 23:36:58 +00:00
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.repository_owner }}
|
|
|
|
password: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
2024-11-14 19:01:15 +00:00
|
|
|
- name: Docker meta
|
|
|
|
id: meta
|
|
|
|
uses: docker/metadata-action@v5
|
|
|
|
with:
|
|
|
|
images: |
|
|
|
|
ghcr.io/prometheus-community/windows-exporter
|
|
|
|
docker.io/prometheuscommunity/windows-exporter
|
2024-11-14 19:14:30 +00:00
|
|
|
# quay.io/prometheuscommunity/windows-exporter
|
2024-11-14 19:01:15 +00:00
|
|
|
tags: |
|
|
|
|
type=semver,pattern={{version}}
|
|
|
|
type=ref,event=branch
|
|
|
|
type=ref,event=pr
|
|
|
|
labels: |
|
|
|
|
org.opencontainers.image.title=windows_exporter
|
|
|
|
org.opencontainers.image.description=A Prometheus exporter for Windows machines.
|
|
|
|
org.opencontainers.image.vendor=The Prometheus Community
|
|
|
|
org.opencontainers.image.licenses=MIT
|
|
|
|
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
|
|
|
|
- name: Build and push
|
|
|
|
uses: docker/build-push-action@v6
|
|
|
|
with:
|
|
|
|
context: .
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
|
|
platforms: windows/amd64
|