-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.ps1
More file actions
34 lines (31 loc) · 944 Bytes
/
Copy pathbuild.ps1
File metadata and controls
34 lines (31 loc) · 944 Bytes
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
function BuildVariants {
param (
$ldflags,
$compileflags,
$prefix,
$suffix,
$arch,
$os,
$path
)
foreach ($currentarch in $arch) {
foreach ($currentos in $os) {
Write-Output "Building $currentarch for $currentos"
$env:GOARCH = $currentarch
$env:GOOS = $currentos
$outputfile = "binaries/$prefix-$currentos-$currentarch$suffix"
if ($currentos -eq "windows") {
$outputfile += ".exe"
}
$env:CGO_ENABLED = 0
go build -ldflags "$ldflags" -o $outputfile $compileflags $path
if (Get-Command "cyclonedx-gomod" -ErrorAction SilentlyContinue)
{
cyclonedx-gomod app -json -licenses -output $outputfile.bom.json -main $path .
}
}
}
}
Set-Location $PSScriptRoot
# Release
BuildVariants -ldflags "$LDFLAGS -s" -prefix fastsync -path cmd/* -arch @("386", "amd64", "arm64") -os @("linux", "openbsd", "darwin", "freebsd", "windows")