Skip to content

Commit 5eff1a0

Browse files
bewuethrmislav
andauthored
Disable cgo by default (#31)
Co-authored-by: Mislav Marohnić <mislav@github.com>
1 parent a9d6d81 commit 5eff1a0

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ When the `release` workflow finishes running, compiled binaries will be uploaded
3333

3434
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.
3535

36+
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:
37+
38+
```yaml
39+
- uses: cli/gh-extension-precompile@v1
40+
env:
41+
CGO_ENABLED: 1
42+
```
43+
3644
## Extensions written in other compiled languages
3745

3846
If you aren't using Go for your compiled extension, you'll need to provide your own script for compiling your extension:

build_and_release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ else
4646
if [ "$goos" = "windows" ]; then
4747
ext=".exe"
4848
fi
49-
GOOS="$goos" GOARCH="$goarch" go build -trimpath -ldflags="-s -w" -o "dist/${p}${ext}"
49+
GOOS="$goos" GOARCH="$goarch" CGO_ENABLED="${CGO_ENABLED:-0}" go build -trimpath -ldflags="-s -w" -o "dist/${p}${ext}"
5050
done
5151
fi
5252

0 commit comments

Comments
 (0)