cli / gh-extension-precompile

Action for publishing binary GitHub CLI extensions
MIT License
93 stars 41 forks source link

Disable cgo by default? #29

Closed bewuethr closed 1 year ago

bewuethr commented 1 year ago

When running this on an Ubuntu runner, the binaries for linux-amd64 use CGO_ENABLED=1:

https://github.com/cli/gh-extension-precompile/blob/ea409c0dc27ec3031d1b0d18d17124441d3c3b6b/build_and_release.sh#L49

builds without setting it, so (as far as I know) cgo is disabled for cross-compilation, but enabled when building for the target architecture of the runner.

As a result, if I use an ubuntu-22.04 runner, but then install the extension on an older Ubuntu such as 20.04, I get glibc.so mismatches like this:

/home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension)
/home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/benjamin/.local/share/gh/extensions/gh-myextension/gh-myextension)

This can be fixed by explicitly disabling cgo:

      - name: Publish CLI extension
        uses: cli/gh-extension-precompile@v1.2.4
        env:
          CGO_ENABLED: 0

Maybe this should be the default, or at least documented in the README?

mislav commented 1 year ago

Agreed about disabled being the default. We do it for the gh codebase: https://github.com/cli/cli/blob/1f85a92463d766c7ea6fa4fba2e7c08a37f5f5ab/.goreleaser.yml#L29

You're welcome to send a PR 👍