-
Notifications
You must be signed in to change notification settings - Fork 40
/
build.ps1
58 lines (44 loc) · 1.27 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
param (
[string]
$BuildPath = ".\build",
[string[]]
$Architectures = @("amd64","386"),
[switch]
$Release = $false,
[string]
$ReleasePath = ".\release.zip"
)
# Cleanup
Remove-item -LiteralPath .\assets.go -ErrorAction SilentlyContinue
Remove-Item -LiteralPath $BuildPath -Force -Recurse -ErrorAction SilentlyContinue
# Build output directory
$outDir = New-Item -ItemType Directory -Path $BuildPath
$oldGOOS = $env:GOOS
$oldGOARCH = $env:GOARCH
$env:GOOS="windows"
$env:GOARCH=$null
$returnValue = 0
# Generate assets.go
go generate
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
# Build for each architecture
Foreach ($arch in $Architectures)
{
$env:GOARCH=$arch
go build -o $outDir\wsl-ssh-pageant-$arch.exe
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
go build -ldflags -H=windowsgui -o $outDir\wsl-ssh-pageant-$arch-gui.exe
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
}
# Build release package
if ($Release)
{
Copy-Item Readme.md $outDir
Copy-Item LICENSE $outDir
Remove-Item -LiteralPath $ReleasePath -ErrorAction SilentlyContinue
Compress-Archive -Path $outDir\* -DestinationPath $ReleasePath
}
# Restore env vars
$env:GOOS = $oldGOOS
$env:GOARCH = $oldGOARCH
exit $returnValue