From e2df486d6029074cd24b27923273f4fb0239587f Mon Sep 17 00:00:00 2001 From: Sam Catlow Date: Tue, 22 Sep 2026 14:53:04 +1000 Subject: [PATCH] ci(deploy): derive the commit by dereferencing the ref, and stop stamping bare dev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two defects, both from consuming a ref's object id as if it were a commit. 1. IMMUTABLE IDENTITY. Both images published only `:latest`, so a deployed artifact could not be traced to a commit or restored. Each build now also publishes `sha-`. The commit is NOT `github.sha`: on a tag push that is the ref's object id, and every release tag in this repo is annotated — measured, 80 of 80 archied/v* and archie/v* tags are tag objects (archied/ v1.36.0 points at 6720bc42 and dereferences to c25f8d39). So the new step resolves `git rev-parse "${GITHUB_REF}^{commit}"` and the tags use that. Annotated tags are the right thing for the producer to create; the consumer stops guessing rather than the tag type being downgraded. 2. NO BARE dev STAMP. `[ -n "$GATEWAY_VERSION" ] || GATEWAY_VERSION=dev` made a main build indistinguishable from any other, and is why a release's stamping looked transient: the next commit to main republished :latest as plain `dev`. The fallback is now `dev+`, so an unreleased build is identifiable and visibly not a release. The warning at the gate now states the consequence it previously only implied. Scope: this file only. Nothing else in the checkout was touched. --- .github/workflows/deploy.yml | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index ca041d415..ff59af4f7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -139,7 +139,7 @@ jobs: exit 1 fi if ! git tag --points-at HEAD | grep -qE 'archie' ; then - echo "::warning ::No release tags at HEAD -- images will be stamped 'dev'" + echo "::warning ::No release tags at HEAD, so this build publishes :latest for a commit that is not a release. It is stamped dev+ and tagged sha- so it stays traceable and restorable, but it supersedes the previous release's :latest stamping until the next release is cut." fi build-and-push: @@ -151,6 +151,19 @@ jobs: with: fetch-depth: 0 + # Deliberately NOT `github.sha`. On a tag push that is the ref's OBJECT id, + # and every release tag in this repo is annotated — measured, 80 of 80 + # `archied/v*` and `archie/v*` tags are tag objects — so it names something + # that cannot be checked out. `archied/v1.36.0` is an instance: it points at + # 6720bc42 (a tag object) and dereferences to commit c25f8d39. The producer + # is right to create annotated tags; the consumer stops guessing. + - name: Resolve the commit this ref points at + id: commit + run: | + sha="$(git rev-parse "${GITHUB_REF}^{commit}")" + echo "sha=$sha" >> "$GITHUB_OUTPUT" + echo "short=${sha:0:12}" >> "$GITHUB_OUTPUT" + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -164,8 +177,14 @@ jobs: RUNTIME_TAG="$(git tag --points-at HEAD --list 'archie/v*' | sort -V | tail -1)" GATEWAY_VERSION="${GATEWAY_TAG#archied/}" RUNTIME_VERSION="${RUNTIME_TAG#archie/}" - [ -n "$GATEWAY_VERSION" ] || GATEWAY_VERSION=dev - [ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION=dev + # Not a bare `dev`. A literal dev tells an operator nothing about which + # build they are running, and it is what made a release's stamping look + # transient: the next commit to main republished :latest as `dev`. The + # commit is appended so a main build is identifiable and is visibly not + # a release. (On an untagged push GITHUB_SHA IS the commit — the tag + # case is handled by the dereference above.) + [ -n "$GATEWAY_VERSION" ] || GATEWAY_VERSION="dev+${GITHUB_SHA:0:12}" + [ -n "$RUNTIME_VERSION" ] || RUNTIME_VERSION="dev+${GITHUB_SHA:0:12}" # Keep the raw tag presence separate from the version fallback: # gateway-only releases must not rebuild the runtime image as dev. echo "gateway_tag=$GATEWAY_TAG" >> "$GITHUB_OUTPUT" @@ -179,7 +198,9 @@ jobs: context: . file: Dockerfile.archied push: true - tags: ghcr.io/samcharles93/archied:latest + tags: | + ghcr.io/samcharles93/archied:latest + ghcr.io/samcharles93/archied:sha-${{ steps.commit.outputs.sha }} build-args: | GATEWAY_VERSION=${{ steps.versions.outputs.gateway }} RUNTIME_VERSION=${{ steps.versions.outputs.runtime }} @@ -193,7 +214,9 @@ jobs: context: . file: Dockerfile push: true - tags: ghcr.io/samcharles93/archie-agent:latest + tags: | + ghcr.io/samcharles93/archie-agent:latest + ghcr.io/samcharles93/archie-agent:sha-${{ steps.commit.outputs.sha }} build-args: | RUNTIME_VERSION=${{ steps.versions.outputs.runtime }} cache-from: type=gha,scope=archie-agent