Skip to content

Commit

Permalink
Finished build script. Release 0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ndbeals committed Jul 22, 2020
1 parent 92cc9f6 commit 0eb9a34
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 2 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
*.out

# Dependency directories (remove the comment below to include it)
# vendor/
# vendor/

# Build artifacts
build/*
release/*
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ Please put report all


## Credits
Big thanks to https://github.com/benpye/wsl-ssh-pageant and the authors for the examples and help they have given me.
Big thanks to https://github.com/benpye/wsl-ssh-pageant and the authors for the examples of interacting with the win32 api, the build script, and help they have given me directly.
- https://github.com/buptczq/WinCryptSSHAgent for a working example of how to open a file mapping another process created.
61 changes: 61 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
param (
[string]
$BuildPath = ".\build",

[string[]]
$Architectures = @("amd64","386"),

[switch]
$Release = $false,

[string]
$ReleasePath = "winssh-pageant"
)

# Cleanup
Remove-Item -LiteralPath $BuildPath -Force -Recurse -ErrorAction SilentlyContinue

# Build output directory
$outDir = New-Item -ItemType Directory -Path $BuildPath
$releaseDir = New-Item -ItemType Directory -Path ".\release"

$oldGOOS = $env:GOOS
$oldGOARCH = $env:GOARCH

$env:GOOS="windows"
$env:GOARCH=$null

$returnValue = 0

# Build release package
if ($Release)
{
Copy-Item Readme.md $outDir
Copy-Item LICENSE $outDir

Remove-Item -LiteralPath $ReleasePath -ErrorAction SilentlyContinue
}
# Build for each architecture
Foreach ($arch in $Architectures)
{
$env:GOARCH=$arch

if ($Release)
{
go build -ldflags -H=windowsgui -o $outDir\winssh-pageant.exe
if ($LastExitCode -ne 0) { $returnValue = $LastExitCode }
# Remove-Item -LiteralPath $ReleasePath -ErrorAction SilentlyContinue
Compress-Archive -Path $outDir\* -DestinationPath $releaseDir\$ReleasePath-$arch.zip -Force

Remove-Item -LiteralPath $outDir\winssh-pageant.exe
} else {
go build -ldflags -H=windowsgui -o $outDir\winssh-pageant-$arch.exe
}
}


# Restore env vars
$env:GOOS = $oldGOOS
$env:GOARCH = $oldGOARCH

exit $returnValue

0 comments on commit 0eb9a34

Please sign in to comment.