-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.ps1
More file actions
35 lines (32 loc) · 1.29 KB
/
build.ps1
File metadata and controls
35 lines (32 loc) · 1.29 KB
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
$GoTmp = "D:\tmp\gotmp"
if (-not (Test-Path $GoTmp)) { New-Item -ItemType Directory -Path $GoTmp -Force | Out-Null }
$env:GOTMPDIR = $GoTmp
$Version = git describe --tags --always --dirty 2>$null
if (-not $Version) { $Version = "dev" }
go build -ldflags "-X github.tools.sap/developer-relations/sap-devs-cli/cmd.Version=$Version" -o sap-devs.exe .
if ($LASTEXITCODE -eq 0) {
Write-Host "Build OK: sap-devs.exe ($Version)" -ForegroundColor Green
} else {
Write-Host "Build FAILED" -ForegroundColor Red
exit 1
}
if (Test-Path "cmd\sap-devs-tray\go.mod") {
# Copy cities.json for embedding in tray binary
$citiesSrc = "internal\geo\cities.json"
$citiesDst = "cmd\sap-devs-tray\data\cities.json"
if (Test-Path $citiesSrc) {
New-Item -ItemType Directory -Path (Split-Path $citiesDst) -Force | Out-Null
Copy-Item $citiesSrc $citiesDst -Force
}
$env:CGO_ENABLED = "1"
Push-Location cmd\sap-devs-tray
go build -ldflags "-X main.version=$Version" -o ..\..\sap-devs-tray.exe .
$rc = $LASTEXITCODE
Pop-Location
if ($rc -eq 0) {
Write-Host "Build OK: sap-devs-tray.exe ($Version)" -ForegroundColor Green
} else {
Write-Host "Build FAILED: sap-devs-tray.exe (CGO required — need gcc in PATH)" -ForegroundColor Red
exit 1
}
}