@@ -40,13 +40,18 @@
# zig cc also cross-links amd64, so no separate gnu cross-compiler is needed.
# Pinned, mutually-compatible pair (cargo-zigbuild is sensitive to the zig
# version it drives). Bump both together and re-check the glibc floor.
ZIG_VERSION=0.14.0
ZIGBUILD_VERSION=0.22.3
# zig 0.14.0 has a macho-linker regression that can't resolve -liconv/-lcharset
# for apple-darwin under rust >= 1.82 (rust-lang/rust#128370, cargo-zigbuild#316)
# — the macOS cross-link fails with "unable to find dynamic system library
# 'iconv'". zig 0.15.2 resolves it. Bumped cargo-zigbuild in lockstep.
ZIG_VERSION=0.15.2
ZIGBUILD_VERSION=0.23.0
GLIBC_FLOOR=2.31
if ! command -v zig >/dev/null 2>&1; then
echo "==> Installing zig $ZIG_VERSION"
curl -sSL "https://ziglang.org/download/${ZIG_VERSION}/zig-linux-$(uname -m)-${ZIG_VERSION}.tar.xz" \
# zig flipped its archive naming to zig-<arch>-<os>-<ver> as of 0.14.1.
curl -sSL "https://ziglang.org/download/${ZIG_VERSION}/zig-$(uname -m)-linux-${ZIG_VERSION}.tar.xz" \
-o /tmp/zig.tar.xz
mkdir -p /opt/zig
tar -xJf /tmp/zig.tar.xz -C /opt/zig --strip-components=1
@@ -55,15 +60,44 @@
command -v cargo-zigbuild >/dev/null 2>&1 || \
cargo install --locked cargo-zigbuild --version "$ZIGBUILD_VERSION" 2>&1
rustup target add aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu 2>&1
rustup target add \
aarch64-unknown-linux-gnu x86_64-unknown-linux-gnu \
aarch64-apple-darwin x86_64-apple-darwin 2>&1
echo "==> Building arm64 (glibc $GLIBC_FLOOR floor)..."
echo "==> Building linux arm64 (glibc $GLIBC_FLOOR floor)..."
cargo zigbuild --release --target "aarch64-unknown-linux-gnu.${GLIBC_FLOOR}" 2>&1
echo "==> Building amd64 (glibc $GLIBC_FLOOR floor)..."
echo "==> Building linux amd64 (glibc $GLIBC_FLOOR floor)..."
cargo zigbuild --release --target "x86_64-unknown-linux-gnu.${GLIBC_FLOOR}" 2>&1
# macOS targets: no glibc floor (Apple libSystem, not glibc). zig bundles
# glibc/musl but NOT Apple's (non-redistributable) libSystem + frameworks, so
# cross-linking against Darwin frameworks needs a macOS SDK — cargo-zigbuild
# finds it via SDKROOT (auto-detected on macOS, but this runner is Linux).
# Dropping native-tls for rustls removed the Security framework, but std +
# iana-time-zone (via chrono) still link CoreFoundation, so the SDK is required.
# Pinned, immutable SDK release asset; extracts to /opt/MacOSX${VER}.sdk.
MACOS_SDK_VERSION=12.3
MACOS_SDK_DIR="/opt/MacOSX${MACOS_SDK_VERSION}.sdk"
if [ ! -d "$MACOS_SDK_DIR" ]; then
echo "==> Fetching macOS SDK $MACOS_SDK_VERSION"
curl -sSL "https://github.com/joseluisq/macosx-sdks/releases/download/${MACOS_SDK_VERSION}/MacOSX${MACOS_SDK_VERSION}.sdk.tar.xz" \
-o /tmp/macos-sdk.tar.xz
mkdir -p /opt
tar -xJf /tmp/macos-sdk.tar.xz -C /opt
fi
export SDKROOT="$MACOS_SDK_DIR"
# Link against an older Darwin so the binaries run on macOS 11+ (Big Sur), not
# just the SDK's own version.
export MACOSX_DEPLOYMENT_TARGET=11.0
echo "==> Building macos arm64 (SDK $MACOS_SDK_VERSION)..."
cargo zigbuild --release --target aarch64-apple-darwin 2>&1
echo "==> Building macos amd64 (SDK $MACOS_SDK_VERSION)..."
cargo zigbuild --release --target x86_64-apple-darwin 2>&1
ARM64_BIN="target/aarch64-unknown-linux-gnu/release/anvil"
AMD64_BIN="target/x86_64-unknown-linux-gnu/release/anvil"
MACOS_ARM64_BIN="target/aarch64-apple-darwin/release/anvil"
MACOS_AMD64_BIN="target/x86_64-apple-darwin/release/anvil"
# Hard-gate the glibc floor: fail the build if either binary references a
# GLIBC symbol newer than the floor. This is the exact failure we're fixing
@@ -91,6 +125,8 @@
mkdir -p runner-dist
cp "$ARM64_BIN" runner-dist/anvil_linux_arm64
cp "$AMD64_BIN" runner-dist/anvil_linux_amd64
cp "$MACOS_ARM64_BIN" runner-dist/anvil_macos_arm64
cp "$MACOS_AMD64_BIN" runner-dist/anvil_macos_amd64
if [ "$PUBLISH" != "1" ]; then
exit 0
@@ -101,6 +137,8 @@
cp "$ARM64_BIN" "runner-dist/anvil_linux_arm64_${VERSION}"
cp "$AMD64_BIN" "runner-dist/anvil_linux_amd64_${VERSION}"
cp "$MACOS_ARM64_BIN" "runner-dist/anvil_macos_arm64_${VERSION}"
cp "$MACOS_AMD64_BIN" "runner-dist/anvil_macos_amd64_${VERSION}"
# Compute SHA256 checksums for every versioned asset — published as
# SHA256SUMS_${VERSION} alongside the binaries so install scripts can
@@ -110,10 +148,11 @@
(
cd runner-dist
# Use whichever is available; macOS has shasum, Linux has sha256sum.
ASSETS="anvil_linux_arm64_${VERSION} anvil_linux_amd64_${VERSION} anvil_macos_arm64_${VERSION} anvil_macos_amd64_${VERSION}"
if command -v sha256sum >/dev/null 2>&1; then
sha256sum "anvil_linux_arm64_${VERSION}" "anvil_linux_amd64_${VERSION}" > "SHA256SUMS_${VERSION}"
sha256sum $ASSETS > "SHA256SUMS_${VERSION}"
else
shasum -a 256 "anvil_linux_arm64_${VERSION}" "anvil_linux_amd64_${VERSION}" > "SHA256SUMS_${VERSION}"
shasum -a 256 $ASSETS > "SHA256SUMS_${VERSION}"
fi
)
cat "runner-dist/SHA256SUMS_${VERSION}"
@@ -128,7 +167,7 @@
else
CHANGELOG=$(git log --oneline -n 20)
fi
BODY=$(printf 'Runner binaries for linux/{amd64,arm64} and macos/{amd64,arm64}.\n\n## Changes\n\n%s\n' "$CHANGELOG")
BODY=$(printf 'Runner binaries for linux/amd64 and linux/arm64.\n\n## Changes\n\n%s\n' "$CHANGELOG")
"$ANVIL_CLI" release create \
--tag "$VERSION" \
@@ -149,6 +188,12 @@
--repo fangorn/anvil-cli
"$ANVIL_CLI" release upload "$VERSION" \
"runner-dist/anvil_linux_amd64_${VERSION}" \
--repo fangorn/anvil-cli
"$ANVIL_CLI" release upload "$VERSION" \
"runner-dist/anvil_macos_arm64_${VERSION}" \
--repo fangorn/anvil-cli
"$ANVIL_CLI" release upload "$VERSION" \
"runner-dist/anvil_macos_amd64_${VERSION}" \
--repo fangorn/anvil-cli
"$ANVIL_CLI" release upload "$VERSION" \
"runner-dist/SHA256SUMS_${VERSION}" \