From 7774dc29d1219f2e61aa63270fadc0cbef39623c Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Fri, 29 May 2026 00:57:29 +0100 Subject: [PATCH] fix(release): partition CGO split builds by target to stop cross-arch failure GoReleaser Pro --split defaults to partitioning by GOOS only, so each linux matrix runner built both linux/amd64 and linux/arm64. With CGO_ENABLED=1 (go-tree-sitter), the native gcc cannot assemble the other arch's CGO runtime (gcc_arm64.S: no such instruction), failing the build. - .goreleaser.yaml: set partial.by=target (partition by GOOS+GOARCH) - workflow-prepare.sh: export GGOOS/GGOARCH from the matrix TARGET_* vars so each native runner builds exactly its own target GGOOS/GGOARCH are filter-only and do not bleed into before-hooks, unlike GOOS/GOARCH. --- .goreleaser.yaml | 9 +++++++++ workflow-prepare.sh | 20 ++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100755 workflow-prepare.sh diff --git a/.goreleaser.yaml b/.goreleaser.yaml index a3bade7..02d8699 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -5,6 +5,15 @@ version: 2 project_name: mcp-filepuff +# Split CGO builds by full target (GOOS+GOARCH), not just GOOS. +# Each release matrix runner builds natively for exactly one target via the +# GGOOS/GGOARCH filters set in workflow-prepare.sh. Without `by: target` the +# split partitions by GOOS only, so a single linux runner would try to build +# both amd64 and arm64 — and native gcc cannot assemble the other arch's CGO +# runtime (gcc_arm64.S errors), breaking the release. +partial: + by: target + before: hooks: - go mod tidy diff --git a/workflow-prepare.sh b/workflow-prepare.sh new file mode 100755 index 0000000..4b74acd --- /dev/null +++ b/workflow-prepare.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +# Invoked by lukaszraczylo/shared-actions go-release-cgo.yaml before GoReleaser, +# with TARGET_GOOS/TARGET_GOARCH set from the build matrix entry. +# +# GoReleaser Pro `release --split` partitions builds across matrix runners. +# Its default partition is by GOOS only, so every linux runner would build +# BOTH linux/amd64 and linux/arm64. With CGO_ENABLED=1 (go-tree-sitter needs +# CGO) the native gcc on one runner cannot assemble the other arch's CGO +# runtime (`gcc_arm64.S: no such instruction`), failing the release. +# +# Exporting GGOOS/GGOARCH restricts each runner to its own target. These are +# filter-only vars (unlike GOOS/GOARCH, which bleed into before-hooks such as +# `go run`/`go generate`) and require `partial.by: target` in .goreleaser.yaml. +set -euo pipefail + +if [ -n "${GITHUB_ENV:-}" ] && [ -n "${TARGET_GOOS:-}" ] && [ -n "${TARGET_GOARCH:-}" ]; then + echo "GGOOS=${TARGET_GOOS}" >>"${GITHUB_ENV}" + echo "GGOARCH=${TARGET_GOARCH}" >>"${GITHUB_ENV}" + echo "Pinned GoReleaser split target: GGOOS=${TARGET_GOOS} GGOARCH=${TARGET_GOARCH}" +fi