From 7cc5e9e41a4ccd151da943d89f0ced1909f6faf6 Mon Sep 17 00:00:00 2001 From: Toby Date: Wed, 2 Nov 2022 20:08:04 +0000 Subject: [PATCH] chore: windows build script --- build.ps1 | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 build.ps1 diff --git a/build.ps1 b/build.ps1 new file mode 100644 index 0000000..dde7a87 --- /dev/null +++ b/build.ps1 @@ -0,0 +1,31 @@ +# Hysteria local build script for Windows (PowerShell) + +$platforms = @("windows/amd64", "linux/amd64", "darwin/amd64") +$ldflags = "-s -w" + +if (!(Get-Command go -ErrorAction SilentlyContinue)) { + Write-Host "Error: go is not installed." -ForegroundColor Red + exit 1 +} + +if (Test-Path build) { + Remove-Item -Recurse -Force build +} +New-Item -ItemType Directory -Force -Path build + +Write-Host "Starting build..." -ForegroundColor Green + +foreach ($platform in $platforms) { + $env:GOOS = $platform.Split("/")[0] + $env:GOARCH = $platform.Split("/")[1] + Write-Host "Building $env:GOOS/$env:GOARCH" -ForegroundColor Green + $output = "build/hysteria-$env:GOOS-$env:GOARCH" + if ($env:GOOS -eq "windows") { + $output = "$output.exe" + } + go build -o $output -ldflags $ldflags ./cmd/ +} + +Write-Host "Build complete." -ForegroundColor Green + +Get-ChildItem -Path build | Format-Table -AutoSize