Skip to content

Commit

Permalink
fix: makefile variable override (#1482)
Browse files Browse the repository at this point in the history
  • Loading branch information
jkroepke authored May 12, 2024
1 parent 6e14d4e commit c99cf18
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 26 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
- name: Install Build deps
run: |
dotnet tool install --global GitVersion.Tool --version 5.*
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
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"
Expand All @@ -53,16 +52,14 @@ jobs:
run: |
$ErrorActionPreference = "Stop"
dotnet-gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
$Version = git describe --tag
$Version = $Version -replace 'v', ''
# '+' symbols are invalid characters in image tags
(Get-Content -Path VERSION) -replace '\+', '_' | Set-Content -Path VERSION
$Version = Get-Content VERSION
make crossbuild
$Version = $Version -replace '\+', '_'
$Version | Set-Content VERSION -PassThru
make build-all
# GH requires all files to have different names, so add version/arch to differentiate
foreach($Arch in "amd64", "arm64") {
Move-Item output\$Arch\windows_exporter.exe output\windows_exporter-$Version-$Arch.exe
Expand All @@ -79,11 +76,11 @@ jobs:
- name: Build Release Artifacts
run: |
$ErrorActionPreference = "Stop"
$BuildVersion = Get-Content VERSION
$Version = Get-Content VERSION
foreach($Arch in "amd64", "arm64") {
Write-Host "Building windows_exporter $BuildVersion msi for $Arch"
.\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$BuildVersion-$Arch.exe -Version $BuildVersion -Arch "$Arch"
Write-Host "Building windows_exporter $Version msi for $Arch"
.\installer\build.ps1 -PathToExecutable .\output\windows_exporter-$Version-$Arch.exe -Version $Version -Arch "$Arch"
}
Move-Item installer\*.msi output\
Expand Down Expand Up @@ -114,7 +111,7 @@ jobs:
uses: docker/login-action@v3
with:
registry: quay.io
username: '$token'
username: 'robot'
password: ${{ secrets.QUAY_IO_API_TOKEN }}

- name: Login to GitHub container registry
Expand Down
23 changes: 11 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
export GOOS=windows
export DOCKER_IMAGE_NAME ?= windows-exporter
GOOS ?= windows
VERSION ?= $(shell cat VERSION)
DOCKER ?= docker

# DOCKER_REPO is the official image repository name at docker.io, quay.io.
DOCKER_REPO:= prometheuscommunity
DOCKER_REPO ?= prometheuscommunity
DOCKER_IMAGE_NAME ?= windows-exporter

# ALL_DOCKER_REPOS is the list of repositories to push the image to. ghcr.io requires that org name be the same as the image repo name.
ALL_DOCKER_REPOS:=docker.io/$(DOCKER_REPO) quay.io/$(DOCKER_REPO) ghcr.io/prometheus-community
ALL_DOCKER_REPOS ?= docker.io/$(DOCKER_REPO) quay.io/$(DOCKER_REPO) ghcr.io/prometheus-community

VERSION?=$(shell cat VERSION)
DOCKER?=docker

# Image Variables for Hostprocess Container
# Image Variables for host process Container
# Windows image build is heavily influenced by https://github.com/kubernetes/kubernetes/blob/master/cluster/images/etcd/Makefile
OS=ltsc2019
ALL_OS:= ltsc2019 ltsc2022
BASE_IMAGE=mcr.microsoft.com/windows/nanoserver
BASE_HOST_PROCESS_IMAGE=mcr.microsoft.com/oss/kubernetes/windows-host-process-containers-base-image:v1.0.0
OS ?= ltsc2019
ALL_OS ?= ltsc2019 ltsc2022
BASE_IMAGE ?= mcr.microsoft.com/windows/nanoserver

.PHONY: build
build: generate windows_exporter.exe
Expand Down Expand Up @@ -79,6 +77,7 @@ push:
sub-push-%:
$(MAKE) DOCKER_REPO=$* push

.PHONY: push-all
push-all: build-all $(addprefix sub-push-,$(ALL_DOCKER_REPOS))

# Mandatory target for container description sync action
Expand Down
4 changes: 2 additions & 2 deletions installer/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Param (
$ErrorActionPreference = "Stop"

# The MSI version is not semver compliant, so just take the numerical parts
$Version = $Version -replace '^v?([0-9\.]+).*$','$1'
$MsiVersion = $Version -replace '^v?([0-9\.]+).*$','$1'

# Get absolute path to executable before switching directories
$PathToExecutable = Resolve-Path $PathToExecutable
Expand All @@ -28,7 +28,7 @@ Copy-Item -Force $PathToExecutable Work/windows_exporter.exe
Write-Verbose "Creating windows_exporter-${Version}-${Arch}.msi"
$wixArch = @{"amd64" = "x64"; "arm64" = "arm64"}[$Arch]

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"
Invoke-Expression "wix build -arch $wixArch -o .\windows_exporter-$($Version)-$($Arch).msi .\windows_exporter.wxs -d Version=$($MsiVersion) -ext WixToolset.Firewall.wixext -ext WixToolset.Util.wixext"

Write-Verbose "Done!"
Pop-Location

0 comments on commit c99cf18

Please sign in to comment.