Skip to content

Commit

Permalink
Disable cgo by default (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: Mislav Marohnić <mislav@github.com>
  • Loading branch information
bewuethr and mislav committed Jan 26, 2023
1 parent a9d6d81 commit 5eff1a0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build_and_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 5eff1a0

Please sign in to comment.