-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·49 lines (39 loc) · 1.05 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.05 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
#!/bin/bash
set -e
# Configuration
BINARY_NAME="github.com/flinternet/flinternet"
MAIN_PATH="cmd/server/main.go"
OUTPUT_DIR="build"
# Platforms to build for (OS/ARCH)
PLATFORMS=(
"linux/amd64"
"linux/arm64"
"windows/amd64"
"darwin/amd64"
"darwin/arm64"
)
echo "Started building $BINARY_NAME..."
# Tidy dependencies
echo "Tidying dependencies..."
go mod tidy
# Create output directory
mkdir -p "$OUTPUT_DIR"
# Build for each platform
for PLATFORM in "${PLATFORMS[@]}"; do
OS="${PLATFORM%%/*}"
ARCH="${PLATFORM##*/}"
OUTPUT_NAME="$BINARY_NAME-$OS-$ARCH"
if [ "$OS" = "windows" ]; then
OUTPUT_NAME+=".exe"
fi
echo "Building for $OS/$ARCH..."
env GOOS=$OS GOARCH=$ARCH go build -trimpath -ldflags="-s -w" -o "$OUTPUT_DIR/$OUTPUT_NAME" "$MAIN_PATH"
if [ $? -eq 0 ]; then
echo "✓ Built $OUTPUT_DIR/$OUTPUT_NAME"
else
echo "✗ Failed to build for $OS/$ARCH"
exit 1
fi
done
echo "All builds complete! Artifacts are in the '$OUTPUT_DIR' directory."
ls -lh "$OUTPUT_DIR"