Skip to content

Compress tool outputs, logs, files, and RAG chunks before they reach the LLM. 20% fewer tokens for coding agents, 60-95% fewer tokens for JSON, same answers. Library, proxy, MCP server.

fix(ci): publish latest from the root Docker manifest (#2252)

Rod Boev5568d738afb5
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index accab994a..091e23928 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -220,6 +220,7 @@ jobs:
# tags, and that manifest is what users pull by `:tag`.
docker-manifest:
needs: docker-build
+ if: ${{ always() }}
runs-on: ubuntu-24.04
timeout-minutes: 20
strategy:
@@ -313,6 +314,11 @@ jobs:
echo "ERROR: no digests downloaded for variant '${{ matrix.variant.name || 'root' }}'" >&2
exit 1
fi
+ digest_count="$(find "${DIGEST_DIR}" -maxdepth 1 -type f | wc -l)"
+ if [ "${digest_count}" -ne 2 ]; then
+ echo "ERROR: expected both architecture digests for variant '${{ matrix.variant.name || 'root' }}', found ${digest_count}" >&2
+ exit 1
+ fi
digest_refs=()
for f in "${DIGEST_DIR}"/*; do
digest="$(basename "$f")"
@@ -382,53 +388,13 @@ jobs:
sleep "$sleep_for"
done
- promote-latest:
- # Re-push the :latest tag pointing at the root variant *after* every
- # variant manifest job has finished, so GHCR's package version
- # listing (sorted by created_at) shows the root image with :latest
- # at the top instead of whichever variant happened to finish last.
- needs: docker-manifest
- runs-on: ubuntu-24.04
- timeout-minutes: 10
- steps:
- - name: Normalize image name
- id: image-name
- run: |
- image_name="$(printf '%s' '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')"
- printf 'image_name=%s\n' "$image_name" >> "$GITHUB_OUTPUT"
-
- - name: Determine image version
- id: version
- env:
- MANUAL_VERSION: ${{ inputs.version || github.event.inputs.version }}
- RELEASE_TAG: ${{ github.event.release.tag_name }}
- run: |
- version="${MANUAL_VERSION#v}"
- if [ -z "$version" ] && [ -n "$RELEASE_TAG" ]; then
- version="${RELEASE_TAG#v}"
- fi
- printf 'version=%s\n' "$version" >> "$GITHUB_OUTPUT"
-
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v4
-
- - name: Log in to GHCR
- uses: docker/login-action@v4
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
-
- name: Re-tag root image as :latest
- if: steps.version.outputs.version != ''
+ if: steps.manifest.outputs.index_digest != '' && matrix.variant.name == '' && steps.version.outputs.version != ''
env:
IMAGE: ${{ env.REGISTRY }}/${{ steps.image-name.outputs.image_name }}
VERSION: ${{ steps.version.outputs.version }}
run: |
- # Add a unique annotation so the resulting image index manifest gets
- # a new digest, which makes GHCR record a fresh package version with
- # current timestamp (otherwise the existing root manifest is reused
- # and stays where it was in the version listing).
+ # Add a unique annotation so GHCR records a fresh root package version.
promoted_at="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
docker buildx imagetools create \
--annotation "index:io.headroom.promoted-at=${promoted_at}" \
diff --git a/tests/test_release_workflows.py b/tests/test_release_workflows.py
index 9acd4faa2..3db9d77db 100644
--- a/tests/test_release_workflows.py
+++ b/tests/test_release_workflows.py
@@ -5,6 +5,7 @@ from __future__ import annotations
from pathlib import Path
import pytest
+import yaml
ROOT = Path(__file__).resolve().parent.parent
@@ -17,6 +18,56 @@ def test_docker_workflow_normalizes_repository_name_for_signing() -> None:
assert "steps.image-name.outputs.image_name" in content
+def test_docker_latest_promotion_is_owned_by_root_manifest_cell() -> None:
+ workflow = yaml.safe_load((ROOT / ".github" / "workflows" / "docker.yml").read_text())
+ jobs = workflow["jobs"]
+ build = jobs["docker-build"]
+ manifest = jobs["docker-manifest"]
+ variants = manifest["strategy"]["matrix"]["variant"]
+ build_variants = build["strategy"]["matrix"]["variant"]
+ architectures = build["strategy"]["matrix"]["arch"]
+ root = next(entry for entry in variants if entry["name"] == "")
+ nonroot = next(entry for entry in variants if entry["name"] == "nonroot")
+ promotion = next(
+ step for step in manifest["steps"] if step["name"] == "Re-tag root image as :latest"
+ )
+ command = promotion["run"]
+
+ assert len(variants) == 8
+ assert [entry["name"] for entry in build_variants] == [entry["name"] for entry in variants]
+ assert len(architectures) == 2
+ assert {entry["platform"] for entry in architectures} == {"linux/amd64", "linux/arm64"}
+ assert root["name"] == ""
+ assert nonroot["name"] == "nonroot"
+ assert "matrix.variant.name == ''" in promotion["if"]
+ assert "steps.manifest.outputs.index_digest != ''" in promotion["if"]
+ assert "steps.version.outputs.version != ''" in promotion["if"]
+ assert (
+ promotion["if"]
+ == "steps.manifest.outputs.index_digest != '' && matrix.variant.name == '' && steps.version.outputs.version != ''"
+ )
+ assert '"${IMAGE}:latest"' in command
+ assert '"${IMAGE}:${VERSION}"' in command
+ assert "promote-latest" not in jobs
+ assert manifest["needs"] == "docker-build"
+ assert manifest["if"] == "${{ always() }}"
+ step_names = [step["name"] for step in manifest["steps"]]
+ assert step_names.index("Sign multi-arch index manifest with cosign") < step_names.index(
+ "Re-tag root image as :latest"
+ )
+ manifest_script = next(
+ step["run"] for step in manifest["steps"] if step["name"] == "Create multi-arch manifest"
+ )
+ assert 'digest_count="$(find "${DIGEST_DIR}" -maxdepth 1 -type f | wc -l)"' in manifest_script
+ assert '"${digest_count}" -ne 2' in manifest_script
+ assert manifest_script.index('"${digest_count}" -ne 2') < manifest_script.index(
+ "docker buildx imagetools create"
+ )
+ guard_start = manifest_script.index('"${digest_count}" -ne 2')
+ create_start = manifest_script.index("docker buildx imagetools create")
+ assert guard_start < manifest_script.index("exit 1", guard_start) < create_start
+
+
def test_release_workflow_publishes_both_node_packages_to_github_packages() -> None:
content = (ROOT / ".github" / "workflows" / "release.yml").read_text(encoding="utf-8")