Skip to content

Commit 68a3640

Browse files
committed
Add build & release script
1 parent 2ec20bc commit 68a3640

File tree

4 files changed

+65
-0
lines changed

4 files changed

+65
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@
1616

1717
# Generated file
1818
assets.go
19+
20+
# Build artifacts
21+
build/*
22+
release.zip

build.ps1

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
param (
2+
[string]
3+
$BuildPath = ".\build",
4+
5+
[string[]]
6+
$Architectures = @("amd64","386"),
7+
8+
[switch]
9+
$Release = $false,
10+
11+
[string]
12+
$ReleasePath = ".\release.zip"
13+
)
14+
15+
# Cleanup
16+
Remove-item -LiteralPath .\assets.go -ErrorAction SilentlyContinue
17+
Remove-Item -LiteralPath $BuildPath -Force -Recurse -ErrorAction SilentlyContinue
18+
19+
# Build output directory
20+
$outDir = New-Item -ItemType Directory -Path $BuildPath
21+
22+
$oldGOOS = $env:GOOS
23+
$oldGOARCH = $env:GOARCH
24+
25+
$env:GOOS="windows"
26+
$env:GOARCH=$null
27+
28+
$returnValue = 0
29+
30+
# Generate assets.go
31+
go generate
32+
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
33+
34+
# Build for each architecture
35+
Foreach ($arch in $Architectures)
36+
{
37+
$env:GOARCH=$arch
38+
go build -o $outDir\wsl-ssh-pageant-$arch.exe
39+
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
40+
go build -ldflags -H=windowsgui -o $outDir\wsl-ssh-pageant-$arch-gui.exe
41+
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
42+
}
43+
44+
# Build release package
45+
if ($Release)
46+
{
47+
Copy-Item Readme.md $outDir
48+
Copy-Item LICENSE $outDir
49+
50+
Remove-Item -LiteralPath $ReleasePath -ErrorAction SilentlyContinue
51+
Compress-Archive -Path $outDir\* -DestinationPath $ReleasePath
52+
}
53+
54+
# Restore env vars
55+
$env:GOOS = $oldGOOS
56+
$env:GOARCH = $oldGOARCH
57+
58+
exit $returnValue

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ require (
1212
github.com/getlantern/hidden v0.0.0-20190325191715-f02dbb02be55 // indirect
1313
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f // indirect
1414
github.com/getlantern/systray v0.0.0-20190131073753-26d5b920200d
15+
github.com/go-bindata/go-bindata v3.1.1+incompatible // indirect
1516
github.com/go-stack/stack v1.8.0 // indirect
1617
github.com/lxn/win v0.0.0-20181015143721-a7f87360b10e
1718
github.com/oxtoacart/bpool v0.0.0-20190227141107-8c4636f812cc // indirect

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f h1:wrYrQttPS8FHIRSl
2020
github.com/getlantern/ops v0.0.0-20190325191751-d70cb0d6f85f/go.mod h1:D5ao98qkA6pxftxoqzibIBBrLSUli+kYnJqrgBf9cIA=
2121
github.com/getlantern/systray v0.0.0-20190131073753-26d5b920200d h1:4P2eDMAoQcQoWIIKCNIkuVbQb+paRmpMxVXVfbs7B4U=
2222
github.com/getlantern/systray v0.0.0-20190131073753-26d5b920200d/go.mod h1:7Splj4WBQSps8jODnMgrIV6goKL0N1HR+mhCAEVWlA0=
23+
github.com/go-bindata/go-bindata v3.1.1+incompatible h1:tR4f0e4VTO7LK6B2YWyAoVEzG9ByG1wrXB4TL9+jiYg=
24+
github.com/go-bindata/go-bindata v3.1.1+incompatible/go.mod h1:xK8Dsgwmeed+BBsSy2XTopBn/8uK2HWuGSnA11C3Joo=
2325
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
2426
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
2527
github.com/lxn/win v0.0.0-20181015143721-a7f87360b10e h1:dz4TzIsrPe4XtUyhLkOLdCS8UkVwJKQu4WY8VcIwo3I=

0 commit comments

Comments
 (0)