-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·59 lines (46 loc) · 1.38 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
52
53
54
55
56
57
58
59
#!/bin/bash
# Set the name of your application
APP_NAME="gottem"
# Set the version number
VERSION="1.0.0"
# Set the architectures to build for
ARCHITECTURES=("amd64" "386")
# Set the operating systems to build for
OPERATING_SYSTEMS=("linux" "darwin" "windows") # "darwin" represents macOS
# Set the path to your Go project directory
PROJECT_DIR="/Users/siddharthjain/Desktop/code/utility-gods/gottem"
# Function to build and package the application
build_and_package() {
OS=$1
ARCH=$2
# Set the output binary name
BINARY_NAME="${APP_NAME}-${OS}-${ARCH}"
if [ "$OS" == "windows" ]; then
BINARY_NAME="${BINARY_NAME}.exe"
fi
# Build the application
echo "Building ${BINARY_NAME}..."
GOOS=$OS GOARCH=$ARCH go build -o "build/$BINARY_NAME" "$PROJECT_DIR"
# Compress the binary
echo "Packaging ${BINARY_NAME}..."
cd build
if [ "$OS" == "windows" ]; then
zip "${BINARY_NAME}-${VERSION}.zip" $BINARY_NAME
else
tar -czf "${BINARY_NAME}-${VERSION}.tar.gz" $BINARY_NAME
fi
# Remove the binary
rm $BINARY_NAME
cd ..
}
# Create a build directory
mkdir -p build
# Iterate over the operating systems and architectures and build the application
for OS in "${OPERATING_SYSTEMS[@]}"
do
for ARCH in "${ARCHITECTURES[@]}"
do
build_and_package $OS $ARCH
done
done
echo "Build and packaging completed."