From c6b1d7c786e57f566e6342485da630ce659dd071 Mon Sep 17 00:00:00 2001 From: Claude Code AI - Gitea MCP <3+claude@noreply.git.rkdr.net> Date: Sun, 25 Oct 2026 11:44:02 +0000 Subject: [PATCH 1/2] feat(image): publish the images under a semver tag Each image gets a version in the build matrix, pushed as a tag next to sha-<12> and latest, so consumers can pin image:X.Y.Z@sha256:. Gitea cannot make a tag immutable, so the prepare step asks the registry first: when the version tag already exists it is left alone and the job warns that the version needs bumping. Image versions are independent of the Collection's release tags, so the v* tag trigger and tag handling go. Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/image.yml | 72 +++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index 39852db..3acad2d 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -36,8 +36,6 @@ on: # yamllint disable-line rule:truthy - 'requirements-dev.txt' - '.pre-commit-config.yaml' - '.gitea/workflows/image.yml' - tags: - - 'v*' workflow_dispatch: {} permissions: @@ -54,20 +52,28 @@ jobs: if: >- github.repository == 'mortis/kamino' && github.event_name != 'pull_request' && - (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + github.ref == 'refs/heads/main' runs-on: kamino-docker timeout-minutes: 45 # One job at a time on the single-capacity runner. An empty subpath means the # repository root is the build context. + # + # version: the semver tag of the image, independent of the Collection's releases. + # Bump it in the same PR as an image change you want to publish under a new tag. + # A version that is already in the registry is never moved (see the prepare step): + # such a build is tagged sha-<12> and latest only. Pin consumers as + # image:@sha256:; the digest is what is enforced. strategy: fail-fast: false max-parallel: 1 matrix: include: - name: molecule-ubuntu2404 + version: 0.1.0 subpath: images/molecule-ubuntu2404 dockerfile: Dockerfile - name: ci + version: 0.1.0 subpath: "" dockerfile: images/ci/Dockerfile container: @@ -77,23 +83,17 @@ jobs: env: DEBIAN_FRONTEND: noninteractive IMAGE_PATH: mortis/${{ matrix.name }} + IMAGE_VERSION: ${{ matrix.version }} steps: - # A tag becomes the image tag. OCI tags cannot contain '+' (semver build metadata), - # and the trigger glob `v*` also matches names like `vfoo`: refuse both before + # The version becomes an image tag. OCI tags cannot contain '+' (semver build + # metadata), so only MAJOR.MINOR.PATCH[-prerelease] is accepted. Refuse before # anything is installed or built. Only bash builtins are used. - - name: Validate the ref - env: - REF: ${{ github.ref }} - REF_NAME: ${{ github.ref_name }} + - name: Validate the image version run: | - case "$REF" in - refs/tags/*) - if ! [[ "$REF_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then - echo "::error::Tag '$REF_NAME' is not vMAJOR.MINOR.PATCH[-prerelease]; refusing to build or push." - exit 1 - fi - ;; - esac + if ! [[ "$IMAGE_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]]; then + echo "::error::Image version '$IMAGE_VERSION' is not MAJOR.MINOR.PATCH[-prerelease]; refusing to build or push." + exit 1 + fi # One step, in this order, so the filesystem the build starts from is the pristine # base image. Kaniko unpacks the base image into the job container's own root @@ -172,6 +172,8 @@ jobs: "https://${registry}/v2/${IMAGE_PATH}/blobs/uploads/" || true } write_config() { + cred_user="$1" + cred_token="$2" auth="$(printf '%s:%s' "$1" "$2" | base64 -w0)" mkdir -p /kaniko/.docker (umask 077; printf '{"auths":{"%s":{"auth":"%s"}}}\n' "$registry" "$auth" > /kaniko/.docker/config.json) @@ -205,6 +207,21 @@ jobs: echo "$method" > /kaniko/credential-method echo "Registry credential in use: $method" + # Gitea cannot make a tag immutable, so look the version tag up first: when it + # exists the build must not move it (the build step reads this marker). + code="$(printf 'user = "%s:%s"\n' "$cred_user" "$cred_token" \ + | curl -sS -o /dev/null -w '%{http_code}' -I -K - \ + -H 'Accept: application/vnd.oci.image.index.v1+json, application/vnd.oci.image.manifest.v1+json, application/vnd.docker.distribution.manifest.v2+json' \ + "https://${registry}/v2/${IMAGE_PATH}/manifests/${IMAGE_VERSION}" || true)" + case "$code" in + 200) touch /kaniko/version-published; echo "Version tag ${IMAGE_VERSION} is already published; it will not be moved." ;; + 404) echo "Version tag ${IMAGE_VERSION} is not published yet." ;; + *) + echo "::error::Unexpected HTTP status $code looking up the tag ${IMAGE_VERSION}; refusing to guess whether it is published." + exit 1 + ;; + esac + # Back to the pristine base image (see above): purge exactly what the install # added, then compare packages (names and versions) and files with the record. pkgs > /kaniko/pkgs.installed @@ -247,11 +264,16 @@ jobs: image="${registry}/${IMAGE_PATH}" short="${SHA:0:12}" - dests=(--destination "${image}:sha-${short}") - case "$REF" in - refs/heads/main) dests+=(--destination "${image}:latest") ;; - refs/tags/v*) dests+=(--destination "${image}:${REF_NAME}") ;; - esac + # /kaniko is removed when the build finishes, so read the marker now. + dests=(--destination "${image}:sha-${short}" --destination "${image}:latest") + version_new=true + if [ -e /kaniko/version-published ]; then + version_new=false + echo "::warning::${image}:${IMAGE_VERSION} is already published and is not moved;" \ + "bump the version in image.yml to release this build under a new tag." + else + dests+=(--destination "${image}:${IMAGE_VERSION}") + fi # Context: this commit of this repository, cloned by kaniko (##: # clone , check out ). With a sub-path only that directory is the @@ -285,12 +307,14 @@ jobs: echo "::error::kaniko finished but no pushed image digest was found in its output." exit 1 fi - echo "Pinned reference: ${image}@${digest}" + ref="${image}@${digest}" + if [ "$version_new" = true ]; then ref="${image}:${IMAGE_VERSION}@${digest}"; fi + echo "Pinned reference: ${ref}" if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then { echo "### ${IMAGE_PATH} pushed" echo - echo "Pin it by digest: \`${image}@${digest}\`" + echo "Pin it as: \`${ref}\`" } >> "$GITHUB_STEP_SUMMARY" || true fi From 605bd66ea4d874e56d33a1ab5ea894a37502352c Mon Sep 17 00:00:00 2001 From: Claude Code AI - Gitea MCP <3+claude@noreply.git.rkdr.net> Date: Sun, 25 Oct 2026 11:44:18 +0000 Subject: [PATCH 2/2] docs(image): update the trigger comment for the removed v* tag trigger Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm --- .gitea/workflows/image.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/image.yml b/.gitea/workflows/image.yml index 3acad2d..3089997 100644 --- a/.gitea/workflows/image.yml +++ b/.gitea/workflows/image.yml @@ -6,7 +6,7 @@ name: Molecule image # # Never on pull_request: a workflow file comes from the PR head, so a fork PR could # otherwise push to the registry. This workflow has no pull_request trigger, and the job -# `if:` repeats the rule for main, v* tags and manual dispatch only. +# `if:` repeats the rule: main only (pushes and manual dispatch from main). # # Design decisions (details in the PR description): # - Sources: the job container has no Node, so actions/checkout cannot run. Kaniko