From 1d0abd358ebe3e71976ae9387515a577feea4983 Mon Sep 17 00:00:00 2001 From: Arkadiy Kukarkin Date: Mon, 13 Jul 2026 12:01:54 +0200 Subject: [PATCH 1/2] goreleaser: enable CGO cross-compile via zig cc; darwin on macos runner --- .github/workflows/release-binaries.yml | 34 ++++++++++++++++++++-- .goreleaser.darwin.yaml | 37 ++++++++++++++++++++++++ .goreleaser.yaml | 40 ++++++++++++++++++++------ 3 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 .goreleaser.darwin.yaml diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 13fbdc351..21c6109f1 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -8,8 +8,18 @@ on: types: [completed] jobs: bin-releaser: - name: Release Binaries - runs-on: ubuntu-latest + name: Release Binaries (${{ matrix.runner }}) + strategy: + fail-fast: false + matrix: + include: + - runner: ubuntu-latest + config: .goreleaser.yaml + needs_zig: true + - runner: macos-latest + config: .goreleaser.darwin.yaml + needs_zig: false + runs-on: ${{ matrix.runner }} steps: - name: Checkout uses: actions/checkout@v3 @@ -19,11 +29,29 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: 'go.mod' + # zig cc provides the C cross-toolchain for linux/windows targets so CGO deps + # (blst) compile. darwin cross doesn't work with zig -- macOS SDK headers + # aren't shipped -- so darwin runs on macos-latest with native clang. + # curl the tarball directly; mlugg/setup-zig@v1's mirror pool was 404/503-ing. + - name: Set up Zig + if: matrix.needs_zig + run: | + set -eu + ZV=0.14.1 + curl -sL https://ziglang.org/download/${ZV}/zig-x86_64-linux-${ZV}.tar.xz -o /tmp/zig.tar.xz + mkdir -p "$HOME/zig-${ZV}" + tar -xJf /tmp/zig.tar.xz -C "$HOME/zig-${ZV}" --strip-components=1 + echo "$HOME/zig-${ZV}" >> "$GITHUB_PATH" + "$HOME/zig-${ZV}/zig" version - name: Release Binaries uses: goreleaser/goreleaser-action@v4 with: distribution: goreleaser version: latest - args: ${{ github.event_name == 'pull_request' && 'release --snapshot --skip-publish' || 'release --clean' }} + # workflow_dispatch runs from a branch (no tag at HEAD); snapshot mode + # builds all targets without trying to publish, for CI iteration. + args: >- + release --clean --config ${{ matrix.config }} + ${{ github.event_name == 'workflow_dispatch' && '--snapshot' || '' }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.darwin.yaml b/.goreleaser.darwin.yaml new file mode 100644 index 000000000..e6316698e --- /dev/null +++ b/.goreleaser.darwin.yaml @@ -0,0 +1,37 @@ +version: 2 + +# darwin-only config; runs on macos-latest so native clang can find mach/mach_vm.h +# and other macOS SDK headers that the ubuntu+zig setup can't provide. +project_name: singularity + +builds: + - id: singularity-darwin + env: + - CGO_ENABLED=1 + binary: singularity + goos: + - darwin + goarch: + - amd64 + - arm64 + mod_timestamp: '{{.CommitTimestamp}}' + +archives: + - format_overrides: + - goos: darwin + formats: [zip] + name_template: '{{ .ProjectName }}_{{ .Version }}_mac_os_{{ .Arch }}' + files: + - LICENSE + - README.md + - docs/* + +release: + mode: keep-existing + +changelog: + disable: true + +checksum: + name_template: 'checksums-darwin.txt' + disable: false diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 743821238..4a7f67b51 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,28 +1,48 @@ version: 2 +# linux + windows only; darwin is built on a macos runner via .goreleaser.darwin.yaml +# because zig's shipped libc has no mach/mach_vm.h header (prometheus/client_golang +# CGO stub for macOS process metrics). native clang on macos-latest handles that. builds: - - env: - - CGO_ENABLED=0 + - id: singularity-nixwin + env: + - CGO_ENABLED=1 binary: singularity goos: - linux - windows - - darwin goarch: - amd64 - arm64 + overrides: + - goos: linux + goarch: amd64 + env: + - CC=zig cc -target x86_64-linux-gnu + - CXX=zig c++ -target x86_64-linux-gnu + - goos: linux + goarch: arm64 + env: + - CC=zig cc -target aarch64-linux-gnu + - CXX=zig c++ -target aarch64-linux-gnu + - goos: windows + goarch: amd64 + env: + - CC=zig cc -target x86_64-windows-gnu + - CXX=zig c++ -target x86_64-windows-gnu + - goos: windows + goarch: arm64 + env: + - CC=zig cc -target aarch64-windows-gnu + - CXX=zig c++ -target aarch64-windows-gnu mod_timestamp: '{{.CommitTimestamp}}' archives: - format_overrides: - goos: windows - format: zip - - goos: darwin - format: zip + formats: [zip] name_template: >- - {{ .ProjectName }}_{{ .Version }}_ - {{- if eq .Os "darwin" }}mac_os - {{- else }}{{ .Os }}{{ end }}_{{ .Arch }} + {{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }} files: - LICENSE - README.md @@ -34,7 +54,9 @@ release: changelog: disable: true +# separate checksums file per runner so ubuntu and macos don't overwrite each other checksum: + name_template: 'checksums-nixwin.txt' disable: false nfpms: From c5681ff152a76407d771da5bbeaef5c1df0c1502 Mon Sep 17 00:00:00 2001 From: Arkadiy Kukarkin Date: Mon, 13 Jul 2026 16:41:44 +0200 Subject: [PATCH 2/2] goreleaser: release for real, no snapshot --- .github/workflows/release-binaries.yml | 11 ++--------- .goreleaser.darwin.yaml | 2 -- .goreleaser.yaml | 4 ---- 3 files changed, 2 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 21c6109f1..16b21554a 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -29,10 +29,7 @@ jobs: uses: actions/setup-go@v5 with: go-version-file: 'go.mod' - # zig cc provides the C cross-toolchain for linux/windows targets so CGO deps - # (blst) compile. darwin cross doesn't work with zig -- macOS SDK headers - # aren't shipped -- so darwin runs on macos-latest with native clang. - # curl the tarball directly; mlugg/setup-zig@v1's mirror pool was 404/503-ing. + # curl zig directly; setup-zig actions have unreliable mirror pools - name: Set up Zig if: matrix.needs_zig run: | @@ -48,10 +45,6 @@ jobs: with: distribution: goreleaser version: latest - # workflow_dispatch runs from a branch (no tag at HEAD); snapshot mode - # builds all targets without trying to publish, for CI iteration. - args: >- - release --clean --config ${{ matrix.config }} - ${{ github.event_name == 'workflow_dispatch' && '--snapshot' || '' }} + args: release --clean --config ${{ matrix.config }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.darwin.yaml b/.goreleaser.darwin.yaml index e6316698e..83cb93f5b 100644 --- a/.goreleaser.darwin.yaml +++ b/.goreleaser.darwin.yaml @@ -1,7 +1,5 @@ version: 2 -# darwin-only config; runs on macos-latest so native clang can find mach/mach_vm.h -# and other macOS SDK headers that the ubuntu+zig setup can't provide. project_name: singularity builds: diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 4a7f67b51..5ad8a3ca6 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,8 +1,5 @@ version: 2 -# linux + windows only; darwin is built on a macos runner via .goreleaser.darwin.yaml -# because zig's shipped libc has no mach/mach_vm.h header (prometheus/client_golang -# CGO stub for macOS process metrics). native clang on macos-latest handles that. builds: - id: singularity-nixwin env: @@ -54,7 +51,6 @@ release: changelog: disable: true -# separate checksums file per runner so ubuntu and macos don't overwrite each other checksum: name_template: 'checksums-nixwin.txt' disable: false