forked from StackExchange/dnscontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.ps1
43 lines (33 loc) · 954 Bytes
/
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
40
41
42
43
param (
[string]$SHA = ""
)
if ($SHA -eq ""){
$SHA = (git rev-parse HEAD) | Out-String
$SHA = $SHA.Replace([System.Environment]::NewLine,"")
}
$PKG = "github.com/StackExchange/dnscontrol"
$DATE = [int][double]::Parse((Get-Date -UFormat %s))
$FLAGS="-mod=readonly -s -w -X main.SHA=$SHA -X main.BuildTime=$DATE"
Write-Host $FLAGS
$OrigGOOS = $env:GOOS
$env:GO111MODULE = "on"
Write-Host 'Building Linux'
$env:GOOS = "linux"
go build -o dnscontrol-Linux -ldflags "$FLAGS" $PKG
Write-Host 'Building Windows'
$env:GOOS = "windows"
go build -o dnscontrol.exe -ldflags "$FLAGS" $PKG
Write-Host 'Building Darwin'
$env:GOOS = "darwin"
go build -o dnscontrol-Darwin -ldflags "$FLAGS" $PKG
$env:GOOS = $OrigGOOS
#No compression if building on windows
<#
if [ "$COMPRESS" = "1" ]
then
echo 'Compressing executables'
upx dnscontrol.exe
upx dnscontrol-Linux
upx dnscontrol-Darwin
fi
#>