Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

feat(release): promote dev-proven digests on a release tag

Jose Ramirez8b9be980284c
diff --git a/.github/workflows/release-images.yml b/.github/workflows/release-images.yml
new file mode 100644
index 000000000..fe13e9b6c
--- /dev/null
+++ b/.github/workflows/release-images.yml
@@ -0,0 +1,54 @@
+name: Release images
+
+# Promotes dev-proven digests to a release tag. Never rebuilds -- prod promotes
+# what dev proved, per the rule build-publish.yml states in its own header.
+on:
+ push:
+ tags: ['v*']
+ workflow_dispatch:
+ inputs:
+ ref:
+ description: 'Ref to rehearse against (dry run, promotes nothing)'
+ required: true
+
+permissions:
+ contents: read
+
+jobs:
+ promote:
+ name: Promote images
+ runs-on: ubuntu-latest
+ # Forks cannot write to ghcr.io/evenfire-ai/*, and a fork's v* tag would
+ # otherwise produce a red run against a namespace it does not own.
+ if: github.repository == 'evenfire-ai/evenfire'
+ permissions:
+ contents: read
+ packages: write
+ steps:
+ - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
+ with:
+ # resolve-release-images.mjs runs `git merge-base --is-ancestor` and
+ # `git diff` against a commit that may be far back on dev. A shallow
+ # checkout has neither.
+ fetch-depth: 0
+
+ - name: Install crane
+ run: |
+ set -euo pipefail
+ VER=v0.20.2
+ curl -fsSL "https://github.com/google/go-containerregistry/releases/download/${VER}/go-containerregistry_Linux_x86_64.tar.gz" \
+ | tar -xz -C /usr/local/bin crane
+ crane version
+
+ - name: Log in to ghcr.io
+ uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3
+ with:
+ registry: ghcr.io
+ username: ${{ github.actor }}
+ password: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Resolve and promote
+ env:
+ DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && 'true' || 'false' }}
+ RELEASE_REF: ${{ github.event.inputs.ref || github.ref_name }}
+ run: bash scripts/release/promote-release-images.sh
diff --git a/scripts/release/promote-release-images.sh b/scripts/release/promote-release-images.sh
new file mode 100755
index 000000000..d63918f00
--- /dev/null
+++ b/scripts/release/promote-release-images.sh
@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+set -euo pipefail
+
+REGISTRY="ghcr.io/evenfire-ai"
+DRY_RUN="${DRY_RUN:-true}"
+RELEASE_REF="${RELEASE_REF:?RELEASE_REF is required}"
+VERSION="${RELEASE_REF#v}"
+TAG_SHA="$(git rev-parse "$RELEASE_REF^{commit}")"
+
+# :stable moves only for a strict release. A v0.6.0-rc dry run must not
+# re-point the tag the documentation tells people to use.
+MOVE_STABLE=false
+[[ "$RELEASE_REF" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && MOVE_STABLE=true
+
+mapfile -t IMAGES < <(node -e '
+ import("./scripts/release/images-manifest.mjs").then(m =>
+ m.publishedImages().forEach(i => console.log(`${i.name}\t${(i.source_paths||[]).join(",")}`)))')
+
+failed=0
+for row in "${IMAGES[@]}"; do
+ name="${row%%$'\t'*}"; paths="${row#*$'\t'}"
+ if ! digest="$(node scripts/release/resolve-release-images.mjs \
+ --image "$name" --source-paths "$paths" --tag-sha "$TAG_SHA")"; then
+ failed=1; continue
+ fi
+
+ # Verify the INDEX we are about to promote is multi-arch. Existence alone
+ # would let a single-platform copy through, which is the exact gap this
+ # workstream exists to close.
+ platforms="$(crane manifest "$REGISTRY/$name@$digest" \
+ | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{
+ const m=JSON.parse(s).manifests||[];
+ console.log(m.map(x=>x.platform?.architecture).filter(a=>a&&a!=="unknown").sort().join(","))})')"
+ if [ "$platforms" != "amd64,arm64" ]; then
+ echo "::error::$name@$digest is [$platforms], expected amd64,arm64"
+ failed=1; continue
+ fi
+
+ if [ "$DRY_RUN" = "true" ]; then
+ echo "would promote $name@$digest -> :$VERSION ($platforms)"
+ continue
+ fi
+
+ crane copy "$REGISTRY/$name@$digest" "$REGISTRY/$name:$VERSION"
+ [ "$MOVE_STABLE" = "true" ] && crane copy "$REGISTRY/$name@$digest" "$REGISTRY/$name:stable"
+ echo "promoted $name@$digest -> :$VERSION"
+done
+
+exit $failed
diff --git a/scripts/release/resolve-release-images.mjs b/scripts/release/resolve-release-images.mjs
new file mode 100644
index 000000000..95583d059
--- /dev/null
+++ b/scripts/release/resolve-release-images.mjs
@@ -0,0 +1,111 @@
+// Decides which digest a release promotes for ONE image, and refuses rather
+// than guessing.
+//
+// node scripts/release/resolve-release-images.mjs \
+// --image control-api --source-paths 'control-api/**' --tag-sha <sha>
+//
+// Prints the digest to promote on success; exits non-zero with a named reason
+// otherwise.
+//
+// Why the revision label and not git history: builds are change-detected, so
+// each image's newest sha- tag sits at a different commit, and the tagged
+// commit on main is a dev->main merge that was never built. Computing "the last
+// commit touching this image's source paths" lands on feature-branch merge
+// commits that have no published image at all. The image knows what it was
+// built from; ask it.
+//
+// Reads the revision from the OCI INDEX's own annotations (`crane manifest`),
+// not a per-arch child manifest's config label (`crane config --platform`).
+// build-publish.yml (Task 3) writes the same value to both: an index-level
+// `--annotation index:org.opencontainers.image.revision=...` on the merged
+// manifest list, and a per-leg `labels:` baked into each platform's image
+// config. The index read is one flat lookup with no --platform to get wrong
+// (`crane config --platform linux/amd64` would break if that leg's manifest
+// were ever the one missing while another platform's was present). Verified
+// against a real docker-buildx-built multi-arch index (amd64 + arm64, pushed
+// by digest, merged with `imagetools create --annotation index:...`, exactly
+// as build-publish.yml does it) during Task 4 development: `crane manifest
+// <ref> | jq .annotations` and `crane config --platform linux/amd64 <ref> |
+// jq .config.Labels` both returned the same revision, confirming either read
+// works against the real thing crane is stubbed to imitate here.
+import { execFileSync } from 'node:child_process'
+import process from 'node:process'
+
+const REGISTRY = 'ghcr.io/evenfire-ai'
+
+function argValue(name) {
+ const index = process.argv.indexOf(name)
+ return index >= 0 ? process.argv[index + 1] : ''
+}
+
+function die(message) {
+ console.error(`::error::${message}`)
+ process.exit(1)
+}
+
+function sh(cmd, args) {
+ return execFileSync(cmd, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim()
+}
+
+const image = argValue('--image')
+const sourcePaths = argValue('--source-paths')
+const tagSha = argValue('--tag-sha')
+
+if (!image || !tagSha) die('--image and --tag-sha are required')
+
+// Resolve the moving tag to an immutable digest ONCE. :latest is re-pointed on
+// every dev push, so reading it twice -- once to verify, once to copy -- can
+// verify one image and promote another.
+let digest
+try {
+ digest = sh('crane', ['digest', `${REGISTRY}/${image}:latest`])
+} catch (error) {
+ die(`${image}: could not resolve ${REGISTRY}/${image}:latest to a digest: ${error.message}`)
+}
+
+let revision
+try {
+ const manifest = JSON.parse(sh('crane', ['manifest', `${REGISTRY}/${image}@${digest}`]))
+ revision = manifest?.annotations?.['org.opencontainers.image.revision']
+} catch (error) {
+ die(`${image}: could not read the image manifest at ${digest}: ${error.message}`)
+}
+
+if (!revision) {
+ die(
+ `${image}@${digest} carries no org.opencontainers.image.revision label, so there is no way ` +
+ `to tell what it was built from. Re-publish via a build_all run before releasing.`
+ )
+}
+
+try {
+ sh('git', ['merge-base', '--is-ancestor', revision, tagSha])
+} catch {
+ die(
+ `${image}: the published image was built from ${revision}, which is not an ancestor of the ` +
+ `release commit ${tagSha}. That image is not in this release.`
+ )
+}
+
+if (sourcePaths) {
+ // Guarded separately from the ancestor check above: an invalid or
+ // unresolvable revision must die with a message this script chose, not an
+ // uncaught `git diff` stack trace. Without this, removing the ancestor
+ // check upstream doesn't redden a test for the ancestor check -- it
+ // crashes here instead, and a test that only asserts "some failure
+ // happened" can't tell the difference.
+ let changed
+ try {
+ changed = sh('git', ['diff', '--name-only', revision, tagSha, '--', ...sourcePaths.split(',')])
+ } catch (error) {
+ die(`${image}: could not diff ${revision}..${tagSha} for source changes: ${error.message}`)
+ }
+ if (changed) {
+ die(
+ `${image}: source changed after the published image (${revision}). Push to dev and let ` +
+ `build-publish run before tagging.\nchanged:\n${changed}`
+ )
+ }
+}
+
+console.log(digest)
diff --git a/scripts/tests/test-resolve-release-images.sh b/scripts/tests/test-resolve-release-images.sh
new file mode 100755
index 000000000..d99cd48cf
--- /dev/null
+++ b/scripts/tests/test-resolve-release-images.sh
@@ -0,0 +1,171 @@
+#!/usr/bin/env bash
+set -u
+FAIL=0
+
+# resolve-release-images.mjs decides WHICH digest a release promotes. crane is
+# stubbed on PATH throughout: these cases are about the decision logic, not the
+# registry.
+#
+# The revision is read from the OCI INDEX's own annotations (`crane manifest`),
+# not a per-arch child manifest's config label (`crane config --platform`).
+# Both are written by build-publish.yml (Task 3): an index-level
+# `--annotation index:org.opencontainers.image.revision=...` on the merged
+# manifest list, and a per-leg `labels:` baked into each platform's image
+# config. The index read is a single flat lookup with no --platform to pick,
+# so the stub below returns `{"annotations": {...}}`.
+
+REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
+
+pass() { echo "PASS: $1"; }
+fail() { echo "FAIL: $1"; FAIL=1; }
+
+# make_stub <dir> <digest> <revision>
+make_stub() {
+ mkdir -p "$1/bin"
+ cat > "$1/bin/crane" <<STUB
+#!/usr/bin/env bash
+case "\$1" in
+ digest) echo "$2" ;;
+ manifest) echo '{"annotations":{"org.opencontainers.image.revision":"$3"}}' ;;
+ copy) echo "copied \$2 -> \$3" ;;
+ *) exit 1 ;;
+esac
+STUB
+ chmod +x "$1/bin/crane"
+}
+
+# A throwaway repo with two commits, so ancestry is real rather than mocked.
+make_repo() {
+ local d=$1
+ mkdir -p "$d/control-api"
+ ( cd "$d" && git init -q .
+ echo one > control-api/a.ts && git add -A && git -c user.email=t@t -c user.name=t commit -qm one
+ echo two > control-api/a.ts && git add -A && git -c user.email=t@t -c user.name=t commit -qm two )
+}
+
+assert_a_revision_that_is_an_ancestor_resolves() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ local old; old="$( cd "$d" && git rev-parse HEAD~1 )"
+ make_stub "$d" "sha256:abc" "$old"
+ # No source change after $old on the paths we ask about, so this must resolve.
+ if ( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
+ --image control-api --source-paths 'unrelated/**' --tag-sha HEAD >/dev/null 2>&1 ); then
+ pass "an ancestor revision with no later source change resolves"
+ else
+ fail "a valid ancestor revision was rejected"
+ fi
+ rm -rf "$d"
+}
+
+assert_a_non_ancestor_revision_is_rejected() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ make_stub "$d" "sha256:abc" "0000000000000000000000000000000000000000"
+ # Check for the ancestor guard's own wording, not just a nonzero exit: the
+ # bogus revision below is also an unresolvable git object, so if the
+ # ancestor check itself were removed, the very next step (the source-paths
+ # diff) would independently choke on that same bogus revision and exit
+ # nonzero too. A bare rc-only assertion can't tell "the ancestor guard
+ # fired" apart from "something downstream happened to crash instead."
+ local out
+ out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
+ --image control-api --source-paths 'control-api/**' --tag-sha HEAD 2>&1 )" && rc=0 || rc=1
+ if [ "$rc" -ne 0 ] && grep -qi "ancestor" <<< "$out"; then
+ pass "a revision that is not an ancestor of the release is rejected"
+ else
+ fail "expected a named failure about the revision not being an ancestor; got rc=$rc out='$out'"
+ fi
+ rm -rf "$d"
+}
+
+assert_a_source_change_after_the_revision_is_rejected() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ local old; old="$( cd "$d" && git rev-parse HEAD~1 )"
+ make_stub "$d" "sha256:abc" "$old"
+ # control-api/** DID change between $old and HEAD, so promoting $old would
+ # ship an image that predates the release's own source.
+ if ( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
+ --image control-api --source-paths 'control-api/**' --tag-sha HEAD >/dev/null 2>&1 ); then
+ fail "a source change after the published image was accepted"
+ else
+ pass "a source change after the published image is rejected"
+ fi
+ rm -rf "$d"
+}
+
+assert_a_missing_revision_label_fails_loudly() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ mkdir -p "$d/bin"
+ cat > "$d/bin/crane" <<'STUB'
+#!/usr/bin/env bash
+case "$1" in
+ digest) echo "sha256:abc" ;;
+ manifest) echo '{"annotations":{}}' ;;
+ *) exit 1 ;;
+esac
+STUB
+ chmod +x "$d/bin/crane"
+ local out
+ out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
+ --image control-api --source-paths 'unrelated/**' --tag-sha HEAD 2>&1 )" && rc=0 || rc=1
+ if [ "$rc" -ne 0 ] && grep -qi "revision label" <<< "$out"; then
+ pass "a missing revision label fails loudly rather than promoting blind"
+ else
+ fail "expected a named failure about the revision label; got rc=$rc out='$out'"
+ fi
+ rm -rf "$d"
+}
+
+assert_the_digest_is_resolved_once_and_reused() {
+ local d; d="$(mktemp -d)"; make_repo "$d"
+ local old; old="$( cd "$d" && git rev-parse HEAD~1 )"
+ mkdir -p "$d/bin"
+ # Emit a DIFFERENT digest on each call. If the script resolves :latest more
+ # than once, the digest it verified is not the digest it would promote --
+ # a time-of-check-to-time-of-use bug, because :latest moves on every dev push.
+ cat > "$d/bin/crane" <<STUB
+#!/usr/bin/env bash
+COUNT_FILE="$d/digest-calls"
+case "\$1" in
+ digest) n=\$(( \$(cat "\$COUNT_FILE" 2>/dev/null || echo 0) + 1 )); echo "\$n" > "\$COUNT_FILE"; echo "sha256:call\$n" ;;
+ manifest) echo '{"annotations":{"org.opencontainers.image.revision":"$old"}}' ;;
+ *) exit 1 ;;
+esac
+STUB
+ chmod +x "$d/bin/crane"
+ local out; out="$( cd "$d" && PATH="$d/bin:$PATH" node "$REPO_ROOT/scripts/release/resolve-release-images.mjs" \
+ --image control-api --source-paths 'unrelated/**' --tag-sha HEAD 2>&1 )"
+ local calls; calls="$(cat "$d/digest-calls" 2>/dev/null || echo 0)"
+ if [ "$calls" = "1" ] && grep -q "sha256:call1" <<< "$out"; then
+ pass "the moving :latest tag is resolved to a digest exactly once"
+ else
+ fail "crane digest called $calls time(s), output '$out'"
+ fi
+ rm -rf "$d"
+}
+
+assert_every_defined_case_is_invoked() {
+ # comm -23 over sorted lists. An earlier draft used a `while read` loop fed by
+ # `grep -oE ... -P`, which mixes two incompatible matcher flags: the loop body
+ # never ran, `missing` stayed empty, and the guard PASSED while printing its
+ # own contradiction ("6 defined, 5 invoked"). This is the pattern proven to
+ # redden in scripts/tests/test-release-coordinates.sh.
+ local defined invoked missing self
+ self="$REPO_ROOT/scripts/tests/test-resolve-release-images.sh"
+ defined="$(grep -oE '^assert_[a-z_]+\(\) \{' "$self" | sed -E 's/\(\) \{$//' | sort -u)"
+ invoked="$(grep -oE '^assert_[a-z_]+$' "$self" | sort -u)"
+ missing="$(comm -23 <(printf '%s\n' "$defined") <(printf '%s\n' "$invoked"))"
+ if [ -z "$missing" ]; then
+ pass "every defined assert_ case is invoked in the call block"
+ else
+ fail "defined but never invoked: $(printf '%s ' $missing)"
+ fi
+}
+
+assert_a_revision_that_is_an_ancestor_resolves
+assert_a_non_ancestor_revision_is_rejected
+assert_a_source_change_after_the_revision_is_rejected
+assert_a_missing_revision_label_fails_loudly
+assert_the_digest_is_resolved_once_and_reused
+assert_every_defined_case_is_invoked
+
+exit $FAIL