-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·51 lines (38 loc) · 1.15 KB
/
build.sh
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
# Define the program name and version
PROGRAM_NAME="subs"
VERSION="1.0.0"
# Define the operating systems and architectures you want to build for
OS_ARCH_LIST=(
"linux/amd64"
"linux/arm64"
"linux/386"
"darwin/amd64"
"darwin/arm64"
"windows/amd64"
"windows/386"
)
# Create an output directory for the binaries
OUTPUT_DIR=".build/binaries/"
rm -rf $OUTPUT_DIR
rm $PROGRAM_NAME
mkdir -p "$OUTPUT_DIR"
# Iterate over each OS/Arch combination and build the binary
for OS_ARCH in "${OS_ARCH_LIST[@]}"; do
IFS="/" read -r OS ARCH <<< "$OS_ARCH"
# Set the output binary name and path
BINARY_NAME="${PROGRAM_NAME}-${VERSION}-${OS}-${ARCH}"
# Add .exe extension for Windows binaries
if [ "$OS" = "windows" ]; then
BINARY_NAME="${BINARY_NAME}.exe"
fi
OUTPUT_PATH="${OUTPUT_DIR}/${BINARY_NAME}"
# Set the environment variables and build the binary
echo "Building for $OS/$ARCH..."
env GOOS="$OS" GOARCH="$ARCH" go build -o "$OUTPUT_PATH"
if [ $? -ne 0 ]; then
echo "Failed to build for $OS/$ARCH"
exit 1
fi
done
echo "All binaries built successfully!"