-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
45 lines (41 loc) · 1.08 KB
/
build.ps1
File metadata and controls
45 lines (41 loc) · 1.08 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
36
37
38
39
40
41
42
43
44
45
# Weather Widget Build Script for Windows
# Usage: .\build.ps1 [build|test|clean|vet]
param(
[Parameter(Position=0)]
[ValidateSet("build", "test", "clean", "vet")]
[string]$Target = "build"
)
$BinaryName = "weatherwidget.exe"
$CmdPath = "./cmd/weatherwidget/"
$LdFlags = "-H windowsgui -s -w"
$env:GOOS = "windows"
$env:GOARCH = "amd64"
switch ($Target) {
"build" {
Write-Host "Building $BinaryName..."
go build -ldflags="$LdFlags" -o $BinaryName $CmdPath
if ($LASTEXITCODE -eq 0) {
Write-Host "Build successful: $BinaryName"
} else {
Write-Host "Build failed" -ForegroundColor Red
exit 1
}
}
"test" {
Write-Host "Running tests..."
go test ./...
}
"clean" {
Write-Host "Cleaning build artifacts..."
if (Test-Path $BinaryName) {
Remove-Item $BinaryName
Write-Host "Removed $BinaryName"
} else {
Write-Host "Nothing to clean"
}
}
"vet" {
Write-Host "Running go vet..."
go vet ./...
}
}