From 2101d06d3258955b58f6a7685092137d6e113966 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Thu, 7 Mar 2024 11:56:54 +0530 Subject: [PATCH] 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 --- .github/workflows/cli-release.yml | 3 +++ cli/release.sh | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/cli-release.yml b/.github/workflows/cli-release.yml index dabfc8dcf..1efa805d4 100644 --- a/.github/workflows/cli-release.yml +++ b/.github/workflows/cli-release.yml @@ -47,5 +47,8 @@ jobs: release_name: ${{ github.ref_name }} goversion: "1.20" project_path: "./cli" + pre_command: export CGO_ENABLED=0 + build_flags: "-trimpath" + ldflags: "-s -w" md5sum: false sha256sum: true diff --git a/cli/release.sh b/cli/release.sh index a2d0a0be5..ac0106bd0 100755 --- a/cli/release.sh +++ b/cli/release.sh @@ -9,6 +9,7 @@ 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 @@ -28,7 +29,7 @@ do fi # Build the binary and place it in the "bin" directory - go build -o "bin/$BINARY_NAME" main.go + 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"