From 2ffeda16c80fbc069a4de714fada52629df68d99 Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:56:13 +0530 Subject: [PATCH] Release: Build binary for all standard os+arch --- release.sh | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/release.sh b/release.sh index fb74e3731..7c5047385 100755 --- a/release.sh +++ b/release.sh @@ -6,40 +6,38 @@ mkdir -p bin # List of target operating systems OS_TARGETS=("windows" "linux" "darwin") +# Corresponding architectures for each OS +ARCH_TARGETS=("386 amd64" "386 amd64 arm arm64" "amd64 arm64") + # Loop through each OS target -for OS in "${OS_TARGETS[@]}" +for index in "${!OS_TARGETS[@]}" do - # Set the GOOS environment variable for the current target OS - export GOOS="$OS" + OS=${OS_TARGETS[$index]} + for ARCH in ${ARCH_TARGETS[$index]} + do + # Set the GOOS environment variable for the current target OS + export GOOS="$OS" + export GOARCH="$ARCH" - # Set the output binary name to "ente-cli" for the current OS - BINARY_NAME="ente-cli" - - # Add .exe extension for Windows - if [ "$OS" == "windows" ]; then - BINARY_NAME="ente-cli.exe" - fi + # Set the output binary name to "ente-cli" for the current OS and architecture + BINARY_NAME="ente-cli-$OS-$ARCH" # Add .exe extension for Windows - if [ "$OS" == "darwin" ]; then - BINARY_NAME="ente-cli-mac" - fi + if [ "$OS" == "windows" ]; then + BINARY_NAME="ente-cli-$OS-$ARCH.exe" + fi - if [ "$OS" == "linux" ]; then - BINARY_NAME="ente-cli-linux" - fi - # make bin directory if it doesn't exist - mkdir -p bin + # Build the binary and place it in the "bin" directory + go build -o "bin/$BINARY_NAME" main.go - # Build the binary and place it in the "bin" directory - go build -o "bin/$BINARY_NAME" main.go - - # Print a message indicating the build is complete for the current OS - echo "Built for $OS as bin/$BINARY_NAME" + # Print a message indicating the build is complete for the current OS and architecture + echo "Built for $OS ($ARCH) as bin/$BINARY_NAME" + done done # Clean up any environment variables unset GOOS +unset GOARCH # Print a message indicating the build process is complete -echo "Build process completed for all platforms. Binaries are in the 'bin' directory." +echo "Build process completed for all platforms and architectures. Binaries are in the 'bin' directory."