From 320940f047e7df2bbd6b4f53a9ecca76c03c094f Mon Sep 17 00:00:00 2001 From: Jacob Bednarz Date: Tue, 27 Jun 2023 15:14:56 +1000 Subject: [PATCH] release: use osxcross for better cross compiling support Updates the release process to perform better cross compiling support and ultimately, set `CGO_ENABLED=1` in the releases. This does drop Windows and FreeBSD support however, I don't have a great testing story for them at the moment so we can revisit when/if the request arises. --- .github/workflows/release.yml | 4 ++++ .goreleaser.yml | 33 +++++++++++++++++++++++++++------ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5f7bfab..8fbeece 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,6 +20,10 @@ jobs: uses: actions/setup-go@v3 with: go-version: "1.20" + - name: OSXCross for CGO Support + run: | + mkdir ../../osxcross + git clone https://github.com/plentico/osxcross-target.git ../../osxcross/target - name: Run GoReleaser uses: goreleaser/goreleaser-action@v4 with: diff --git a/.goreleaser.yml b/.goreleaser.yml index 6a34f5e..c9111c3 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -1,7 +1,5 @@ builds: - - env: - - CGO_ENABLED=0 - mod_timestamp: '{{ .CommitTimestamp }}' + - id: linux-build flags: - -trimpath asmflags: @@ -10,16 +8,39 @@ builds: - all=-trimpath=$GOPATH ldflags: - -s -w -X github.com/jacobbednarz/cf-vault/cmd.Rev={{ .Version }} + env: + - CGO_ENABLED=1 goos: - - darwin - - freebsd - linux - - windows + ignore: + - goos: linux + goarch: "386" + - id: darwin-build + flags: + - -trimpath + asmflags: + - all=-trimpath=$GOPATH + gcflags: + - all=-trimpath=$GOPATH + ldflags: + - -s -w -X github.com/jacobbednarz/cf-vault/cmd.Rev={{ .Version }} + env: + - CGO_ENABLED=1 + - CC=/home/runner/work/osxcross/target/bin/o64-clang + - CXX=/home/runner/work/osxcross/target/bin/o64-clang++ + goos: + - darwin + ignore: + - goos: darwin + goarch: "386" + archives: - format: zip name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}' + checksum: name_template: '{{ .ProjectName }}_{{ .Version }}_SHA256SUMS' algorithm: sha256 + changelog: skip: true