forked from sercanarga/ipmap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.ps1
More file actions
84 lines (74 loc) · 2.62 KB
/
build.ps1
File metadata and controls
84 lines (74 loc) · 2.62 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# ipmap Multi-Platform Build Script
# Builds for macOS (ARM64 + AMD64) and Linux (AMD64)
$VERSION = "2.4.1"
$APP_NAME = "ipmap"
$BUILD_DIR = "bin"
Write-Host "Building $APP_NAME v$VERSION for multiple platforms..." -ForegroundColor Cyan
Write-Host ""
# Create build directory
if (-not (Test-Path $BUILD_DIR)) {
New-Item -ItemType Directory -Path $BUILD_DIR | Out-Null
}
# Build for macOS ARM64
Write-Host "Building for macOS ARM64 (Apple Silicon)..." -ForegroundColor Yellow
$env:GOOS = "darwin"
$env:GOARCH = "arm64"
go build -o "$BUILD_DIR/${APP_NAME}_darwin_arm64" .
if ($LASTEXITCODE -eq 0) {
Write-Host "SUCCESS: macOS ARM64 build completed" -ForegroundColor Green
} else {
Write-Host "ERROR: macOS ARM64 build failed" -ForegroundColor Red
exit 1
}
Write-Host ""
# Build for macOS AMD64
Write-Host "Building for macOS AMD64 (Intel)..." -ForegroundColor Yellow
$env:GOOS = "darwin"
$env:GOARCH = "amd64"
go build -o "$BUILD_DIR/${APP_NAME}_darwin_amd64" .
if ($LASTEXITCODE -eq 0) {
Write-Host "SUCCESS: macOS AMD64 build completed" -ForegroundColor Green
} else {
Write-Host "ERROR: macOS AMD64 build failed" -ForegroundColor Red
exit 1
}
Write-Host ""
# Build for Linux AMD64
Write-Host "Building for Linux AMD64..." -ForegroundColor Yellow
$env:GOOS = "linux"
$env:GOARCH = "amd64"
go build -o "$BUILD_DIR/${APP_NAME}_linux_amd64" .
if ($LASTEXITCODE -eq 0) {
Write-Host "SUCCESS: Linux AMD64 build completed" -ForegroundColor Green
} else {
Write-Host "ERROR: Linux AMD64 build failed" -ForegroundColor Red
exit 1
}
Write-Host ""
# Build for Windows AMD64
Write-Host "Building for Windows AMD64..." -ForegroundColor Yellow
$env:GOOS = "windows"
$env:GOARCH = "amd64"
go build -o "$BUILD_DIR/${APP_NAME}_windows_amd64.exe" .
if ($LASTEXITCODE -eq 0) {
Write-Host "SUCCESS: Windows AMD64 build completed" -ForegroundColor Green
} else {
Write-Host "ERROR: Windows AMD64 build failed" -ForegroundColor Red
exit 1
}
Write-Host ""
# Show file sizes
Write-Host "Build Summary:" -ForegroundColor Cyan
Write-Host "================================================" -ForegroundColor Gray
Get-ChildItem -Path $BUILD_DIR | ForEach-Object {
$size = "{0:N2} MB" -f ($_.Length / 1MB)
Write-Host ("{0,-35} {1,10}" -f $_.Name, $size)
}
Write-Host "================================================" -ForegroundColor Gray
Write-Host ""
Write-Host "All builds completed successfully!" -ForegroundColor Green
Write-Host ""
Write-Host "Binaries location: $BUILD_DIR/" -ForegroundColor Cyan
# Reset environment variables
Remove-Item Env:\GOOS -ErrorAction SilentlyContinue
Remove-Item Env:\GOARCH -ErrorAction SilentlyContinue