forked from maximhq/bifrost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-cli-executables.sh
More file actions
executable file
·59 lines (44 loc) · 1.62 KB
/
Copy pathbuild-cli-executables.sh
File metadata and controls
executable file
·59 lines (44 loc) · 1.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
#!/usr/bin/env bash
set -euo pipefail
# Cross-compile CLI binaries for multiple platforms
# Usage: ./build-cli-executables.sh <version>
if [[ -z "${1:-}" ]]; then
echo "Usage: $0 <version>" >&2
exit 1
fi
VERSION="$1"
echo "🔨 Building CLI executables with version: $VERSION"
# Get the script directory and project root
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
# Clean and create dist directory
rm -rf "$PROJECT_ROOT/dist"
mkdir -p "$PROJECT_ROOT/dist"
# Define platforms
platforms=(
"darwin/amd64"
"darwin/arm64"
"linux/amd64"
"linux/arm64"
"windows/amd64"
)
MODULE_PATH="$PROJECT_ROOT/cli"
COMMIT="${GITHUB_SHA:-$(git rev-parse HEAD 2>/dev/null || echo 'unknown')}"
for platform in "${platforms[@]}"; do
IFS='/' read -r GOOS GOARCH <<< "$platform"
output_name="bifrost"
[[ "$GOOS" = "windows" ]] && output_name+='.exe'
echo "Building bifrost CLI for $GOOS/$GOARCH..."
mkdir -p "$PROJECT_ROOT/dist/$GOOS/$GOARCH"
cd "$MODULE_PATH"
# CLI has no CGO dependencies, so we can cross-compile without cross-compilers
env GOWORK=off CGO_ENABLED=0 GOOS="$GOOS" GOARCH="$GOARCH" \
go build -trimpath \
-ldflags "-s -w -buildid= -X main.version=v${VERSION} -X main.commit=${COMMIT}" \
-o "$PROJECT_ROOT/dist/$GOOS/$GOARCH/$output_name" .
# Generate SHA-256 checksum for the binary
(cd "$PROJECT_ROOT/dist/$GOOS/$GOARCH" && shasum -a 256 "$output_name" > "$output_name.sha256")
echo " → checksum: $(cat "$PROJECT_ROOT/dist/$GOOS/$GOARCH/$output_name.sha256")"
cd "$PROJECT_ROOT"
done
echo "✅ All CLI binaries built successfully"