ente/cli/release.sh
Manav Rathi 2101d06d32 export CGO_ENABLED=0
The configuration used by goreleaser (which we previously used to build the
release binaries) had set CGO_ENABLED=0. Since we don't specifically need this
to be on, revert to that configuration.

Also add a few more go build flags to reduce the size of the produced binaries

Ref:
- https://github.com/wangyoucao577/go-release-action/issues/33
- https://github.com/wangyoucao577/go-release-action
- https://github.com/ente-io/cli/blob/main/.goreleaser.yaml#L18

Related:
- https://github.com/ente-io/ente/issues/727
2024-03-07 12:00:17 +05:30

40 lines
1.2 KiB
Bash
Executable file

#!/bin/bash
# Create a "bin" directory if it doesn't exist
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")
export CGO_ENABLED=0
# Loop through each OS target
for index in "${!OS_TARGETS[@]}"
do
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 and architecture
BINARY_NAME="ente-$OS-$ARCH"
# Add .exe extension for Windows
if [ "$OS" == "windows" ]; then
BINARY_NAME="ente-$OS-$ARCH.exe"
fi
# Build the binary and place it in the "bin" directory
go build -ldflags="-s -w" -trimpath -o "bin/$BINARY_NAME" main.go
# 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
# Print a message indicating the build process is complete
echo "Build process completed for all platforms and architectures. Binaries are in the 'bin' directory."