From b1355c44a63ee25e0199c14105b9320a730b33f9 Mon Sep 17 00:00:00 2001 From: Daniel Grbac Bravo Date: Sat, 30 Mar 2024 17:02:13 +0100 Subject: [PATCH] build: added a build script --- build.sh | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 build.sh diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..7739a72 --- /dev/null +++ b/build.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Name of your project +PROJECT_NAME="chatterbox-cli" + +# Output name +OUTPUT_NAME="chatterbox" + +# Go path +GO_PATH=$(which go) + +# Platforms to build for +PLATFORMS=("darwin/amd64" "darwin/arm64" "windows/amd64" "linux/amd64") + +# Build directory +BUILD_DIR="./bin" + +# Create the build directory if it doesn't exist +mkdir -p $BUILD_DIR + +# Build for all platforms +for platform in "${PLATFORMS[@]}" +do + platform_split=(${platform//\// }) + GOOS=${platform_split[0]} + GOARCH=${platform_split[1]} + + output_name=$BUILD_DIR/$OUTPUT_NAME'-'$GOOS'-'$GOARCH + + if [ $GOOS = "windows" ]; then + output_name+='.exe' + fi + + env GOOS=$GOOS GOARCH=$GOARCH $GO_PATH build -o $output_name $PROJECT_NAME + + echo 'Built for '$platform +done