Added support for multi-platform build and release
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# Binary
|
||||
/pcli
|
||||
/pcli-*
|
||||
|
||||
# IDE
|
||||
.idea/
|
||||
|
||||
@@ -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
|
||||
|
||||
+4
-1
@@ -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!"
|
||||
|
||||
Reference in New Issue
Block a user