From ad384fe7497cb4cd9cf4885b4f44f80ef111b60a Mon Sep 17 00:00:00 2001 From: Steve Cliff Date: Tue, 17 Feb 2026 08:19:17 +0000 Subject: [PATCH] Added support for multi-platform build and release --- .gitignore | 1 + build.sh | 22 +++++++++++++++++++--- release.sh | 5 ++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5a965f3..e1fad29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ # Binary /pcli +/pcli-* # IDE .idea/ diff --git a/build.sh b/build.sh index 47eca84..20cbff2 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,23 @@ #!/usr/bin/env bash set -euo pipefail -CGO_ENABLED=0 go build -ldflags='-s -w -extldflags "-static"' -o pcli . +LDFLAGS='-s -w' +TARGETS=( + "linux/amd64/pcli-linux-amd64" + "darwin/amd64/pcli-darwin-amd64" + "darwin/arm64/pcli-darwin-arm64" + "windows/amd64/pcli-windows-amd64.exe" +) -echo "Built: pcli" -file pcli +for target in "${TARGETS[@]}"; do + IFS='/' read -r os arch output <<< "$target" + echo "Building ${os}/${arch} -> ${output}" + CGO_ENABLED=0 GOOS="$os" GOARCH="$arch" go build -ldflags="$LDFLAGS" -o "$output" . +done + +# Symlink the linux binary as the default 'pcli' for local use +ln -sf pcli-linux-amd64 pcli + +echo "" +echo "Built all targets:" +ls -l pcli-* pcli.exe 2>/dev/null || true diff --git a/release.sh b/release.sh index faee351..2a99968 100755 --- a/release.sh +++ b/release.sh @@ -16,6 +16,9 @@ tea release create \ --note "Automated release for version $VERSION" \ --tag "$VERSION" \ --target "$(git rev-parse HEAD)" \ - --asset pcli + --asset pcli-linux-amd64 \ + --asset pcli-darwin-amd64 \ + --asset pcli-darwin-arm64 \ + --asset pcli-windows-amd64.exe echo "Release $VERSION created successfully!"