forked from lkarlslund/Adalanche
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
39 lines (33 loc) · 1.21 KB
/
build.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
function BuildVariants {
param (
$ldflags,
$compileflags,
$prefix,
$suffix,
$arch,
$os,
$path
)
foreach ($currentarch in $arch) {
foreach ($currentos in $os) {
$env:GOARCH = $currentarch
$env:GOOS = $currentos
go build -ldflags "$ldflags" -o binaries/$prefix-$currentos-$currentarch-$VERSION$suffix.exe $compileflags $path
if (Get-Command "cyclonedx-gomod" -ErrorAction SilentlyContinue)
{
cyclonedx-gomod app -json -licenses -output binaries/$prefix-$currentos-$currentarch-$VERSION$suffix.bom.json -main $path .
}
}
}
}
Set-Location $PSScriptRoot
$COMMIT = git rev-parse --short HEAD
$VERSION = git describe --tags --exclude latest
$DIRTYFILES = git status --porcelain
if ("$DIRTYFILES" -ne "") {
$VERSION = "$VERSION-local-changes"
}
$LDFLAGS = "-X github.com/lkarlslund/adalanche/modules/version.Commit=$COMMIT -X github.com/lkarlslund/adalanche/modules/version.Version=$VERSION"
# Release
BuildVariants -ldflags "$LDFLAGS -s" -prefix adalanche-collector -path ./collector -arch @("386") -os @("windows")
BuildVariants -ldflags "$LDFLAGS -s" -prefix adalanche -path ./adalanche -arch @("amd64", "arm64") -os @("windows", "darwin", "linux")