From 5eff1a0e187503e04b6cf51da7691036bff2d210 Mon Sep 17 00:00:00 2001 From: Benjamin Wuethrich Date: Thu, 26 Jan 2023 11:42:15 -0500 Subject: [PATCH] Disable cgo by default (#31) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Mislav Marohnić --- README.md | 8 ++++++++ build_and_release.sh | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f753d36..138a66b 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,14 @@ When the `release` workflow finishes running, compiled binaries will be uploaded You can safely test out release automation by creating tags that have a `-` in them; for example: `v2.0.0-rc.1`. Such Releases will be published as _prereleases_ and will not count as a stable release of your extension. +To maximize portability of built products, this action builds Go binaries with [cgo](https://pkg.go.dev/cmd/cgo) disabled. To override that, set the `CGO_ENABLED` environment variable: + +```yaml +- uses: cli/gh-extension-precompile@v1 + env: + CGO_ENABLED: 1 +``` + ## Extensions written in other compiled languages If you aren't using Go for your compiled extension, you'll need to provide your own script for compiling your extension: diff --git a/build_and_release.sh b/build_and_release.sh index 0e3bb28..f360524 100755 --- a/build_and_release.sh +++ b/build_and_release.sh @@ -46,7 +46,7 @@ else if [ "$goos" = "windows" ]; then ext=".exe" fi - GOOS="$goos" GOARCH="$goarch" go build -trimpath -ldflags="-s -w" -o "dist/${p}${ext}" + GOOS="$goos" GOARCH="$goarch" CGO_ENABLED="${CGO_ENABLED:-0}" go build -trimpath -ldflags="-s -w" -o "dist/${p}${ext}" done fi