From 6fdee57e39249edc5346622afeb58f8d8f9bb098 Mon Sep 17 00:00:00 2001 From: Nima Shafie Date: Thu, 3 Dec 2026 19:51:21 -0800 Subject: [PATCH] feat: make release/build pipeline Option-B-safe Under Option B the prebuilt submodule is manifests-only and tool binaries live in each release's assets (fetch-artifacts.sh rehydrates + verifies them). The release and LLVM-build pipelines still assumed binaries were in git, so a naive tool-update release would either ship a tag with no artifacts (fetch 404s) or re-bloat the slimmed repo. - release.sh: after creating the GitHub release, publish the prebuilt tool artifacts to the tag via publish-artifacts.sh --gh (opt out with --skip-artifacts). First verifies prebuilt/ holds the complete declared set with the new check-prebuilt-artifacts.sh, and refuses to publish an incomplete tag (prevents shipping a release that cannot install). - check-prebuilt-artifacts.sh: new on-disk completeness check (companion to the checksum-only check-prebuilt-manifests.sh) for publishers/bundlers. - build-llvm-linux.yml: the commit job now commits MANIFEST ONLY to prebuilt git and ships the split parts as the llvm-linux-parts- workflow artifact, so CI-built LLVM variants no longer land in git. (The musl/sqlite build workflows already only upload workflow artifacts.) - smoke-test.yml: refresh the stale "prebuilt must contain archives" header. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/build-llvm-linux.yml | 34 +++++++++++--- .github/workflows/smoke-test.yml | 11 ++--- scripts/internal/check-prebuilt-artifacts.sh | 48 ++++++++++++++++++++ scripts/internal/release.sh | 40 +++++++++++++++- 4 files changed, 119 insertions(+), 14 deletions(-) create mode 100644 scripts/internal/check-prebuilt-artifacts.sh diff --git a/.github/workflows/build-llvm-linux.yml b/.github/workflows/build-llvm-linux.yml index fe41039..7c643fc 100644 --- a/.github/workflows/build-llvm-linux.yml +++ b/.github/workflows/build-llvm-linux.yml @@ -296,14 +296,21 @@ jobs: path: /tmp/llvm-output/LLVM-${{ inputs.llvm_version }}-Linux-X64-musl.tar.xz retention-days: 3 -# ── Job 2: Commit ───────────────────────────────────────────────────────────── +# ── Job 2: Stage manifest + publish parts (Option B) ────────────────────────── # Separate job so a commit/push failure can be re-run in seconds without # repeating the 90-minute builds. # +# Option B: the LLVM binaries do NOT go into git. This job commits only the +# regenerated manifest.json (checksums) to the prebuilt submodule, and uploads +# the split parts as a workflow artifact. The release operator downloads that +# artifact into prebuilt/ alongside the other staged tools, and release.sh +# publishes the whole set to the release tag (where fetch-artifacts.sh reads +# them). This keeps the slimmed prebuilt repo manifests-only. +# # Clones prebuilt directly (not via git submodule update) so it is always # on the main branch — no detached HEAD, no push ambiguity. commit: - name: Commit to prebuilt/ and update submodule pointer + name: Stage LLVM manifest + publish parts artifact needs: [build, build-musl] # Run even if one leg (a distro or musl) failed, so the variants that DID # build still get staged. The steps below no-op cleanly when nothing is new. @@ -388,18 +395,31 @@ jobs: print("manifest platforms:", list(man["platforms"].keys())) PY - - name: Commit and push prebuilt + - name: Upload LLVM parts as release-staging artifact + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: llvm-linux-parts-${{ inputs.llvm_version }} + # Option B: the binaries are published to the release by release.sh, not + # committed to git. The operator downloads this into prebuilt/ before + # releasing. Preserve the toolchains/llvm// tree so it drops in place. + path: prebuilt-wr/toolchains/llvm/${{ inputs.llvm_version }}/*.part-* + retention-days: 7 + if-no-files-found: warn + + - name: Commit manifest only (Option B — binaries stay out of git) working-directory: prebuilt-wr run: | git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" - git add "toolchains/llvm/${LLVM_VERSION}/" + # Commit ONLY the regenerated manifest (checksums). The split parts are + # left untracked here and shipped via the release-staging artifact above. + git add "toolchains/llvm/${LLVM_VERSION}/manifest.json" if git diff --cached --quiet; then - echo "No new/changed LLVM parts to commit — nothing to do." + echo "Manifest unchanged — nothing to commit." exit 0 fi git diff --cached --stat - git commit -m "build: LLVM ${LLVM_VERSION} tools for RHEL/Rocky (per-distro glibc builds)" + git commit -m "build: LLVM ${LLVM_VERSION} manifest (Linux RHEL/Rocky + musl checksums)" git push - name: Update submodule pointer in main repo @@ -415,5 +435,5 @@ jobs: fi echo "Pointing prebuilt submodule → ${PREBUILT_SHA}" git update-index --cacheinfo "160000,${PREBUILT_SHA},prebuilt" - git commit -m "chore: update prebuilt — LLVM ${LLVM_VERSION} RHEL/Rocky builds" + git commit -m "chore: update prebuilt — LLVM ${LLVM_VERSION} manifest" git push diff --git a/.github/workflows/smoke-test.yml b/.github/workflows/smoke-test.yml index 07f2539..d07b26e 100644 --- a/.github/workflows/smoke-test.yml +++ b/.github/workflows/smoke-test.yml @@ -2,12 +2,11 @@ name: Smoke Test # Full install + run-tests.sh regression suite. # -# REQUIREMENTS: -# This workflow installs real tools from the prebuilt archives. -# The prebuilt submodule must contain the tool archives (tar.xz / zip), -# OR a self-hosted runner must have them pre-staged at the repo root. -# GitHub-hosted runners can run this only if archives are committed to -# the prebuilt submodule (large files should use Git LFS). +# REQUIREMENTS (Option B): +# The prebuilt submodule ships manifests only; the tool binaries live in the +# matching release's assets. The "Fetch prebuilt binaries" step below rehydrates +# and checksum-verifies this platform's set into prebuilt/ before installing, +# using DEVKIT_ARTIFACT_BASE (defaults to the release tag derived from version.go). # # TRIGGERS: # - Weekly (Monday 06:00 UTC) -- automated regression check diff --git a/scripts/internal/check-prebuilt-artifacts.sh b/scripts/internal/check-prebuilt-artifacts.sh new file mode 100644 index 0000000..f51c675 --- /dev/null +++ b/scripts/internal/check-prebuilt-artifacts.sh @@ -0,0 +1,48 @@ +#!/usr/bin/env bash +# Author: Nima Shafie +# ============================================================================= +# check-prebuilt-artifacts.sh +# +# Option B companion to check-prebuilt-manifests.sh. Where that check asserts +# every declared artifact has a resolvable SHA256 (a manifest/authoring check +# that runs in CI with no binaries present), THIS check asserts every declared +# artifact file is actually PRESENT ON DISK in the prebuilt working tree — the +# guarantee a publisher needs before uploading a release (publish-artifacts.sh) +# or building an offline bundle, so the tag/bundle is a complete, installable set. +# +# Enumerates each manifest's required files for all platforms (whole archives and +# split .part-* sets alike) via enumerate-artifacts.py, and fails if any are not +# found under the prebuilt root. +# +# USAGE: bash scripts/internal/check-prebuilt-artifacts.sh [prebuilt-dir] +# EXIT: 0 = every declared artifact file is present on disk; 1 = one or more absent. +# ============================================================================= +set -euo pipefail + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" +PREBUILT="${1:-$REPO_ROOT/prebuilt}" + +command -v python3 >/dev/null 2>&1 || { echo "[!!] python3 not found on PATH" >&2; exit 1; } + +missing=0 +while IFS= read -r manifest; do + reldir="$(dirname "${manifest#"$PREBUILT"/}")" + while IFS=$'\t' read -r name _sha; do + [[ -z "$name" ]] && continue + if [[ ! -f "$PREBUILT/$reldir/$name" ]]; then + echo "ABSENT $reldir/$name (declared in ${manifest#"$PREBUILT"/})" + missing=$((missing + 1)) + fi + done < <(python3 "$SCRIPT_DIR/lib/enumerate-artifacts.py" "$manifest" all | tr -d '\r') +done < <(find "$PREBUILT" -name manifest.json -type f | sort) + +if [[ "$missing" -gt 0 ]]; then + echo "" >&2 + echo "[!!] $missing declared artifact file(s) are not present on disk in prebuilt/." >&2 + echo " This tree is manifests-only or partially staged; a release/bundle built" >&2 + echo " from it would be incomplete. Rehydrate with fetch-artifacts.sh (from the" >&2 + echo " previous release tag) and overlay any newly-staged tool bumps." >&2 + exit 1 +fi +echo "[OK] every manifest-declared artifact file is present on disk in prebuilt/." diff --git a/scripts/internal/release.sh b/scripts/internal/release.sh index 0e5eec6..dea5459 100644 --- a/scripts/internal/release.sh +++ b/scripts/internal/release.sh @@ -12,6 +12,13 @@ # --skip-sign Skip Authenticode / GPG binary signing # --skip-vt Skip VirusTotal scan # --skip-gh-release Skip creating the GitHub release and tag +# --skip-artifacts Skip publishing prebuilt tool artifacts to the release +# (Option B). By default, after the release is created, every +# artifact present in prebuilt/ is uploaded to the tag so +# fetch-artifacts.sh can rehydrate a complete set. The tree +# must therefore hold the FULL artifact set at release time — +# hydrate it first with fetch-artifacts.sh from the previous +# tag, then overlay any newly-staged tool bumps. # # Standard full release (new binaries, public): # bash scripts/internal/release.sh 1.2.3 --upload @@ -34,9 +41,10 @@ TEST_PYPI=false SKIP_SIGN=false SKIP_VT=false SKIP_GH_RELEASE=false +SKIP_ARTIFACTS=false if [[ -z "$VERSION" ]]; then - echo "Usage: bash scripts/internal/release.sh [--no-build] [--upload] [--test] [--skip-sign] [--skip-vt] [--skip-gh-release]" >&2 + echo "Usage: bash scripts/internal/release.sh [--no-build] [--upload] [--test] [--skip-sign] [--skip-vt] [--skip-gh-release] [--skip-artifacts]" >&2 echo " version format: 1.2.3 or 1.2.3rc1 or 1.2.3b2" >&2 exit 1 fi @@ -50,6 +58,7 @@ for arg in "$@"; do --skip-sign) SKIP_SIGN=true ;; --skip-vt) SKIP_VT=true ;; --skip-gh-release) SKIP_GH_RELEASE=true ;; + --skip-artifacts) SKIP_ARTIFACTS=true ;; *) echo "Unknown flag: $arg" >&2; exit 1 ;; esac done @@ -288,6 +297,35 @@ pip install airgap-devkit==$VERSION "${GH_FLAGS[@]}" echo " GitHub release: https://github.com/$(gh repo view --json nameWithOwner -q .nameWithOwner)/releases/tag/$TAG" + + # ── Option B: publish the prebuilt tool artifacts to this release ────── + # The prebuilt submodule ships manifests only; the tool binaries live in + # the release's assets and are rehydrated by fetch-artifacts.sh, which + # verifies each file against the manifest SHA256. Upload every artifact + # present in prebuilt/ so the tag is a complete, self-contained set. + if [[ "$SKIP_ARTIFACTS" == false ]]; then + # Guard against publishing an incomplete tag: fetch-artifacts.sh uses + # a single base, so every manifest-declared artifact must end up on + # THIS tag. Verify the working tree holds them all before uploading; + # a manifests-only or partially-staged tree would silently ship a tag + # that cannot install. Hydrate first (fetch-artifacts.sh from the + # previous tag) + overlay new stagings, or pass --skip-artifacts. + echo "" + echo " Verifying prebuilt artifact tree is complete before publish ..." + missing=$(bash "$REPO_ROOT/scripts/internal/check-prebuilt-artifacts.sh" 2>&1) || { + echo "$missing" >&2 + echo " [FAIL] prebuilt/ is missing artifacts the manifests declare — refusing to" >&2 + echo " publish an incomplete release. Hydrate the full set first:" >&2 + echo " DEVKIT_ARTIFACT_BASE=.../releases/download/ \\" >&2 + echo " bash scripts/internal/fetch-artifacts.sh --platform all" >&2 + echo " then re-stage this version's tool bumps and re-run (or --skip-artifacts)." >&2 + exit 1 + } + echo " Publishing prebuilt tool artifacts to $TAG ..." + bash "$REPO_ROOT/scripts/internal/publish-artifacts.sh" --gh "$TAG" + else + echo " --skip-artifacts: not publishing prebuilt tool artifacts to $TAG." + fi fi fi