#!/usr/bin/env pwsh # Cross-compile factory for all platforms (Windows-friendly) $ErrorActionPreference = "Stop" $VERSION = if ($env:VERSION) { $env:VERSION } else { "0.1.0" } $DIST_DIR = "dist" Push-Location (Split-Path $PSScriptRoot) Write-Host "Building factory v$VERSION..." New-Item -ItemType Directory -Force -Path $DIST_DIR | Out-Null $Targets = @( @{ Name = "linux-amd64"; GOOS = "linux"; GOARCH = "amd64" } @{ Name = "linux-arm64"; GOOS = "linux"; GOARCH = "arm64" } @{ Name = "windows-amd64"; GOOS = "windows"; GOARCH = "amd64" } @{ Name = "windows-arm64"; GOOS = "windows"; GOARCH = "arm64" } @{ Name = "darwin-amd64"; GOOS = "darwin"; GOARCH = "amd64" } @{ Name = "darwin-arm64"; GOOS = "darwin"; GOARCH = "arm64" } ) foreach ($t in $Targets) { $output = "$DIST_DIR/factory-$($t.GOOS)-$($t.GOARCH)" if ($t.GOOS -eq "windows") { $output += ".exe" } Write-Host " → $($t.Name)" $env:GOOS = $t.GOOS $env:GOARCH = $t.GOARCH $env:CGO_ENABLED = "0" go build -ldflags="-s -w -X main.Version=$VERSION" -o $output ./cmd/factory } Pop-Location Write-Host "`nāœ“ Built to $DIST_DIR/" Get-ChildItem $DIST_DIR | Format-Table Name, Length