-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild-all.sh
executable file
·37 lines (28 loc) · 910 Bytes
/
build-all.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
#!/bin/bash
BINARY_NAME="lexido"
# Array of build targets
PLATFORMS=("darwin/amd64" "darwin/arm64" "linux/amd64" "linux/arm64")
# Clear previous builds
echo "Cleaning up previous builds..."
rm -rf build
mkdir build
# Loop through each platform and build
for platform in "${PLATFORMS[@]}"; do
# Splitting platform into OS and architecture
IFS='/' read -r -a os_arch <<< "$platform"
# Setting up environment variables
GOOS="${os_arch[0]}"
GOARCH="${os_arch[1]}"
OUTPUT="build/${BINARY_NAME}-${GOOS}-${GOARCH}"
if [ $GOOS = "windows" ]; then
OUTPUT+='.exe'
fi
echo "Building for $GOOS $GOARCH..."
env GOOS=$GOOS GOARCH=$GOARCH go build -ldflags "-w -s" -o $OUTPUT
# Check if build was successful
if [ $? -ne 0 ]; then
echo "An error has occurred! Aborting the script execution..."
exit 1
fi
done
echo "Build process completed."