GameOver1337 / GitClone Public
К репозиторию
965 B
build.ps1
965 B
1# Build Clancore Repo binaries for Windows and Debian/Linux.
2# Usage: .\build.ps1
3$ErrorActionPreference = "Stop"
4
5$root = Split-Path -Parent $MyInvocation.MyCommand.Path
6Set-Location $root
7
8$dist = Join-Path $root "dist"
9New-Item -ItemType Directory -Force $dist | Out-Null
10
11$targets = @(
12 @{ GOOS = "windows"; GOARCH = "amd64"; Out = "clancore-repo-windows-amd64.exe" },
13 @{ GOOS = "linux"; GOARCH = "amd64"; Out = "clancore-repo-linux-amd64" }
14)
15
16foreach ($t in $targets) {
17 Write-Host "==> $($t.GOOS)/$($t.GOARCH)"
18 $env:CGO_ENABLED = "0"
19 $env:GOOS = $t.GOOS
20 $env:GOARCH = $t.GOARCH
21
22 go build -trimpath -ldflags "-s -w" -o (Join-Path $dist $t.Out) .
23 if ($LASTEXITCODE -ne 0) {
24 throw "Build failed for $($t.GOOS)/$($t.GOARCH)"
25 }
26}
27
28Remove-Item Env:CGO_ENABLED, Env:GOOS, Env:GOARCH -ErrorAction SilentlyContinue
29
30Write-Host ""
31Write-Host "Done:"
32Get-ChildItem $dist | Select-Object Name, Length | Format-Table -AutoSize