Change AppVeyor build to cross-compile instead of having two runs (#311)

This commit is contained in:
Calle Pettersson
2019-01-23 02:24:59 +01:00
committed by Martin Lindhe
parent 39b0000514
commit 35b81dcdd0
4 changed files with 76 additions and 51 deletions

1
.gitignore vendored
View File

@@ -2,3 +2,4 @@
VERSION VERSION
*.swp *.swp
*.un~ *.un~
output/

View File

@@ -12,3 +12,7 @@ build:
tarball: tarball:
files: files:
- LICENSE - LICENSE
crossbuild:
platforms:
- windows/amd64
- windows/386

View File

@@ -1,5 +1,16 @@
export GOOS=windows
fmt: fmt:
gofmt -l -w -s . gofmt -l -w -s .
build: build:
promu build -v promu build -v
test:
go test -v ./...
crossbuild:
# The prometheus/golang-builder image for promu crossbuild doesn't exist
# on Windows, so for now, we'll just build twice
GOARCH=amd64 promu build --prefix=output/amd64
GOARCH=386 promu build --prefix=output/386

View File

@@ -1,51 +1,60 @@
version: "{build}" version: "{build}"
os: Windows Server 2012 R2 os: Visual Studio 2017
build: off
environment: stack: go 1.10
GOPATH: c:\gopath
matrix: environment:
- MSI_ARCH: amd64 GOPATH: c:\gopath
GOARCH: amd64
- MSI_ARCH: 386 clone_folder: c:\gopath\src\github.com\martinlindhe\wmi_exporter
GOARCH: 386
install:
clone_folder: c:\gopath\src\github.com\martinlindhe\wmi_exporter - set PATH=%GOPATH%\bin;%PATH%
- go get -u github.com/prometheus/promu
install: - choco install gitversion.portable make -y
- go version
- set PATH=%GOPATH%\bin;c:\go\bin;%GOPATH%\bin\windows_%GOARCH%;%PATH% test_script:
- go get -u github.com/prometheus/promu - make test
- choco install gitversion.portable -y
build_script:
build_script: - ps: |
- ps: gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru $ErrorActionPreference = "Stop"
- go test -v ./... gitversion /output json /showvariable FullSemVer | Set-Content VERSION -PassThru
- promu build -v $Version = Get-Content VERSION
- ps: | make crossbuild
$ErrorActionPreference = "Stop" # GH requires all files to have different names, so add version/arch to differentiate
if($env:APPVEYOR_REPO_TAG -eq "True") { foreach($Arch in "amd64","386") {
# The MSI version is not semver compliant, so just take the numerical parts Rename-Item output\$Arch\wmi_exporter.exe -NewName wmi_exporter-$Version-$Arch.exe
$Version = $env:APPVEYOR_REPO_TAG_NAME -replace '^v?([0-9\.]+).*$','$1' }
Write-Verbose "Setting msi version to $Version"
.\installer\build.ps1 -PathToExecutable .\wmi_exporter.exe -Version $Version -Arch "$env:MSI_ARCH" after_build:
Push-AppveyorArtifact installer\Output\wmi_exporter-$Version-$env:MSI_ARCH.msi -DeploymentName Installer - ps: |
} # Build installer packages only on tagged releases
if($env:APPVEYOR_REPO_TAG -ne "True") {
after_build: return
- 7z a wmi_exporter-%MSI_ARCH%.zip wmi_exporter.exe }
$ErrorActionPreference = "Stop"
artifacts: # The MSI version is not semver compliant, so just take the numerical parts
- name: Executable $Version = $env:APPVEYOR_REPO_TAG_NAME -replace '^v?([0-9\.]+).*$','$1'
path: 'wmi_exporter-*.zip' foreach($Arch in "amd64","386") {
Write-Verbose "Building wmi_exporter $Version msi for $Arch"
deploy: .\installer\build.ps1 -PathToExecutable .\output\$Arch\wmi_exporter-$Version-$Arch.exe -Version $Version -Arch "$Arch"
- provider: GitHub Move-Item installer\Output\wmi_exporter-$Version-$Arch.msi output\$Arch\
description: WMI Exporter version $(appveyor_build_version) }
artifact: Executable,Installer - promu checksum output\
auth_token:
secure: 'CrXWeTf7qONUOEki5olFfGEUPMLDeHj61koDXV3OVEaLgtACmnVHsKUub9POflda' artifacts:
draft: false - name: Artifacts
prerelease: false path: output\**\*
on:
appveyor_repo_tag: true deploy:
- provider: GitHub
description: WMI Exporter version $(appveyor_build_version)
artifact: Artifacts
auth_token:
secure: 'CrXWeTf7qONUOEki5olFfGEUPMLDeHj61koDXV3OVEaLgtACmnVHsKUub9POflda'
draft: false
prerelease: false
on:
appveyor_repo_tag: true