-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathbuilds.sh
More file actions
executable file
·45 lines (38 loc) · 1.07 KB
/
Copy pathbuilds.sh
File metadata and controls
executable file
·45 lines (38 loc) · 1.07 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
#!/bin/bash
# Define your application name and main package path
APP_NAME="callfs"
PACKAGE_PATH="./cmd" # Main package is in cmd/main.go
# Define your target platforms (OS/ARCH)
PLATFORMS=(
"linux/amd64"
"linux/arm64"
"windows/amd64"
"darwin/amd64"
"darwin/arm64"
"freebsd/amd64"
"freebsd/arm64"
"openbsd/amd64"
"openbsd/arm64"
"netbsd/amd64"
"netbsd/arm64"
)
# Create a directory for the builds
BUILD_DIR="builds"
mkdir -p "$BUILD_DIR"
for platform in "${PLATFORMS[@]}"
do
# Split the platform string into OS and ARCH
IFS='/' read -r GOOS GOARCH <<< "$platform"
# Define the output name
OUTPUT_NAME="$BUILD_DIR/${APP_NAME}-${GOOS}-${GOARCH}"
if [ "$GOOS" = "windows" ]; then
OUTPUT_NAME+=".exe"
fi
echo "Building for $GOOS/$GOARCH..."
env GOOS="$GOOS" GOARCH="$GOARCH" go build -ldflags="-s -w" -o "$OUTPUT_NAME" "$PACKAGE_PATH"
if [ $? -ne 0 ]; then
echo "An error occurred while building for $GOOS/$GOARCH."
# Optionally exit on error: exit 1
fi
done
echo "All builds completed."