-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·51 lines (40 loc) · 1.12 KB
/
build.sh
File metadata and controls
executable file
·51 lines (40 loc) · 1.12 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
#!/bin/bash
# Create bin directory if it doesn't exist
mkdir -p bin
# Version - using current date in YYYY.MM.DD format
VERSION=$(date +"%Y.%m.%d")
# Platforms to build for
PLATFORMS=(
"linux/amd64"
"linux/386"
"linux/arm64"
"linux/arm"
"darwin/amd64"
"darwin/arm64"
)
# Build function
build() {
GOOS=$1
GOARCH=$2
output_name="massmap"
# Create final output name with version, os and arch
final_name="bin/massmap-${VERSION}-${GOOS}-${GOARCH}-${output_name}"
echo "Building for ${GOOS}/${GOARCH}..."
# Build with version information embedded
GOOS=$GOOS GOARCH=$GOARCH go build -o "${final_name}" -ldflags="-s -w -X main.Version=${VERSION}" ./cmd/massmap
if [ $? -ne 0 ]; then
echo "Build failed for ${GOOS}/${GOARCH}"
fi
}
# Clean bin directory
echo "Cleaning bin directory..."
rm -rf bin/*
# Build for each platform
for platform in "${PLATFORMS[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
build $GOOS $GOARCH
done
echo "Build complete! Binaries are available in the bin directory."