Add initial Apple tar validation script and CI integration
Intent: Introduce a reusable shell script that unpacks every `*.tar.gz` artifact in a given directory, locates the first Mach-O file, and runs `lipo -info` to confirm it is a valid universal binary. Wire this script into the GitHub Actions `build.yml` release job so it runs immediately after Apple artifacts are downloaded.
Affected files: .github/workflows/build.yml, scripts/validate-apple-tar.sh
@@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -euo pipefail +# validate-apple-tar.sh – sanity-check fetched Apple .tar.gz artifacts
@@ + echo "--- Validating $tar ---" + tmpdir=$(mktemp -d) + tar xzf "$tar" -C "$tmpdir"
@@ + macho=$(find "$tmpdir" -type f | head -n1) + if [ -z "$macho" ]; then + echo "ERROR: archive is empty: $tar" + exit 1 + fi + lipo -info "$macho" 2>/dev/null || file "$macho"
@@ (build.yml) + - name: Validate Apple tarballs + run: bash scripts/validate-apple-tar.sh artifacts/
The first commit lays the foundation for artifact validation.
scripts/validate-apple-tar.sh
A new Bash script is added with set -euo pipefail for strict error handling. It accepts a single positional argument — the directory containing downloaded artifacts — and iterates over every *.tar.gz file it finds there.
For each archive the script:
- Creates a temporary directory with
mktemp -d. - Extracts the tarball into the temp directory.
- Finds the first regular file (expected to be a Mach-O binary).
- Runs
lipo -infoto confirm it is a valid universal (fat) binary; falls back tofileiflipois unavailable. - Cleans up the temp directory.
If the archive is empty or contains no files, the script exits with status 1, failing the CI job.
.github/workflows/build.yml
A new step "Validate Apple tarballs" is inserted after the existing actions/download-artifact step in the release job. It simply runs:
bash scripts/validate-apple-tar.sh artifacts/
This ensures every macOS artifact is sanity-checked before the release is published.