From 411f964eb8d1438ea795d0995417d1b0c90aa08f Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Mon, 9 Nov 2026 12:52:47 +0100 Subject: [PATCH 01/13] Add the bake.yml reusable workflow One call builds and publishes everything a consumer's docker-bake.hcl defines: - plan works out the version, the push decision and the other bake variables once, runs docker buildx bake --print and freezes the result, so every later job sees identical tags and labels (created included). - build runs once per platform, building every target for that platform in one bake invocation, and pushes by digest. - publish merges the digests per target with imagetools create and copies the labels onto the index and its descriptors. - status reports the result as a single "Image" check. push now follows the event instead of github.actor: no push for dependabot pull requests (also when a person re-runs them), pull requests from forks, dependabot branches, or events the tag rules don't cover. Build secrets come in through one build-secrets secret. Every input reaches the scripts through env, and every action is pinned by commit SHA. The plan job warns when the consumer's vendored specs.hcl differs from bake/specs.hcl at this version, by comparing it with SPECS_HCL_SHA256; lint.yml checks that hash, and tests the plan job's version and push rules. test-bake.yml runs the workflow on a test image (pushing only on a manual run), and builds, loads and runs one target the way a consumer's pull request test would. --- .github/workflows/bake.yml | 453 ++++++++++++++++++++++++++++++++ .github/workflows/lint.yml | 4 + .github/workflows/test-bake.yml | 65 +++++ Taskfile.dist.yml | 13 +- bake/test/e2e/Dockerfile | 15 ++ bake/test/e2e/docker-bake.hcl | 33 +++ bake/test/plan.sh | 99 +++++++ bake/test/specs-hash.sh | 25 ++ 8 files changed, 703 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/bake.yml create mode 100644 .github/workflows/test-bake.yml create mode 100644 bake/test/e2e/Dockerfile create mode 100644 bake/test/e2e/docker-bake.hcl create mode 100755 bake/test/plan.sh create mode 100755 bake/test/specs-hash.sh diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml new file mode 100644 index 0000000..2956062 --- /dev/null +++ b/.github/workflows/bake.yml @@ -0,0 +1,453 @@ +name: Bake + +on: + workflow_call: + inputs: + files: + description: The consumer's bake files (multiline), read after specs-file. + type: string + default: docker-bake.hcl + specs-file: + description: >- + Path of the vendored copy of bake/specs.hcl. Read first, and compared with the copy this version of the + workflow expects. Set to an empty string if the bake files don't use it. + type: string + default: specs.hcl + targets: + description: Bake targets or groups to build (multiline). Defaults to the "default" group. + type: string + required: false + version: + description: >- + The VERSION bake variable. Defaults to the tag without its leading "v" on a tag push, "pr-" on a + pull request, the branch name on a branch push, "nightly" on a schedule and the dispatch tag on + workflow_dispatch. + type: string + required: false + dispatch-tag: + description: Tag published by a workflow_dispatch run. Lowercased. + type: string + default: latest + push: + description: >- + "true" or "false". Defaults to pushing, except for pull requests from dependabot or from a fork, pushes to + a dependabot branch, and events the tag rules don't cover. + type: string + required: false + runners: + description: >- + JSON object mapping a platform to its runner, merged over the default + {"linux/amd64": "ubuntu-24.04", "linux/arm64": "ubuntu-24.04-arm"}. + type: string + required: false + disable-apparmor: + description: Disable AppArmor on the build runners before building. + type: boolean + default: false + timeout-minutes: + description: Timeout of each build job. + type: number + default: 60 + secrets: + build-secrets: + description: >- + Build secrets as "NAME=value" lines. Each one is masked and exported as an environment variable to the + build, where the bake file refers to it with secret = ["id=,env=NAME"]. + required: false + outputs: + version: + description: The VERSION the images were built with. + value: ${{ jobs.plan.outputs.version }} + push: + description: Whether the images were pushed ("true" or "false"). + value: ${{ jobs.plan.outputs.push }} + +permissions: {} + +jobs: + + plan: + name: Plan + runs-on: ubuntu-24.04 + timeout-minutes: 10 + permissions: + contents: read + outputs: + version: ${{ steps.vars.outputs.version }} + push: ${{ steps.vars.outputs.push }} + matrix: ${{ steps.freeze.outputs.matrix }} + artifact: ${{ steps.freeze.outputs.artifact }} + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Work out the run's variables + id: vars + env: + INPUT_VERSION: ${{ inputs.version }} + INPUT_DISPATCH_TAG: ${{ inputs.dispatch-tag }} + INPUT_PUSH: ${{ inputs.push }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} + run: | + dispatch_tag="${INPUT_DISPATCH_TAG,,}" + dispatch_tag="${dispatch_tag:-latest}" + + version="$INPUT_VERSION" + if [ -z "$version" ]; then + case "$GITHUB_EVENT_NAME" in + push) + version="$GITHUB_REF_NAME" + if [ "$GITHUB_REF_TYPE" = tag ] && [[ $version =~ ^v[0-9] ]]; then + version="${version#v}" + fi + ;; + pull_request | pull_request_target) version="pr-$PR_NUMBER" ;; + schedule) version=nightly ;; + workflow_dispatch) version="$dispatch_tag" ;; + esac + fi + + is_stable=false + if [ "$GITHUB_EVENT_NAME" = push ] && [ "$GITHUB_REF_TYPE" = tag ] && [[ $version != *-* ]]; then + is_stable=true + fi + + push="$INPUT_PUSH" + if [ -z "$push" ]; then + push=true + case "$GITHUB_EVENT_NAME" in + pull_request | pull_request_target) + if [ "$PR_AUTHOR" = 'dependabot[bot]' ] || [ "$PR_HEAD_REPOSITORY" != "$GITHUB_REPOSITORY" ]; then + push=false + fi + ;; + push) + if [ "$GITHUB_REF_TYPE" = branch ] && [[ $GITHUB_REF_NAME == dependabot/* ]]; then + push=false + fi + ;; + schedule | workflow_dispatch) ;; + *) push=false ;; + esac + fi + if [ "$push" != true ] && [ "$push" != false ]; then + echo "::error::push must be \"true\" or \"false\", got \"$push\"." + exit 1 + fi + + delimiter="EOF_$(openssl rand -hex 16)" + { + echo "version<<$delimiter" + echo "$version" + echo "$delimiter" + echo "dispatch-tag<<$delimiter" + echo "$dispatch_tag" + echo "$delimiter" + echo "is-stable=$is_stable" + echo "push=$push" + echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" + } >> "$GITHUB_OUTPUT" + + - name: Compare specs.hcl + if: ${{ inputs.specs-file != '' }} + env: + SPECS_FILE: ${{ inputs.specs-file }} + SPECS_HCL_SHA256: aff6f204fd37325f5d0764a9b073608f35f9f87fe3e922a0259724084948e7cd + run: | + if [ ! -f "$SPECS_FILE" ]; then + echo "::error::$SPECS_FILE not found. Copy bake/specs.hcl from specsnl/github-actions at the version of bake.yml you use, or set specs-file to an empty string." + exit 1 + fi + actual=$(sha256sum "$SPECS_FILE" | cut -d' ' -f1) + if [ "$actual" != "$SPECS_HCL_SHA256" ]; then + echo "::warning file=$SPECS_FILE::$SPECS_FILE differs from bake/specs.hcl at the version of bake.yml you use. Copy that file over it." + fi + + - name: Freeze the bake definition + id: freeze + env: + FILES: ${{ inputs.files }} + SPECS_FILE: ${{ inputs.specs-file }} + TARGETS: ${{ inputs.targets }} + RUNNERS: ${{ inputs.runners }} + PUSH: ${{ steps.vars.outputs.push }} + VERSION: ${{ steps.vars.outputs.version }} + DISPATCH_TAG: ${{ steps.vars.outputs.dispatch-tag }} + IS_STABLE: ${{ steps.vars.outputs.is-stable }} + CREATED: ${{ steps.vars.outputs.created }} + EVENT: ${{ github.event_name }} + REF_TYPE: ${{ github.ref_type }} + REF_NAME: ${{ github.ref_name }} + PR_NUMBER: ${{ github.event.pull_request.number }} + REVISION: ${{ github.sha }} + SOURCE: ${{ github.server_url }}/${{ github.repository }} + run: | + trim() { sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d'; } + + files=() + while IFS= read -r file; do files+=(-f "$file"); done < <(printf '%s\n%s\n' "$SPECS_FILE" "$FILES" | trim) + mapfile -t targets < <(printf '%s\n' "$TARGETS" | trim) + + dir="$RUNNER_TEMP/bake" + mkdir -p "$dir" + docker buildx bake --progress=quiet "${files[@]}" --print "${targets[@]}" > "$dir/print.json" + if jq -e '(.target // {}) == {}' "$dir/print.json" > /dev/null; then + echo "::error::The bake files define no targets to build." + exit 1 + fi + + jq --arg push "$PUSH" ' + def image: .tags[0] | sub(":[^:/]*$"; ""); + .target |= with_entries( + if (.value.platforms // []) == [] then + error("target \(.key) has no platforms; set platforms in the bake file") + elif $push == "true" and (.value.tags // []) == [] then + error("target \(.key) has no tags for this event, so there is nothing to push") + else . end + ) + | .target |= map_values( + (if $push == "true" then + "type=image,name=\(image),push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + else + "type=cacheonly" + end) as $output + | del(.tags, .output, .["cache-from"], .["cache-to"], .load, .push) + | .output = [$output] + ) + | .group = {default: {targets: (.target | keys)}} + ' "$dir/print.json" > "$dir/definition.json" + + jq ' + .target | map_values({ + image: (.tags[0] // "" | sub(":[^:/]*$"; "")), + tags: (.tags // []), + labels: (.labels // {}), + platforms + }) + ' "$dir/print.json" > "$dir/publish.json" + + jq --argjson override "${RUNNERS:-"{}"}" ' + ({"linux/amd64": "ubuntu-24.04", "linux/arm64": "ubuntu-24.04-arm"} + $override) as $runners + | [.target[].platforms[]] | unique + | map({ + platform: ., + slug: gsub("[^A-Za-z0-9]+"; "-"), + runner: ($runners[.] // error("no runner for platform \(.); add it to the runners input")) + }) + ' "$dir/print.json" > "$dir/matrix.json" + + echo "matrix=$(jq -c . "$dir/matrix.json")" >> "$GITHUB_OUTPUT" + # Unique per call, so a caller can use this workflow more than once in a run. + echo "artifact=bake-$(printf '%s\n' "$SPECS_FILE" "$FILES" "$TARGETS" | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" + + { + echo '### Bake definition' + echo + echo "Version \`$VERSION\`, push \`$PUSH\`." + echo + echo '| Target | Platforms | Tags |' + echo '|--------|-----------|------|' + jq -r 'to_entries[] | "| `\(.key)` | \(.value.platforms | join(", ")) | \(.value.tags | map("`\(.)`") | join("
")) |"' "$dir/publish.json" + } >> "$GITHUB_STEP_SUMMARY" + + - name: Upload the bake definition + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: ${{ steps.freeze.outputs.artifact }}-definition + path: | + ${{ runner.temp }}/bake/definition.json + ${{ runner.temp }}/bake/publish.json + if-no-files-found: error + retention-days: 1 + + build: + name: Build ${{ matrix.platform }} + needs: plan + runs-on: ${{ matrix.runner }} + timeout-minutes: ${{ inputs.timeout-minutes }} + permissions: + contents: read + packages: write + strategy: + fail-fast: false + matrix: + include: ${{ fromJSON(needs.plan.outputs.matrix) }} + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Download the bake definition + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: ${{ needs.plan.outputs.artifact }}-definition + path: ${{ runner.temp }}/bake + + - name: Narrow the definition to ${{ matrix.platform }} + id: definition + env: + PLATFORM: ${{ matrix.platform }} + SLUG: ${{ matrix.slug }} + run: | + dir="$RUNNER_TEMP/bake" + jq --arg platform "$PLATFORM" --arg slug "$SLUG" --slurpfile publish "$dir/publish.json" ' + .target |= with_entries( + select(.value.platforms | index($platform)) + | ("\($publish[0][.key].image | gsub("[^A-Za-z0-9]+"; "-"))-\(.key)-\($slug)") as $scope + | .value.platforms = [$platform] + | .value["cache-from"] = ["type=gha,scope=\($scope)"] + | .value["cache-to"] = ["type=gha,mode=max,scope=\($scope)"] + ) + | .group = {default: {targets: (.target | keys)}} + ' "$dir/definition.json" > "$dir/definition-$SLUG.json" + echo "file=$dir/definition-$SLUG.json" >> "$GITHUB_OUTPUT" + + - name: Export the build secrets + env: + BUILD_SECRETS: ${{ secrets.build-secrets }} + run: | + while IFS= read -r line || [ -n "$line" ]; do + [ -z "${line//[[:space:]]/}" ] && continue + name="${line%%=*}" + value="${line#*=}" + if [ "$name" = "$line" ] || [[ ! $name =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then + echo "::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores." + exit 1 + fi + case "$name" in + GITHUB_* | RUNNER_* | ACTIONS_* | BUILDX_* | DOCKER_* | PATH | HOME | BASH_ENV | ENV | NODE_OPTIONS | LD_*) + echo "::error::build-secrets may not set $name." + exit 1 + ;; + esac + [ -n "$value" ] && echo "::add-mask::$value" + delimiter="EOF_$(openssl rand -hex 16)" + printf '%s<<%s\n%s\n%s\n' "$name" "$delimiter" "$value" "$delimiter" >> "$GITHUB_ENV" + done <<< "$BUILD_SECRETS" + + - name: Log in to the Container registry + if: ${{ needs.plan.outputs.push == 'true' }} + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Disable AppArmor + if: ${{ inputs.disable-apparmor }} + uses: cisagov/action-disable-apparmor@437d94f26a2e4bf8c03acfb500a6afc688b497db # v1.0.0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + + - name: Build + id: bake + uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 + env: + BUILDX_NO_DEFAULT_ATTESTATIONS: 1 + with: + source: . + files: ${{ steps.definition.outputs.file }} + + - name: Export the digests + if: ${{ needs.plan.outputs.push == 'true' }} + env: + METADATA: ${{ steps.bake.outputs.metadata }} + SLUG: ${{ matrix.slug }} + run: | + dir="$RUNNER_TEMP/digests" + mkdir -p "$dir" + jq ' + with_entries(select(.value | type == "object")) + | map_values(.["containerimage.digest"] // error("no digest in the build metadata")) + ' <<< "$METADATA" > "$dir/digests-$SLUG.json" + cat "$dir/digests-$SLUG.json" + + - name: Upload the digests + if: ${{ needs.plan.outputs.push == 'true' }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: ${{ needs.plan.outputs.artifact }}-digests-${{ matrix.slug }} + path: ${{ runner.temp }}/digests/digests-${{ matrix.slug }}.json + if-no-files-found: error + retention-days: 1 + + publish: + name: Publish + needs: [plan, build] + if: ${{ needs.plan.outputs.push == 'true' }} + runs-on: ubuntu-24.04 + timeout-minutes: 15 + permissions: + packages: write + steps: + + - name: Download the bake definition + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: ${{ needs.plan.outputs.artifact }}-definition + path: ${{ runner.temp }}/bake + + - name: Download the digests + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: ${{ needs.plan.outputs.artifact }}-digests-* + path: ${{ runner.temp }}/digests + merge-multiple: true + + - name: Log in to the Container registry + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create the manifests + run: | + publish="$RUNNER_TEMP/bake/publish.json" + digests=$(jq -s 'map(to_entries) | add | group_by(.key) | map({key: .[0].key, value: map(.value)}) | from_entries' "$RUNNER_TEMP"/digests/digests-*.json) + + for target in $(jq -r 'keys[]' "$publish"); do + image=$(jq -r --arg t "$target" '.[$t].image' "$publish") + mapfile -t tags < <(jq -r --arg t "$target" '.[$t].tags[]' "$publish") + mapfile -t annotations < <(jq -r --arg t "$target" ' + .[$t].labels | to_entries[] | "index:\(.key)=\(.value)", "manifest-descriptor:\(.key)=\(.value)" + ' "$publish") + mapfile -t sources < <(jq -r --arg t "$target" --arg image "$image" '(.[$t] // [])[] | "\($image)@\(.)"' <<< "$digests") + + expected=$(jq -r --arg t "$target" '.[$t].platforms | length' "$publish") + if [ "${#sources[@]}" -ne "$expected" ]; then + echo "::error::$target has ${#sources[@]} digests for $expected platforms." + exit 1 + fi + + args=() + for tag in "${tags[@]}"; do args+=(--tag "$tag"); done + for annotation in "${annotations[@]}"; do args+=(--annotation "$annotation"); done + + echo "::group::$target" + docker buildx imagetools create "${args[@]}" "${sources[@]}" + docker buildx imagetools inspect "${tags[0]}" + echo "::endgroup::" + done + + status: + name: Image + needs: [plan, build, publish] + if: ${{ always() }} + runs-on: ubuntu-24.04 + timeout-minutes: 5 + steps: + - name: Check the results + env: + NEEDS: ${{ toJSON(needs) }} + run: | + jq -r 'to_entries[] | "\(.key): \(.value.result)"' <<< "$NEEDS" + jq -e '.plan.result == "success" and all(.[]; .result == "success" or .result == "skipped")' <<< "$NEEDS" > /dev/null diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a4989e2..c2b7137 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,3 +35,7 @@ jobs: persist-credentials: false - name: Run the specs.hcl fixture tests run: bake/test/run.sh + - name: Run the plan job tests + run: bake/test/plan.sh + - name: Check SPECS_HCL_SHA256 + run: bake/test/specs-hash.sh diff --git a/.github/workflows/test-bake.yml b/.github/workflows/test-bake.yml new file mode 100644 index 0000000..218e884 --- /dev/null +++ b/.github/workflows/test-bake.yml @@ -0,0 +1,65 @@ +name: Test bake.yml + +on: + pull_request: + push: + branches: [main] + workflow_dispatch: + inputs: + push: + description: Push the test images to ghcr.io/specsnl/github-actions/e2e + type: boolean + default: false + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + + bake: + name: Bake + uses: ./.github/workflows/bake.yml + permissions: + contents: read + packages: write + with: + files: bake/test/e2e/docker-bake.hcl + specs-file: bake/specs.hcl + push: ${{ inputs.push && 'true' || 'false' }} + secrets: + build-secrets: E2E_SECRET=e2e-secret + + load: + name: Load + runs-on: ubuntu-24.04 + timeout-minutes: 15 + permissions: + contents: read + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@f87e5991a6d7451dcb8d9637bfbc97413f497069 # v4.4.1 + + - name: Build and load + uses: docker/bake-action@59cb1203cd42bcefd40a1b6d73b589e48c86040e # v7.5.0 + env: + VERSION: ci + with: + source: . + files: | + bake/specs.hcl + bake/test/e2e/docker-bake.hcl + targets: cli-debian + load: true + set: '*.platform=linux/amd64' + + - name: Run + run: test "$(docker run --rm ghcr.io/specsnl/github-actions/e2e-cli:local)" = "debian ci" diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index fe7103b..8e791dc 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -14,9 +14,14 @@ tasks: rhysd/actionlint:{{.ACTIONLINT_TAG_VERSION}} test: - desc: Run the bake/specs.hcl fixture tests - cmd: bake/test/run.sh + desc: Run the bake/specs.hcl fixture tests and the bake.yml plan job tests + cmds: + - bake/test/run.sh + - bake/test/plan.sh + - bake/test/specs-hash.sh test:update: - desc: Rewrite the expected output of the bake/specs.hcl fixture tests - cmd: bake/test/run.sh --update + desc: Rewrite the expected output of the specs.hcl fixture tests, and bake.yml's SPECS_HCL_SHA256 + cmds: + - bake/test/run.sh --update + - bake/test/specs-hash.sh --update diff --git a/bake/test/e2e/Dockerfile b/bake/test/e2e/Dockerfile new file mode 100644 index 0000000..53ceb28 --- /dev/null +++ b/bake/test/e2e/Dockerfile @@ -0,0 +1,15 @@ +FROM busybox:1.37 AS base + +FROM base AS app +RUN --mount=type=secret,id=e2e,env=E2E_SECRET test "$E2E_SECRET" = e2e-secret +CMD ["echo", "app"] + +FROM base AS debian +ARG E2E_VERSION=dev +RUN echo "debian $E2E_VERSION" > /version +CMD ["cat", "/version"] + +FROM base AS alpine +ARG E2E_VERSION=dev +RUN echo "alpine $E2E_VERSION" > /version +CMD ["cat", "/version"] diff --git a/bake/test/e2e/docker-bake.hcl b/bake/test/e2e/docker-bake.hcl new file mode 100644 index 0000000..927baf8 --- /dev/null +++ b/bake/test/e2e/docker-bake.hcl @@ -0,0 +1,33 @@ +variable "IMAGE" { + default = "ghcr.io/specsnl/github-actions/e2e" +} + +group "default" { + targets = ["app", "cli"] +} + +target "_e2e" { + context = "bake/test/e2e" +} + +target "app" { + inherits = ["_e2e"] + target = "app" + platforms = ["linux/amd64", "linux/arm64"] + secret = ["id=e2e,env=E2E_SECRET"] + tags = specs_tags([IMAGE], "") + labels = specs_labels("e2e app", "End-to-end test image of specsnl/github-actions") + annotations = specs_annotations("e2e app", "End-to-end test image of specsnl/github-actions") +} + +target "cli" { + name = "cli-${variant}" + matrix = { variant = ["debian", "alpine"] } + inherits = ["_e2e"] + target = variant + platforms = variant == "debian" ? ["linux/amd64", "linux/arm64"] : ["linux/amd64"] + args = { E2E_VERSION = VERSION } + tags = specs_tags(["${IMAGE}-cli"], variant == "debian" ? "" : variant) + labels = specs_labels("e2e cli", "") + annotations = specs_annotations("e2e cli", "") +} diff --git a/bake/test/plan.sh b/bake/test/plan.sh new file mode 100755 index 0000000..b53108b --- /dev/null +++ b/bake/test/plan.sh @@ -0,0 +1,99 @@ +#!/usr/bin/env bash +# Runs the "vars" step of bake.yml's plan job for a set of GitHub contexts and checks its outputs. +set -euo pipefail + +cd "$(dirname "$0")/../.." + +script=$(yq '.jobs.plan.steps[] | select(.id == "vars") | .run' .github/workflows/bake.yml) +failed=0 + +# check +check() { + local description="$1" expected="$2" + shift 2 + + local output status=0 actual + output=$(mktemp) + env -i PATH="$PATH" GITHUB_OUTPUT="$output" GITHUB_REPOSITORY=specsnl/example "$@" bash -e -c "$script" > /dev/null 2>&1 || status=$? + + if [ "$status" -ne 0 ]; then + actual="exit=$status" + else + actual=$(awk ' + /< /dev/null; then + actual=$(sha256sum bake/specs.hcl | cut -d' ' -f1) +else + actual=$(shasum -a 256 bake/specs.hcl | cut -d' ' -f1) +fi +expected=$(yq "$path" "$workflow") + +if [ "${1:-}" = "--update" ]; then + sed -i.bak "s/SPECS_HCL_SHA256: $expected/SPECS_HCL_SHA256: $actual/" "$workflow" && rm "$workflow.bak" + echo "SPECS_HCL_SHA256 is now $actual" +elif [ "$actual" != "$expected" ]; then + echo "SPECS_HCL_SHA256 in $workflow is $expected, but bake/specs.hcl hashes to $actual. Run: task test:update" + exit 1 +else + echo "ok SPECS_HCL_SHA256" +fi From 02c7a452be508ccd9dbc435609b19bcff93c779b Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Mon, 9 Nov 2026 13:29:51 +0100 Subject: [PATCH 02/13] Default bake.yml to ubuntu-26.04 runners and call it with $/ in its test --- .github/workflows/bake.yml | 10 +++++----- .github/workflows/test-bake.yml | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 2956062..4c079e3 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -37,7 +37,7 @@ on: runners: description: >- JSON object mapping a platform to its runner, merged over the default - {"linux/amd64": "ubuntu-24.04", "linux/arm64": "ubuntu-24.04-arm"}. + {"linux/amd64": "ubuntu-26.04", "linux/arm64": "ubuntu-26.04-arm"}. type: string required: false disable-apparmor: @@ -68,7 +68,7 @@ jobs: plan: name: Plan - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 10 permissions: contents: read @@ -232,7 +232,7 @@ jobs: ' "$dir/print.json" > "$dir/publish.json" jq --argjson override "${RUNNERS:-"{}"}" ' - ({"linux/amd64": "ubuntu-24.04", "linux/arm64": "ubuntu-24.04-arm"} + $override) as $runners + ({"linux/amd64": "ubuntu-26.04", "linux/arm64": "ubuntu-26.04-arm"} + $override) as $runners | [.target[].platforms[]] | unique | map({ platform: ., @@ -383,7 +383,7 @@ jobs: name: Publish needs: [plan, build] if: ${{ needs.plan.outputs.push == 'true' }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 15 permissions: packages: write @@ -442,7 +442,7 @@ jobs: name: Image needs: [plan, build, publish] if: ${{ always() }} - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 5 steps: - name: Check the results diff --git a/.github/workflows/test-bake.yml b/.github/workflows/test-bake.yml index 218e884..71f7828 100644 --- a/.github/workflows/test-bake.yml +++ b/.github/workflows/test-bake.yml @@ -21,7 +21,7 @@ jobs: bake: name: Bake - uses: ./.github/workflows/bake.yml + uses: $/.github/workflows/bake.yml permissions: contents: read packages: write @@ -34,7 +34,7 @@ jobs: load: name: Load - runs-on: ubuntu-24.04 + runs-on: ubuntu-26.04 timeout-minutes: 15 permissions: contents: read From 66dda659a25e9dc420ff8d3d81d641cd40eb71fe Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Mon, 9 Nov 2026 13:30:12 +0100 Subject: [PATCH 03/13] Ignore actionlint's errors for the $/ self-repository syntax --- .github/actionlint.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml index a621881..19e8e2f 100644 --- a/.github/actionlint.yaml +++ b/.github/actionlint.yaml @@ -3,3 +3,10 @@ self-hosted-runner: labels: - ubuntu-26.04 - ubuntu-26.04-arm + +paths: + .github/workflows/**/*.{yml,yaml}: + ignore: + # actionlint 1.7.12 doesn't know GitHub's "$/" self-repository syntax yet: rhysd/actionlint#711 + - 'reusable workflow call "\$/.+" at "uses" is not following the format' + - 'specifying action "\$/.+" in invalid format because ref is missing' From af1c3617e4ecb07ea7782c959537445e78a83126 Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Mon, 9 Nov 2026 14:57:16 +0100 Subject: [PATCH 04/13] Read the repository's name, description and license in the plan job They reach bake as REPOSITORY_NAME, REPOSITORY_DESCRIPTION and LICENSES, the fallbacks specs_labels uses for the title, description and licenses labels, so a migrated image keeps the labels metadata-action gave it. The repository is read once from the GitHub API with the token's contents: read; an unrecognised license (NOASSERTION) is left out. SPECS_HCL_SHA256 follows the specs.hcl change. --- .github/workflows/bake.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 4c079e3..848e798 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -157,7 +157,7 @@ jobs: if: ${{ inputs.specs-file != '' }} env: SPECS_FILE: ${{ inputs.specs-file }} - SPECS_HCL_SHA256: aff6f204fd37325f5d0764a9b073608f35f9f87fe3e922a0259724084948e7cd + SPECS_HCL_SHA256: 614358730448525dc70538f509930a0e0c85b21f0d6d8f04016ac1089797d4c8 run: | if [ ! -f "$SPECS_FILE" ]; then echo "::error::$SPECS_FILE not found. Copy bake/specs.hcl from specsnl/github-actions at the version of bake.yml you use, or set specs-file to an empty string." @@ -168,6 +168,23 @@ jobs: echo "::warning file=$SPECS_FILE::$SPECS_FILE differs from bake/specs.hcl at the version of bake.yml you use. Copy that file over it." fi + - name: Read the repository + id: repository + env: + GH_TOKEN: ${{ github.token }} + run: | + gh api "repos/$GITHUB_REPOSITORY" > "$RUNNER_TEMP/repository.json" + delimiter="EOF_$(openssl rand -hex 16)" + { + echo "name<<$delimiter" + jq -r '.name' "$RUNNER_TEMP/repository.json" + echo "$delimiter" + echo "description<<$delimiter" + jq -r '.description // ""' "$RUNNER_TEMP/repository.json" + echo "$delimiter" + echo "license=$(jq -r '.license.spdx_id // "" | select(. != "NOASSERTION")' "$RUNNER_TEMP/repository.json")" + } >> "$GITHUB_OUTPUT" + - name: Freeze the bake definition id: freeze env: @@ -186,6 +203,9 @@ jobs: PR_NUMBER: ${{ github.event.pull_request.number }} REVISION: ${{ github.sha }} SOURCE: ${{ github.server_url }}/${{ github.repository }} + REPOSITORY_NAME: ${{ steps.repository.outputs.name }} + REPOSITORY_DESCRIPTION: ${{ steps.repository.outputs.description }} + LICENSES: ${{ steps.repository.outputs.license }} run: | trim() { sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d'; } From 04574b746acc3f3a3dc836b2504398308d2f1750 Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Tue, 10 Nov 2026 20:53:54 +0100 Subject: [PATCH 05/13] Move bake.yml's scripts into composite actions that ship specs.hcl Every scripted step of bake.yml is now a script in a small composite action under bake/ (plan, narrow, secrets, digests, publish), called with the $/ self-repository syntax so it runs at the same commit as bake.yml. The larger jq programs live in .jq files next to the scripts, and the scripts share their output helpers in bake/lib.sh. The plan action reads bake/specs.hcl from its own checkout before the caller's bake files, so consumers no longer keep a copy of it. The specs-file input, SPECS_HCL_SHA256 and its check are gone; a local build fetches specs.hcl at the commit the caller pins bake.yml to. The tests now run the scripts directly: vars.sh for the plan variables, secrets.sh for the build secrets parsing, and pipeline.sh for freeze, narrow, digests and publish end to end, against golden files and with a docker that only records the imagetools calls. Shellcheck lints the scripts, locally and in CI. --- .github/workflows/bake.yml | 307 ++------------- .github/workflows/lint.yml | 14 +- .github/workflows/test-bake.yml | 1 - .shellcheckrc | 1 + Taskfile.dist.yml | 28 +- bake/digests/action.yml | 22 ++ bake/digests/digests.sh | 14 + bake/lib.sh | 24 ++ bake/narrow/action.yml | 27 ++ bake/narrow/narrow.jq | 9 + bake/narrow/narrow.sh | 14 + bake/plan/action.yml | 87 +++++ bake/plan/definition.jq | 21 + bake/plan/freeze.sh | 53 +++ bake/plan/matrix.jq | 8 + bake/plan/publish.jq | 8 + bake/plan/repository.sh | 15 + bake/plan/vars.sh | 62 +++ bake/publish/action.yml | 11 + bake/publish/publish.sh | 33 ++ bake/secrets/action.yml | 17 + bake/secrets/secrets.sh | 27 ++ bake/specs.hcl | 8 +- bake/test/pipeline.sh | 143 +++++++ bake/test/pipeline/pr.txt | 452 +++++++++++++++++++++ bake/test/pipeline/tag-stable.txt | 628 ++++++++++++++++++++++++++++++ bake/test/secrets.sh | 70 ++++ bake/test/specs-hash.sh | 25 -- bake/test/{plan.sh => vars.sh} | 8 +- 29 files changed, 1812 insertions(+), 325 deletions(-) create mode 100644 .shellcheckrc create mode 100644 bake/digests/action.yml create mode 100755 bake/digests/digests.sh create mode 100644 bake/lib.sh create mode 100644 bake/narrow/action.yml create mode 100644 bake/narrow/narrow.jq create mode 100755 bake/narrow/narrow.sh create mode 100644 bake/plan/action.yml create mode 100644 bake/plan/definition.jq create mode 100755 bake/plan/freeze.sh create mode 100644 bake/plan/matrix.jq create mode 100644 bake/plan/publish.jq create mode 100755 bake/plan/repository.sh create mode 100755 bake/plan/vars.sh create mode 100644 bake/publish/action.yml create mode 100755 bake/publish/publish.sh create mode 100644 bake/secrets/action.yml create mode 100755 bake/secrets/secrets.sh create mode 100755 bake/test/pipeline.sh create mode 100644 bake/test/pipeline/pr.txt create mode 100644 bake/test/pipeline/tag-stable.txt create mode 100755 bake/test/secrets.sh delete mode 100755 bake/test/specs-hash.sh rename bake/test/{plan.sh => vars.sh} (93%) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 848e798..4cac39a 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -4,15 +4,11 @@ on: workflow_call: inputs: files: - description: The consumer's bake files (multiline), read after specs-file. - type: string - default: docker-bake.hcl - specs-file: description: >- - Path of the vendored copy of bake/specs.hcl. Read first, and compared with the copy this version of the - workflow expects. Set to an empty string if the bake files don't use it. + The consumer's bake files (multiline). The workflow reads its own bake/specs.hcl first, at the version of + this workflow, so the bake files can use its functions without a copy of it. type: string - default: specs.hcl + default: docker-bake.hcl targets: description: Bake targets or groups to build (multiline). Defaults to the "default" group. type: string @@ -73,10 +69,10 @@ jobs: permissions: contents: read outputs: - version: ${{ steps.vars.outputs.version }} - push: ${{ steps.vars.outputs.push }} - matrix: ${{ steps.freeze.outputs.matrix }} - artifact: ${{ steps.freeze.outputs.artifact }} + version: ${{ steps.plan.outputs.version }} + push: ${{ steps.plan.outputs.push }} + matrix: ${{ steps.plan.outputs.matrix }} + artifact: ${{ steps.plan.outputs.artifact }} steps: - name: Checkout @@ -84,201 +80,21 @@ jobs: with: persist-credentials: false - - name: Work out the run's variables - id: vars - env: - INPUT_VERSION: ${{ inputs.version }} - INPUT_DISPATCH_TAG: ${{ inputs.dispatch-tag }} - INPUT_PUSH: ${{ inputs.push }} - PR_NUMBER: ${{ github.event.pull_request.number }} - PR_AUTHOR: ${{ github.event.pull_request.user.login }} - PR_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} - run: | - dispatch_tag="${INPUT_DISPATCH_TAG,,}" - dispatch_tag="${dispatch_tag:-latest}" - - version="$INPUT_VERSION" - if [ -z "$version" ]; then - case "$GITHUB_EVENT_NAME" in - push) - version="$GITHUB_REF_NAME" - if [ "$GITHUB_REF_TYPE" = tag ] && [[ $version =~ ^v[0-9] ]]; then - version="${version#v}" - fi - ;; - pull_request | pull_request_target) version="pr-$PR_NUMBER" ;; - schedule) version=nightly ;; - workflow_dispatch) version="$dispatch_tag" ;; - esac - fi - - is_stable=false - if [ "$GITHUB_EVENT_NAME" = push ] && [ "$GITHUB_REF_TYPE" = tag ] && [[ $version != *-* ]]; then - is_stable=true - fi - - push="$INPUT_PUSH" - if [ -z "$push" ]; then - push=true - case "$GITHUB_EVENT_NAME" in - pull_request | pull_request_target) - if [ "$PR_AUTHOR" = 'dependabot[bot]' ] || [ "$PR_HEAD_REPOSITORY" != "$GITHUB_REPOSITORY" ]; then - push=false - fi - ;; - push) - if [ "$GITHUB_REF_TYPE" = branch ] && [[ $GITHUB_REF_NAME == dependabot/* ]]; then - push=false - fi - ;; - schedule | workflow_dispatch) ;; - *) push=false ;; - esac - fi - if [ "$push" != true ] && [ "$push" != false ]; then - echo "::error::push must be \"true\" or \"false\", got \"$push\"." - exit 1 - fi - - delimiter="EOF_$(openssl rand -hex 16)" - { - echo "version<<$delimiter" - echo "$version" - echo "$delimiter" - echo "dispatch-tag<<$delimiter" - echo "$dispatch_tag" - echo "$delimiter" - echo "is-stable=$is_stable" - echo "push=$push" - echo "created=$(date -u +%Y-%m-%dT%H:%M:%SZ)" - } >> "$GITHUB_OUTPUT" - - - name: Compare specs.hcl - if: ${{ inputs.specs-file != '' }} - env: - SPECS_FILE: ${{ inputs.specs-file }} - SPECS_HCL_SHA256: 614358730448525dc70538f509930a0e0c85b21f0d6d8f04016ac1089797d4c8 - run: | - if [ ! -f "$SPECS_FILE" ]; then - echo "::error::$SPECS_FILE not found. Copy bake/specs.hcl from specsnl/github-actions at the version of bake.yml you use, or set specs-file to an empty string." - exit 1 - fi - actual=$(sha256sum "$SPECS_FILE" | cut -d' ' -f1) - if [ "$actual" != "$SPECS_HCL_SHA256" ]; then - echo "::warning file=$SPECS_FILE::$SPECS_FILE differs from bake/specs.hcl at the version of bake.yml you use. Copy that file over it." - fi - - - name: Read the repository - id: repository - env: - GH_TOKEN: ${{ github.token }} - run: | - gh api "repos/$GITHUB_REPOSITORY" > "$RUNNER_TEMP/repository.json" - delimiter="EOF_$(openssl rand -hex 16)" - { - echo "name<<$delimiter" - jq -r '.name' "$RUNNER_TEMP/repository.json" - echo "$delimiter" - echo "description<<$delimiter" - jq -r '.description // ""' "$RUNNER_TEMP/repository.json" - echo "$delimiter" - echo "license=$(jq -r '.license.spdx_id // "" | select(. != "NOASSERTION")' "$RUNNER_TEMP/repository.json")" - } >> "$GITHUB_OUTPUT" - - - name: Freeze the bake definition - id: freeze - env: - FILES: ${{ inputs.files }} - SPECS_FILE: ${{ inputs.specs-file }} - TARGETS: ${{ inputs.targets }} - RUNNERS: ${{ inputs.runners }} - PUSH: ${{ steps.vars.outputs.push }} - VERSION: ${{ steps.vars.outputs.version }} - DISPATCH_TAG: ${{ steps.vars.outputs.dispatch-tag }} - IS_STABLE: ${{ steps.vars.outputs.is-stable }} - CREATED: ${{ steps.vars.outputs.created }} - EVENT: ${{ github.event_name }} - REF_TYPE: ${{ github.ref_type }} - REF_NAME: ${{ github.ref_name }} - PR_NUMBER: ${{ github.event.pull_request.number }} - REVISION: ${{ github.sha }} - SOURCE: ${{ github.server_url }}/${{ github.repository }} - REPOSITORY_NAME: ${{ steps.repository.outputs.name }} - REPOSITORY_DESCRIPTION: ${{ steps.repository.outputs.description }} - LICENSES: ${{ steps.repository.outputs.license }} - run: | - trim() { sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d'; } - - files=() - while IFS= read -r file; do files+=(-f "$file"); done < <(printf '%s\n%s\n' "$SPECS_FILE" "$FILES" | trim) - mapfile -t targets < <(printf '%s\n' "$TARGETS" | trim) - - dir="$RUNNER_TEMP/bake" - mkdir -p "$dir" - docker buildx bake --progress=quiet "${files[@]}" --print "${targets[@]}" > "$dir/print.json" - if jq -e '(.target // {}) == {}' "$dir/print.json" > /dev/null; then - echo "::error::The bake files define no targets to build." - exit 1 - fi - - jq --arg push "$PUSH" ' - def image: .tags[0] | sub(":[^:/]*$"; ""); - .target |= with_entries( - if (.value.platforms // []) == [] then - error("target \(.key) has no platforms; set platforms in the bake file") - elif $push == "true" and (.value.tags // []) == [] then - error("target \(.key) has no tags for this event, so there is nothing to push") - else . end - ) - | .target |= map_values( - (if $push == "true" then - "type=image,name=\(image),push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - else - "type=cacheonly" - end) as $output - | del(.tags, .output, .["cache-from"], .["cache-to"], .load, .push) - | .output = [$output] - ) - | .group = {default: {targets: (.target | keys)}} - ' "$dir/print.json" > "$dir/definition.json" - - jq ' - .target | map_values({ - image: (.tags[0] // "" | sub(":[^:/]*$"; "")), - tags: (.tags // []), - labels: (.labels // {}), - platforms - }) - ' "$dir/print.json" > "$dir/publish.json" - - jq --argjson override "${RUNNERS:-"{}"}" ' - ({"linux/amd64": "ubuntu-26.04", "linux/arm64": "ubuntu-26.04-arm"} + $override) as $runners - | [.target[].platforms[]] | unique - | map({ - platform: ., - slug: gsub("[^A-Za-z0-9]+"; "-"), - runner: ($runners[.] // error("no runner for platform \(.); add it to the runners input")) - }) - ' "$dir/print.json" > "$dir/matrix.json" - - echo "matrix=$(jq -c . "$dir/matrix.json")" >> "$GITHUB_OUTPUT" - # Unique per call, so a caller can use this workflow more than once in a run. - echo "artifact=bake-$(printf '%s\n' "$SPECS_FILE" "$FILES" "$TARGETS" | sha256sum | cut -c1-12)" >> "$GITHUB_OUTPUT" - - { - echo '### Bake definition' - echo - echo "Version \`$VERSION\`, push \`$PUSH\`." - echo - echo '| Target | Platforms | Tags |' - echo '|--------|-----------|------|' - jq -r 'to_entries[] | "| `\(.key)` | \(.value.platforms | join(", ")) | \(.value.tags | map("`\(.)`") | join("
")) |"' "$dir/publish.json" - } >> "$GITHUB_STEP_SUMMARY" + - name: Plan + id: plan + uses: $/bake/plan + with: + files: ${{ inputs.files }} + targets: ${{ inputs.targets }} + version: ${{ inputs.version }} + dispatch-tag: ${{ inputs.dispatch-tag }} + push: ${{ inputs.push }} + runners: ${{ inputs.runners }} - name: Upload the bake definition uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ${{ steps.freeze.outputs.artifact }}-definition + name: ${{ steps.plan.outputs.artifact }}-definition path: | ${{ runner.temp }}/bake/definition.json ${{ runner.temp }}/bake/publish.json @@ -312,45 +128,15 @@ jobs: - name: Narrow the definition to ${{ matrix.platform }} id: definition - env: - PLATFORM: ${{ matrix.platform }} - SLUG: ${{ matrix.slug }} - run: | - dir="$RUNNER_TEMP/bake" - jq --arg platform "$PLATFORM" --arg slug "$SLUG" --slurpfile publish "$dir/publish.json" ' - .target |= with_entries( - select(.value.platforms | index($platform)) - | ("\($publish[0][.key].image | gsub("[^A-Za-z0-9]+"; "-"))-\(.key)-\($slug)") as $scope - | .value.platforms = [$platform] - | .value["cache-from"] = ["type=gha,scope=\($scope)"] - | .value["cache-to"] = ["type=gha,mode=max,scope=\($scope)"] - ) - | .group = {default: {targets: (.target | keys)}} - ' "$dir/definition.json" > "$dir/definition-$SLUG.json" - echo "file=$dir/definition-$SLUG.json" >> "$GITHUB_OUTPUT" + uses: $/bake/narrow + with: + platform: ${{ matrix.platform }} + slug: ${{ matrix.slug }} - name: Export the build secrets - env: - BUILD_SECRETS: ${{ secrets.build-secrets }} - run: | - while IFS= read -r line || [ -n "$line" ]; do - [ -z "${line//[[:space:]]/}" ] && continue - name="${line%%=*}" - value="${line#*=}" - if [ "$name" = "$line" ] || [[ ! $name =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then - echo "::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores." - exit 1 - fi - case "$name" in - GITHUB_* | RUNNER_* | ACTIONS_* | BUILDX_* | DOCKER_* | PATH | HOME | BASH_ENV | ENV | NODE_OPTIONS | LD_*) - echo "::error::build-secrets may not set $name." - exit 1 - ;; - esac - [ -n "$value" ] && echo "::add-mask::$value" - delimiter="EOF_$(openssl rand -hex 16)" - printf '%s<<%s\n%s\n%s\n' "$name" "$delimiter" "$value" "$delimiter" >> "$GITHUB_ENV" - done <<< "$BUILD_SECRETS" + uses: $/bake/secrets + with: + secrets: ${{ secrets.build-secrets }} - name: Log in to the Container registry if: ${{ needs.plan.outputs.push == 'true' }} @@ -378,17 +164,10 @@ jobs: - name: Export the digests if: ${{ needs.plan.outputs.push == 'true' }} - env: - METADATA: ${{ steps.bake.outputs.metadata }} - SLUG: ${{ matrix.slug }} - run: | - dir="$RUNNER_TEMP/digests" - mkdir -p "$dir" - jq ' - with_entries(select(.value | type == "object")) - | map_values(.["containerimage.digest"] // error("no digest in the build metadata")) - ' <<< "$METADATA" > "$dir/digests-$SLUG.json" - cat "$dir/digests-$SLUG.json" + uses: $/bake/digests + with: + metadata: ${{ steps.bake.outputs.metadata }} + slug: ${{ matrix.slug }} - name: Upload the digests if: ${{ needs.plan.outputs.push == 'true' }} @@ -430,33 +209,7 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} - name: Create the manifests - run: | - publish="$RUNNER_TEMP/bake/publish.json" - digests=$(jq -s 'map(to_entries) | add | group_by(.key) | map({key: .[0].key, value: map(.value)}) | from_entries' "$RUNNER_TEMP"/digests/digests-*.json) - - for target in $(jq -r 'keys[]' "$publish"); do - image=$(jq -r --arg t "$target" '.[$t].image' "$publish") - mapfile -t tags < <(jq -r --arg t "$target" '.[$t].tags[]' "$publish") - mapfile -t annotations < <(jq -r --arg t "$target" ' - .[$t].labels | to_entries[] | "index:\(.key)=\(.value)", "manifest-descriptor:\(.key)=\(.value)" - ' "$publish") - mapfile -t sources < <(jq -r --arg t "$target" --arg image "$image" '(.[$t] // [])[] | "\($image)@\(.)"' <<< "$digests") - - expected=$(jq -r --arg t "$target" '.[$t].platforms | length' "$publish") - if [ "${#sources[@]}" -ne "$expected" ]; then - echo "::error::$target has ${#sources[@]} digests for $expected platforms." - exit 1 - fi - - args=() - for tag in "${tags[@]}"; do args+=(--tag "$tag"); done - for annotation in "${annotations[@]}"; do args+=(--annotation "$annotation"); done - - echo "::group::$target" - docker buildx imagetools create "${args[@]}" "${sources[@]}" - docker buildx imagetools inspect "${tags[0]}" - echo "::endgroup::" - done + uses: $/bake/publish status: name: Image diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c2b7137..696955b 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,7 +35,13 @@ jobs: persist-credentials: false - name: Run the specs.hcl fixture tests run: bake/test/run.sh - - name: Run the plan job tests - run: bake/test/plan.sh - - name: Check SPECS_HCL_SHA256 - run: bake/test/specs-hash.sh + - name: Run the plan tests + run: bake/test/vars.sh + - name: Run the build secrets tests + run: bake/test/secrets.sh + - name: Run the pipeline tests + run: bake/test/pipeline.sh + - name: Run shellcheck + run: >- + docker run --rm --volume "$PWD:/mnt" --workdir /mnt koalaman/shellcheck:v0.11.0 + bake/lib.sh bake/*/*.sh bake/test/*.sh diff --git a/.github/workflows/test-bake.yml b/.github/workflows/test-bake.yml index 71f7828..20be1a8 100644 --- a/.github/workflows/test-bake.yml +++ b/.github/workflows/test-bake.yml @@ -27,7 +27,6 @@ jobs: packages: write with: files: bake/test/e2e/docker-bake.hcl - specs-file: bake/specs.hcl push: ${{ inputs.push && 'true' || 'false' }} secrets: build-secrets: E2E_SECRET=e2e-secret diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..472bfba --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1 @@ +source-path=SCRIPTDIR diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index 8e791dc..1d0edd6 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -4,24 +4,32 @@ silent: true vars: ACTIONLINT_TAG_VERSION: "1.7.12" + SHELLCHECK_TAG_VERSION: "v0.11.0" tasks: lint: - desc: Lint GitHub Actions workflow files using actionlint - cmd: docker run --rm - --volume "{{.ROOT_DIR}}:/workdir" - --workdir /workdir - rhysd/actionlint:{{.ACTIONLINT_TAG_VERSION}} + desc: Lint GitHub Actions workflow files using actionlint, and the bake scripts using shellcheck + cmds: + - docker run --rm + --volume "{{.ROOT_DIR}}:/workdir" + --workdir /workdir + rhysd/actionlint:{{.ACTIONLINT_TAG_VERSION}} + - docker run --rm + --volume "{{.ROOT_DIR}}:/workdir" + --workdir /workdir + koalaman/shellcheck:{{.SHELLCHECK_TAG_VERSION}} + bake/lib.sh bake/*/*.sh bake/test/*.sh test: - desc: Run the bake/specs.hcl fixture tests and the bake.yml plan job tests + desc: Run the bake/specs.hcl fixture tests and the tests of the bake actions' scripts cmds: - bake/test/run.sh - - bake/test/plan.sh - - bake/test/specs-hash.sh + - bake/test/vars.sh + - bake/test/secrets.sh + - bake/test/pipeline.sh test:update: - desc: Rewrite the expected output of the specs.hcl fixture tests, and bake.yml's SPECS_HCL_SHA256 + desc: Rewrite the expected output of the specs.hcl fixture tests and the pipeline tests cmds: - bake/test/run.sh --update - - bake/test/specs-hash.sh --update + - bake/test/pipeline.sh --update diff --git a/bake/digests/action.yml b/bake/digests/action.yml new file mode 100644 index 0000000..0a16aa1 --- /dev/null +++ b/bake/digests/action.yml @@ -0,0 +1,22 @@ +name: Bake digests +description: >- + Internal to .github/workflows/bake.yml. Writes the digests of a build job's images to + $RUNNER_TEMP/digests/digests-.json. + +inputs: + metadata: + description: The metadata output of docker/bake-action. + required: true + slug: + description: The platform as a name, i.e. "linux-amd64". + required: true + +runs: + using: composite + steps: + - name: Export the digests + shell: bash + env: + METADATA: ${{ inputs.metadata }} + SLUG: ${{ inputs.slug }} + run: bash "$GITHUB_ACTION_PATH/digests.sh" diff --git a/bake/digests/digests.sh b/bake/digests/digests.sh new file mode 100755 index 0000000..07abe3f --- /dev/null +++ b/bake/digests/digests.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Writes the image digest of every target in bake's build metadata to $RUNNER_TEMP/digests/digests-$SLUG.json, as +# {"": ""}. +# +# Reads METADATA and SLUG. +set -euo pipefail + +dir="$RUNNER_TEMP/digests" +mkdir -p "$dir" +jq ' + with_entries(select(.value | type == "object")) + | map_values(.["containerimage.digest"] // error("no digest in the build metadata")) +' <<< "$METADATA" > "$dir/digests-$SLUG.json" +cat "$dir/digests-$SLUG.json" diff --git a/bake/lib.sh b/bake/lib.sh new file mode 100644 index 0000000..f0c67e4 --- /dev/null +++ b/bake/lib.sh @@ -0,0 +1,24 @@ +# shellcheck shell=bash +# Helpers for the scripts of the bake actions. Source it, don't run it. + +# output : set a step output. The value may span several lines. +output() { + _bake_write "$GITHUB_OUTPUT" "$1" "$2" +} + +# export_env : set an environment variable for the job's later steps. +export_env() { + _bake_write "$GITHUB_ENV" "$1" "$2" +} + +# The random delimiter keeps a value from ending the block early or injecting more variables. +_bake_write() { + local delimiter + delimiter="EOF_$(openssl rand -hex 16)" + printf '%s<<%s\n%s\n%s\n' "$2" "$delimiter" "$3" "$delimiter" >> "$1" +} + +# Reads lines from stdin and writes them trimmed, without the empty ones. +trim_lines() { + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' +} diff --git a/bake/narrow/action.yml b/bake/narrow/action.yml new file mode 100644 index 0000000..c611cb3 --- /dev/null +++ b/bake/narrow/action.yml @@ -0,0 +1,27 @@ +name: Bake narrow +description: >- + Internal to .github/workflows/bake.yml. Narrows the bake definition in $RUNNER_TEMP/bake to one platform. + +inputs: + platform: + description: The platform to build, i.e. "linux/amd64". + required: true + slug: + description: The platform as a name, i.e. "linux-amd64". + required: true + +outputs: + file: + description: The narrowed bake definition. + value: ${{ steps.narrow.outputs.file }} + +runs: + using: composite + steps: + - name: Narrow the definition + id: narrow + shell: bash + env: + PLATFORM: ${{ inputs.platform }} + SLUG: ${{ inputs.slug }} + run: bash "$GITHUB_ACTION_PATH/narrow.sh" diff --git a/bake/narrow/narrow.jq b/bake/narrow/narrow.jq new file mode 100644 index 0000000..7849747 --- /dev/null +++ b/bake/narrow/narrow.jq @@ -0,0 +1,9 @@ +# The targets that build for $platform, narrowed to it, each with its own GitHub Actions cache scope. +.target |= with_entries( + select(.value.platforms | index($platform)) + | ("\($publish[0][.key].image | gsub("[^A-Za-z0-9]+"; "-"))-\(.key)-\($slug)") as $scope + | .value.platforms = [$platform] + | .value["cache-from"] = ["type=gha,scope=\($scope)"] + | .value["cache-to"] = ["type=gha,mode=max,scope=\($scope)"] +) +| .group = {default: {targets: (.target | keys)}} diff --git a/bake/narrow/narrow.sh b/bake/narrow/narrow.sh new file mode 100755 index 0000000..1f6ea62 --- /dev/null +++ b/bake/narrow/narrow.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Narrows $RUNNER_TEMP/bake/definition.json to one platform, see narrow.jq. +# +# Reads PLATFORM and SLUG. Sets the output file to the narrowed definition. +set -euo pipefail + +here=$(cd "$(dirname "$0")" && pwd) +# shellcheck source=../lib.sh +source "$here/../lib.sh" + +dir="$RUNNER_TEMP/bake" +jq --arg platform "$PLATFORM" --arg slug "$SLUG" --slurpfile publish "$dir/publish.json" -f "$here/narrow.jq" \ + "$dir/definition.json" > "$dir/definition-$SLUG.json" +output file "$dir/definition-$SLUG.json" diff --git a/bake/plan/action.yml b/bake/plan/action.yml new file mode 100644 index 0000000..9f444c4 --- /dev/null +++ b/bake/plan/action.yml @@ -0,0 +1,87 @@ +name: Bake plan +description: >- + Internal to .github/workflows/bake.yml. Works out the run's variables and resolves the bake files, with this + repository's bake/specs.hcl first, into the definition, publish list and build matrix in $RUNNER_TEMP/bake. + +inputs: + files: + description: The bake files (multiline). + required: true + targets: + description: Bake targets or groups to build (multiline). + required: false + version: + description: The VERSION bake variable, if set explicitly. + required: false + dispatch-tag: + description: Tag published by a workflow_dispatch run. + required: false + push: + description: '"true" or "false", if set explicitly.' + required: false + runners: + description: JSON object mapping a platform to its runner. + required: false + token: + description: Token to read the repository's metadata with. + default: ${{ github.token }} + +outputs: + version: + description: The VERSION the images are built with. + value: ${{ steps.vars.outputs.version }} + push: + description: Whether the images are pushed ("true" or "false"). + value: ${{ steps.vars.outputs.push }} + matrix: + description: The build jobs, as a JSON array of {platform, slug, runner}. + value: ${{ steps.freeze.outputs.matrix }} + artifact: + description: The prefix of this call's artifact names. + value: ${{ steps.freeze.outputs.artifact }} + +runs: + using: composite + steps: + + - name: Work out the run's variables + id: vars + shell: bash + env: + INPUT_VERSION: ${{ inputs.version }} + INPUT_DISPATCH_TAG: ${{ inputs.dispatch-tag }} + INPUT_PUSH: ${{ inputs.push }} + PR_NUMBER: ${{ github.event.pull_request.number }} + PR_AUTHOR: ${{ github.event.pull_request.user.login }} + PR_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} + run: bash "$GITHUB_ACTION_PATH/vars.sh" + + - name: Read the repository + id: repository + shell: bash + env: + GH_TOKEN: ${{ inputs.token }} + run: bash "$GITHUB_ACTION_PATH/repository.sh" + + - name: Freeze the bake definition + id: freeze + shell: bash + env: + FILES: ${{ inputs.files }} + TARGETS: ${{ inputs.targets }} + RUNNERS: ${{ inputs.runners }} + PUSH: ${{ steps.vars.outputs.push }} + VERSION: ${{ steps.vars.outputs.version }} + DISPATCH_TAG: ${{ steps.vars.outputs.dispatch-tag }} + IS_STABLE: ${{ steps.vars.outputs.is-stable }} + CREATED: ${{ steps.vars.outputs.created }} + EVENT: ${{ github.event_name }} + REF_TYPE: ${{ github.ref_type }} + REF_NAME: ${{ github.ref_name }} + PR_NUMBER: ${{ github.event.pull_request.number }} + REVISION: ${{ github.sha }} + SOURCE: ${{ github.server_url }}/${{ github.repository }} + REPOSITORY_NAME: ${{ steps.repository.outputs.name }} + REPOSITORY_DESCRIPTION: ${{ steps.repository.outputs.description }} + LICENSES: ${{ steps.repository.outputs.license }} + run: bash "$GITHUB_ACTION_PATH/freeze.sh" diff --git a/bake/plan/definition.jq b/bake/plan/definition.jq new file mode 100644 index 0000000..92ac948 --- /dev/null +++ b/bake/plan/definition.jq @@ -0,0 +1,21 @@ +# The targets as the build jobs build them: pushed by digest when $push is "true", otherwise only to the cache. The +# tags and cache settings are left out; the publish job tags the images, and each build job sets its own cache. +def image: .tags[0] | sub(":[^:/]*$"; ""); + +.target |= with_entries( + if (.value.platforms // []) == [] then + error("target \(.key) has no platforms; set platforms in the bake file") + elif $push == "true" and (.value.tags // []) == [] then + error("target \(.key) has no tags for this event, so there is nothing to push") + else . end +) +| .target |= map_values( + (if $push == "true" then + "type=image,name=\(image),push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + else + "type=cacheonly" + end) as $output + | del(.tags, .output, .["cache-from"], .["cache-to"], .load, .push) + | .output = [$output] + ) +| .group = {default: {targets: (.target | keys)}} diff --git a/bake/plan/freeze.sh b/bake/plan/freeze.sh new file mode 100755 index 0000000..1ef0875 --- /dev/null +++ b/bake/plan/freeze.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +# Resolves the bake files, with specs.hcl first, into fixed JSON in $RUNNER_TEMP/bake for the build and publish jobs: +# +# definition.json the targets to build, see definition.jq +# publish.json the images, tags, labels and platforms to publish, see publish.jq +# matrix.json the build jobs, see matrix.jq +# +# Reads FILES, TARGETS, RUNNERS and PUSH, and passes the environment on to bake for its variables (VERSION, EVENT, +# ...). Sets the outputs matrix and artifact, and writes the step summary. +set -euo pipefail + +here=$(cd "$(dirname "$0")" && pwd) +# shellcheck source=../lib.sh +source "$here/../lib.sh" + +specs="$here/../specs.hcl" +if [ ! -f "$specs" ]; then + echo "::error::$specs not found next to the bake actions." + exit 1 +fi + +files=(-f "$specs") +while IFS= read -r file; do files+=(-f "$file"); done < <(printf '%s\n' "${FILES:-}" | trim_lines) +mapfile -t targets < <(printf '%s\n' "${TARGETS:-}" | trim_lines) + +dir="$RUNNER_TEMP/bake" +mkdir -p "$dir" +docker buildx bake --progress=quiet "${files[@]}" --print "${targets[@]}" > "$dir/print.json" +if jq -e '(.target // {}) == {}' "$dir/print.json" > /dev/null; then + echo "::error::The bake files define no targets to build." + exit 1 +fi + +jq --arg push "$PUSH" -f "$here/definition.jq" "$dir/print.json" > "$dir/definition.json" +jq -f "$here/publish.jq" "$dir/print.json" > "$dir/publish.json" +jq --argjson override "${RUNNERS:-"{}"}" -f "$here/matrix.jq" "$dir/print.json" > "$dir/matrix.json" + +output matrix "$(jq -c . "$dir/matrix.json")" +# Unique per call, so a caller can use bake.yml more than once in a run. +output artifact "bake-$(printf '%s\n' "${FILES:-}" "${TARGETS:-}" | sha256sum | cut -c1-12)" + +{ + echo '### Bake definition' + echo + echo "Version \`${VERSION:-}\`, push \`$PUSH\`." + echo + echo '| Target | Platforms | Tags |' + echo '|--------|-----------|------|' + jq -r ' + to_entries[] + | "| `\(.key)` | \(.value.platforms | join(", ")) | \(.value.tags | map("`\(.)`") | join("
")) |" + ' "$dir/publish.json" +} >> "$GITHUB_STEP_SUMMARY" diff --git a/bake/plan/matrix.jq b/bake/plan/matrix.jq new file mode 100644 index 0000000..7e3b076 --- /dev/null +++ b/bake/plan/matrix.jq @@ -0,0 +1,8 @@ +# One build job per platform, on the runner $override maps it to, or the default one. +({"linux/amd64": "ubuntu-26.04", "linux/arm64": "ubuntu-26.04-arm"} + $override) as $runners +| [.target[].platforms[]] | unique +| map({ + platform: ., + slug: gsub("[^A-Za-z0-9]+"; "-"), + runner: ($runners[.] // error("no runner for platform \(.); add it to the runners input")) + }) diff --git a/bake/plan/publish.jq b/bake/plan/publish.jq new file mode 100644 index 0000000..13ce6cf --- /dev/null +++ b/bake/plan/publish.jq @@ -0,0 +1,8 @@ +# Per target, what the publish job needs: the image name, its tags, the labels it copies into annotations, and the +# platforms it expects a digest for. +.target | map_values({ + image: (.tags[0] // "" | sub(":[^:/]*$"; "")), + tags: (.tags // []), + labels: (.labels // {}), + platforms +}) diff --git a/bake/plan/repository.sh b/bake/plan/repository.sh new file mode 100755 index 0000000..b5a1f2b --- /dev/null +++ b/bake/plan/repository.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +# Reads the repository's name, description and SPDX license from the GitHub API, the fallbacks specs_labels uses. +# +# Reads GH_TOKEN and GITHUB_REPOSITORY. Sets the outputs name, description and license. +set -euo pipefail + +# shellcheck source=../lib.sh +source "$(dirname "$0")/../lib.sh" + +repository=$(gh api "repos/$GITHUB_REPOSITORY") + +output name "$(jq -r '.name' <<< "$repository")" +output description "$(jq -r '.description // ""' <<< "$repository")" +# GitHub reports a license it doesn't recognise as NOASSERTION, which isn't a license. +output license "$(jq -r '.license.spdx_id // "" | select(. != "NOASSERTION")' <<< "$repository")" diff --git a/bake/plan/vars.sh b/bake/plan/vars.sh new file mode 100755 index 0000000..d4a0f55 --- /dev/null +++ b/bake/plan/vars.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Works out the run's version, dispatch tag, stability and whether to push, from the event and the inputs. +# +# Reads INPUT_VERSION, INPUT_DISPATCH_TAG, INPUT_PUSH, PR_NUMBER, PR_AUTHOR, PR_HEAD_REPOSITORY and the GITHUB_* +# variables of the event. Sets the outputs version, dispatch-tag, is-stable, push and created. +set -euo pipefail + +# shellcheck source=../lib.sh +source "$(dirname "$0")/../lib.sh" + +dispatch_tag="${INPUT_DISPATCH_TAG:-}" +dispatch_tag="${dispatch_tag,,}" +dispatch_tag="${dispatch_tag:-latest}" + +version="${INPUT_VERSION:-}" +if [ -z "$version" ]; then + case "${GITHUB_EVENT_NAME:-}" in + push) + version="$GITHUB_REF_NAME" + if [ "$GITHUB_REF_TYPE" = tag ] && [[ $version =~ ^v[0-9] ]]; then + version="${version#v}" + fi + ;; + pull_request | pull_request_target) version="pr-${PR_NUMBER:-}" ;; + schedule) version=nightly ;; + workflow_dispatch) version="$dispatch_tag" ;; + esac +fi + +is_stable=false +if [ "${GITHUB_EVENT_NAME:-}" = push ] && [ "${GITHUB_REF_TYPE:-}" = tag ] && [[ $version != *-* ]]; then + is_stable=true +fi + +push="${INPUT_PUSH:-}" +if [ -z "$push" ]; then + push=true + case "${GITHUB_EVENT_NAME:-}" in + pull_request | pull_request_target) + if [ "${PR_AUTHOR:-}" = 'dependabot[bot]' ] || [ "${PR_HEAD_REPOSITORY:-}" != "${GITHUB_REPOSITORY:-}" ]; then + push=false + fi + ;; + push) + if [ "${GITHUB_REF_TYPE:-}" = branch ] && [[ ${GITHUB_REF_NAME:-} == dependabot/* ]]; then + push=false + fi + ;; + schedule | workflow_dispatch) ;; + *) push=false ;; + esac +fi +if [ "$push" != true ] && [ "$push" != false ]; then + echo "::error::push must be \"true\" or \"false\", got \"$push\"." + exit 1 +fi + +output version "$version" +output dispatch-tag "$dispatch_tag" +output is-stable "$is_stable" +output push "$push" +output created "$(date -u +%Y-%m-%dT%H:%M:%SZ)" diff --git a/bake/publish/action.yml b/bake/publish/action.yml new file mode 100644 index 0000000..45fc145 --- /dev/null +++ b/bake/publish/action.yml @@ -0,0 +1,11 @@ +name: Bake publish +description: >- + Internal to .github/workflows/bake.yml. Creates, tags and annotates the multi-platform manifests from the bake + definition in $RUNNER_TEMP/bake and the digests in $RUNNER_TEMP/digests. + +runs: + using: composite + steps: + - name: Create the manifests + shell: bash + run: bash "$GITHUB_ACTION_PATH/publish.sh" diff --git a/bake/publish/publish.sh b/bake/publish/publish.sh new file mode 100755 index 0000000..a9c3060 --- /dev/null +++ b/bake/publish/publish.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# Creates a multi-platform manifest list for every target in $RUNNER_TEMP/bake/publish.json from the build jobs' +# digests in $RUNNER_TEMP/digests, tags it, and copies the target's labels onto it as annotations. +set -euo pipefail + +publish="$RUNNER_TEMP/bake/publish.json" +digests=$(jq -s ' + map(to_entries) | add | group_by(.key) | map({key: .[0].key, value: map(.value)}) | from_entries +' "$RUNNER_TEMP"/digests/digests-*.json) + +for target in $(jq -r 'keys[]' "$publish"); do + image=$(jq -r --arg t "$target" '.[$t].image' "$publish") + mapfile -t tags < <(jq -r --arg t "$target" '.[$t].tags[]' "$publish") + mapfile -t annotations < <(jq -r --arg t "$target" ' + .[$t].labels | to_entries[] | "index:\(.key)=\(.value)", "manifest-descriptor:\(.key)=\(.value)" + ' "$publish") + mapfile -t sources < <(jq -r --arg t "$target" --arg image "$image" '(.[$t] // [])[] | "\($image)@\(.)"' <<< "$digests") + + expected=$(jq -r --arg t "$target" '.[$t].platforms | length' "$publish") + if [ "${#sources[@]}" -ne "$expected" ]; then + echo "::error::$target has ${#sources[@]} digests for $expected platforms." + exit 1 + fi + + args=() + for tag in "${tags[@]}"; do args+=(--tag "$tag"); done + for annotation in "${annotations[@]}"; do args+=(--annotation "$annotation"); done + + echo "::group::$target" + docker buildx imagetools create "${args[@]}" "${sources[@]}" + docker buildx imagetools inspect "${tags[0]}" + echo "::endgroup::" +done diff --git a/bake/secrets/action.yml b/bake/secrets/action.yml new file mode 100644 index 0000000..8545c42 --- /dev/null +++ b/bake/secrets/action.yml @@ -0,0 +1,17 @@ +name: Bake secrets +description: >- + Internal to .github/workflows/bake.yml. Masks the build secrets and exports them as environment variables. + +inputs: + secrets: + description: Build secrets as "NAME=value" lines. + required: false + +runs: + using: composite + steps: + - name: Export the build secrets + shell: bash + env: + BUILD_SECRETS: ${{ inputs.secrets }} + run: bash "$GITHUB_ACTION_PATH/secrets.sh" diff --git a/bake/secrets/secrets.sh b/bake/secrets/secrets.sh new file mode 100755 index 0000000..f4c0223 --- /dev/null +++ b/bake/secrets/secrets.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Masks every build secret and exports it as an environment variable for the build. +# +# Reads BUILD_SECRETS, "NAME=value" lines. Blank lines are skipped. A NAME the runner or the build tooling depends on +# is refused, so a secret can't change how the job runs. +set -euo pipefail + +# shellcheck source=../lib.sh +source "$(dirname "$0")/../lib.sh" + +while IFS= read -r line || [ -n "$line" ]; do + [ -z "${line//[[:space:]]/}" ] && continue + name="${line%%=*}" + value="${line#*=}" + if [ "$name" = "$line" ] || [[ ! $name =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then + echo "::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores." + exit 1 + fi + case "$name" in + GITHUB_* | RUNNER_* | ACTIONS_* | BUILDX_* | DOCKER_* | PATH | HOME | BASH_ENV | ENV | NODE_OPTIONS | LD_*) + echo "::error::build-secrets may not set $name." + exit 1 + ;; + esac + [ -n "$value" ] && echo "::add-mask::$value" + export_env "$name" "$value" +done <<< "${BUILD_SECRETS:-}" diff --git a/bake/specs.hcl b/bake/specs.hcl index 963a913..b010036 100644 --- a/bake/specs.hcl +++ b/bake/specs.hcl @@ -1,9 +1,11 @@ # Shared tag, label and annotation rules for images built with specsnl/github-actions bake.yml. # -# Vendored: copy this file into the consuming repository unchanged and update it when you move bake.yml to a new -# version; the workflow warns when the copy differs. Build locally with: +# bake.yml reads this file before the caller's bake files, at the version of bake.yml the caller uses, so a consuming +# repository doesn't keep a copy. For a local build, fetch it at the commit of the repository's +# `uses: specsnl/github-actions/.github/workflows/bake.yml@` line, and leave it out of git: # -# docker buildx bake -f specs.hcl -f docker-bake.hcl +# curl -fsSL -o .specs.hcl https://raw.githubusercontent.com/specsnl/github-actions//bake/specs.hcl +# docker buildx bake -f .specs.hcl -f docker-bake.hcl # # The variables below are set by bake.yml's plan job. The defaults are what a local build gets. diff --git a/bake/test/pipeline.sh b/bake/test/pipeline.sh new file mode 100755 index 0000000..008d81d --- /dev/null +++ b/bake/test/pipeline.sh @@ -0,0 +1,143 @@ +#!/usr/bin/env bash +# Runs the scripts of the bake actions in the order bake.yml does (freeze, narrow, digests, publish) on +# test/e2e/docker-bake.hcl, with fake build digests and a docker that only records the imagetools calls. Compares +# everything they write with test/pipeline/.txt; pass --update to rewrite those files instead. Also checks that +# freeze.sh refuses bake files it can't build. +set -euo pipefail + +cd "$(dirname "$0")/../.." + +update=false +[ "${1:-}" = "--update" ] && update=true + +work=$(mktemp -d) +trap 'rm -rf "$work"' EXIT + +# A docker that records the imagetools calls and passes everything else to the real one. +mkdir "$work/bin" +cat > "$work/bin/docker" <> "\$DOCKER_LOG" + exit 0 +fi +exec $(command -v docker) "\$@" +STUB +chmod +x "$work/bin/docker" + +# run : the environment of a step, with the case's bake variables. +run() { + local case_file="$1" dir="$2" + shift 2 + local vars=() + while IFS= read -r line || [ -n "$line" ]; do + case "$line" in '' | '#'*) continue ;; esac + vars+=("$line") + done < "$case_file" + env -i PATH="$work/bin:$PATH" HOME="$HOME" RUNNER_TEMP="$dir" GITHUB_OUTPUT="$dir/output" \ + GITHUB_STEP_SUMMARY="$dir/summary" DOCKER_LOG="$dir/docker" "${vars[@]}" "$@" +} + +# section <file...> +section() { + local title="$1" file + shift + for file in "$@"; do + echo "== $title${file:+ $(basename "$file")}" + if [[ $file == *.json ]]; then jq --sort-keys . "$file"; else cat "$file"; fi + echo + done +} + +# pipeline <case env> <push>: everything the scripts write, as one document. +pipeline() { + local case_file="$1" push="$2" dir slug + dir="$work/$(basename "$case_file" .env)" + mkdir -p "$dir" + : > "$dir/docker" + + run "$case_file" "$dir" FILES=$'\n bake/test/e2e/docker-bake.hcl\n' PUSH="$push" \ + RUNNERS='{"linux/arm64": "arm-runner"}' bake/plan/freeze.sh + sed 's/^\(.*\)<<EOF_.*/\1<<EOF/; s/^EOF_.*/EOF/' "$dir/output" > "$dir/outputs.txt" + : > "$dir/output" + + for slug in $(jq -r '.[].slug' "$dir/bake/matrix.json"); do + run "$case_file" "$dir" PLATFORM="$(jq -r --arg s "$slug" '.[] | select(.slug == $s) | .platform' "$dir/bake/matrix.json")" \ + SLUG="$slug" bake/narrow/narrow.sh + # What docker/bake-action reports: an object per target, and keys that aren't targets. + run "$case_file" "$dir" SLUG="$slug" METADATA="$(jq --arg slug "$slug" ' + .target | with_entries(.value = {"containerimage.digest": "sha256:\(.key)-\($slug)"}) + | . + {"buildx.build.warnings": []} + ' "$dir/bake/definition-$slug.json")" bake/digests/digests.sh > /dev/null + done + + if [ "$push" = true ]; then + run "$case_file" "$dir" bake/publish/publish.sh > /dev/null + fi + + section outputs "$dir/outputs.txt" + section summary "$dir/summary" + section bake "$dir"/bake/definition.json "$dir"/bake/publish.json "$dir"/bake/matrix.json \ + "$dir"/bake/definition-*.json + if [ "$push" = true ]; then + section digests "$dir"/digests/*.json + section docker "$dir/docker" + fi +} + +failed=0 + +for spec in tag-stable:true pr:false; do + name="${spec%%:*}" + expected="bake/test/pipeline/$name.txt" + actual=$(pipeline "bake/test/cases/$name.env" "${spec#*:}") + if $update; then + printf '%s\n' "$actual" > "$expected" + echo "updated pipeline $name" + elif diff -u --label "$expected" --label actual "$expected" <(printf '%s\n' "$actual"); then + echo "ok pipeline $name" + else + echo "FAILED pipeline $name" + failed=1 + fi +done + +# refuse <description> <expected error> <case env> <bake file content> <variable=value...> +refuse() { + local description="$1" expected="$2" case_file="$3" content="$4" dir status=0 actual + shift 4 + dir=$(mktemp -d "$work/refuse.XXXXXX") + printf '%s\n' "$content" > "$dir/docker-bake.hcl" + actual=$(run "$case_file" "$dir" FILES="$dir/docker-bake.hcl" "$@" bake/plan/freeze.sh 2>&1) || status=$? + if [ "$status" -ne 0 ] && [[ $actual == *"$expected"* ]]; then + echo "ok refuses $description" + else + echo "FAILED refuses $description" + echo " expected: $expected" + echo " actual: exit=$status $actual" + failed=1 + fi +} + +refuse 'bake files without targets' \ + 'The bake files define no targets to build.' \ + bake/test/cases/tag-stable.env 'group "default" { targets = [] }' PUSH=true +refuse 'a target without platforms' \ + 'target default has no platforms' \ + bake/test/cases/tag-stable.env 'target "default" { tags = specs_tags(["ghcr.io/specsnl/app"], "") }' PUSH=true +refuse 'pushing a target without tags' \ + 'target default has no tags for this event' \ + bake/test/cases/unknown-event.env \ + 'target "default" { + platforms = ["linux/amd64"] + tags = specs_tags(["ghcr.io/specsnl/app"], "") + }' PUSH=true +refuse 'a platform without a runner' \ + 'no runner for platform linux/riscv64' \ + bake/test/cases/tag-stable.env \ + 'target "default" { + platforms = ["linux/riscv64"] + tags = specs_tags(["ghcr.io/specsnl/app"], "") + }' PUSH=true + +exit "$failed" diff --git a/bake/test/pipeline/pr.txt b/bake/test/pipeline/pr.txt new file mode 100644 index 0000000..9d1cc5f --- /dev/null +++ b/bake/test/pipeline/pr.txt @@ -0,0 +1,452 @@ +== outputs outputs.txt +matrix<<EOF +[{"platform":"linux/amd64","slug":"linux-amd64","runner":"ubuntu-26.04"},{"platform":"linux/arm64","slug":"linux-arm64","runner":"arm-runner"}] +EOF +artifact<<EOF +bake-84f32ca7fae9 +EOF + +== summary summary +### Bake definition + +Version `pr-42`, push `false`. + +| Target | Platforms | Tags | +|--------|-----------|------| +| `app` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e:pr-42` | +| `cli-alpine` | linux/amd64 | `ghcr.io/specsnl/github-actions/e2e-cli:pr-42-alpine` | +| `cli-debian` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e-cli:pr-42` | + +== bake definition.json +{ + "group": { + "default": { + "targets": [ + "app", + "cli-alpine", + "cli-debian" + ] + } + }, + "target": { + "app": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e app", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "secret": [ + { + "env": "E2E_SECRET", + "id": "e2e" + } + ], + "target": "app" + }, + "cli-alpine": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "args": { + "E2E_VERSION": "pr-42" + }, + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/amd64" + ], + "target": "alpine" + }, + "cli-debian": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "args": { + "E2E_VERSION": "pr-42" + }, + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "target": "debian" + } + } +} + +== bake publish.json +{ + "app": { + "image": "ghcr.io/specsnl/github-actions/e2e", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "tags": [ + "ghcr.io/specsnl/github-actions/e2e:pr-42" + ] + }, + "cli-alpine": { + "image": "ghcr.io/specsnl/github-actions/e2e-cli", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "platforms": [ + "linux/amd64" + ], + "tags": [ + "ghcr.io/specsnl/github-actions/e2e-cli:pr-42-alpine" + ] + }, + "cli-debian": { + "image": "ghcr.io/specsnl/github-actions/e2e-cli", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "tags": [ + "ghcr.io/specsnl/github-actions/e2e-cli:pr-42" + ] + } +} + +== bake matrix.json +[ + { + "platform": "linux/amd64", + "runner": "ubuntu-26.04", + "slug": "linux-amd64" + }, + { + "platform": "linux/arm64", + "runner": "arm-runner", + "slug": "linux-arm64" + } +] + +== bake definition-linux-amd64.json +{ + "group": { + "default": { + "targets": [ + "app", + "cli-alpine", + "cli-debian" + ] + } + }, + "target": { + "app": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e app", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/amd64" + ], + "secret": [ + { + "env": "E2E_SECRET", + "id": "e2e" + } + ], + "target": "app" + }, + "cli-alpine": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "args": { + "E2E_VERSION": "pr-42" + }, + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/amd64" + ], + "target": "alpine" + }, + "cli-debian": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "args": { + "E2E_VERSION": "pr-42" + }, + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/amd64" + ], + "target": "debian" + } + } +} + +== bake definition-linux-arm64.json +{ + "group": { + "default": { + "targets": [ + "app", + "cli-debian" + ] + } + }, + "target": { + "app": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e app", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/arm64" + ], + "secret": [ + { + "env": "E2E_SECRET", + "id": "e2e" + } + ], + "target": "app" + }, + "cli-debian": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=pr-42" + ], + "args": { + "E2E_VERSION": "pr-42" + }, + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "output": [ + "type=cacheonly" + ], + "platforms": [ + "linux/arm64" + ], + "target": "debian" + } + } +} diff --git a/bake/test/pipeline/tag-stable.txt b/bake/test/pipeline/tag-stable.txt new file mode 100644 index 0000000..278c1d6 --- /dev/null +++ b/bake/test/pipeline/tag-stable.txt @@ -0,0 +1,628 @@ +== outputs outputs.txt +matrix<<EOF +[{"platform":"linux/amd64","slug":"linux-amd64","runner":"ubuntu-26.04"},{"platform":"linux/arm64","slug":"linux-arm64","runner":"arm-runner"}] +EOF +artifact<<EOF +bake-84f32ca7fae9 +EOF + +== summary summary +### Bake definition + +Version `1.2.3`, push `true`. + +| Target | Platforms | Tags | +|--------|-----------|------| +| `app` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e:1.2.3`<br>`ghcr.io/specsnl/github-actions/e2e:1.2`<br>`ghcr.io/specsnl/github-actions/e2e:1`<br>`ghcr.io/specsnl/github-actions/e2e:latest` | +| `cli-alpine` | linux/amd64 | `ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1.2-alpine`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1-alpine`<br>`ghcr.io/specsnl/github-actions/e2e-cli:alpine` | +| `cli-debian` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e-cli:1.2.3`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1.2`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1`<br>`ghcr.io/specsnl/github-actions/e2e-cli:latest` | + +== bake definition.json +{ + "group": { + "default": { + "targets": [ + "app", + "cli-alpine", + "cli-debian" + ] + } + }, + "target": { + "app": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e app", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "secret": [ + { + "env": "E2E_SECRET", + "id": "e2e" + } + ], + "target": "app" + }, + "cli-alpine": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "args": { + "E2E_VERSION": "1.2.3" + }, + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/amd64" + ], + "target": "alpine" + }, + "cli-debian": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "args": { + "E2E_VERSION": "1.2.3" + }, + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "target": "debian" + } + } +} + +== bake publish.json +{ + "app": { + "image": "ghcr.io/specsnl/github-actions/e2e", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "tags": [ + "ghcr.io/specsnl/github-actions/e2e:1.2.3", + "ghcr.io/specsnl/github-actions/e2e:1.2", + "ghcr.io/specsnl/github-actions/e2e:1", + "ghcr.io/specsnl/github-actions/e2e:latest" + ] + }, + "cli-alpine": { + "image": "ghcr.io/specsnl/github-actions/e2e-cli", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "platforms": [ + "linux/amd64" + ], + "tags": [ + "ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine", + "ghcr.io/specsnl/github-actions/e2e-cli:1.2-alpine", + "ghcr.io/specsnl/github-actions/e2e-cli:1-alpine", + "ghcr.io/specsnl/github-actions/e2e-cli:alpine" + ] + }, + "cli-debian": { + "image": "ghcr.io/specsnl/github-actions/e2e-cli", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "platforms": [ + "linux/amd64", + "linux/arm64" + ], + "tags": [ + "ghcr.io/specsnl/github-actions/e2e-cli:1.2.3", + "ghcr.io/specsnl/github-actions/e2e-cli:1.2", + "ghcr.io/specsnl/github-actions/e2e-cli:1", + "ghcr.io/specsnl/github-actions/e2e-cli:latest" + ] + } +} + +== bake matrix.json +[ + { + "platform": "linux/amd64", + "runner": "ubuntu-26.04", + "slug": "linux-amd64" + }, + { + "platform": "linux/arm64", + "runner": "arm-runner", + "slug": "linux-arm64" + } +] + +== bake definition-linux-amd64.json +{ + "group": { + "default": { + "targets": [ + "app", + "cli-alpine", + "cli-debian" + ] + } + }, + "target": { + "app": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e app", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/amd64" + ], + "secret": [ + { + "env": "E2E_SECRET", + "id": "e2e" + } + ], + "target": "app" + }, + "cli-alpine": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "args": { + "E2E_VERSION": "1.2.3" + }, + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/amd64" + ], + "target": "alpine" + }, + "cli-debian": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "args": { + "E2E_VERSION": "1.2.3" + }, + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/amd64" + ], + "target": "debian" + } + } +} + +== bake definition-linux-arm64.json +{ + "group": { + "default": { + "targets": [ + "app", + "cli-debian" + ] + } + }, + "target": { + "app": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e app", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e app", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/arm64" + ], + "secret": [ + { + "env": "E2E_SECRET", + "id": "e2e" + } + ], + "target": "app" + }, + "cli-debian": { + "annotations": [ + "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", + "manifest:org.opencontainers.image.description=An example repository", + "manifest:org.opencontainers.image.licenses=MIT", + "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", + "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.title=e2e cli", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", + "manifest:org.opencontainers.image.version=1.2.3" + ], + "args": { + "E2E_VERSION": "1.2.3" + }, + "cache-from": [ + "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" + ], + "cache-to": [ + "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" + ], + "context": "bake/test/e2e", + "dockerfile": "Dockerfile", + "labels": { + "org.opencontainers.image.created": "2026-11-09T12:00:00Z", + "org.opencontainers.image.description": "An example repository", + "org.opencontainers.image.licenses": "MIT", + "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", + "org.opencontainers.image.source": "https://github.com/specsnl/example", + "org.opencontainers.image.title": "e2e cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "output": [ + "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + ], + "platforms": [ + "linux/arm64" + ], + "target": "debian" + } + } +} + +== digests digests-linux-amd64.json +{ + "app": "sha256:app-linux-amd64", + "cli-alpine": "sha256:cli-alpine-linux-amd64", + "cli-debian": "sha256:cli-debian-linux-amd64" +} + +== digests digests-linux-arm64.json +{ + "app": "sha256:app-linux-arm64", + "cli-debian": "sha256:cli-debian-linux-arm64" +} + +== docker docker +docker + buildx + imagetools + create + --tag + ghcr.io/specsnl/github-actions/e2e:1.2.3 + --tag + ghcr.io/specsnl/github-actions/e2e:1.2 + --tag + ghcr.io/specsnl/github-actions/e2e:1 + --tag + ghcr.io/specsnl/github-actions/e2e:latest + --annotation + index:org.opencontainers.image.created=2026-11-09T12:00:00Z + --annotation + manifest-descriptor:org.opencontainers.image.created=2026-11-09T12:00:00Z + --annotation + index:org.opencontainers.image.description=End-to-end\ test\ image\ of\ specsnl/github-actions + --annotation + manifest-descriptor:org.opencontainers.image.description=End-to-end\ test\ image\ of\ specsnl/github-actions + --annotation + index:org.opencontainers.image.licenses=MIT + --annotation + manifest-descriptor:org.opencontainers.image.licenses=MIT + --annotation + index:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 + --annotation + manifest-descriptor:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 + --annotation + index:org.opencontainers.image.source=https://github.com/specsnl/example + --annotation + manifest-descriptor:org.opencontainers.image.source=https://github.com/specsnl/example + --annotation + index:org.opencontainers.image.title=e2e\ app + --annotation + manifest-descriptor:org.opencontainers.image.title=e2e\ app + --annotation + index:org.opencontainers.image.url=https://github.com/specsnl/example + --annotation + manifest-descriptor:org.opencontainers.image.url=https://github.com/specsnl/example + --annotation + index:org.opencontainers.image.version=1.2.3 + --annotation + manifest-descriptor:org.opencontainers.image.version=1.2.3 + ghcr.io/specsnl/github-actions/e2e@sha256:app-linux-amd64 + ghcr.io/specsnl/github-actions/e2e@sha256:app-linux-arm64 +docker + buildx + imagetools + inspect + ghcr.io/specsnl/github-actions/e2e:1.2.3 +docker + buildx + imagetools + create + --tag + ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine + --tag + ghcr.io/specsnl/github-actions/e2e-cli:1.2-alpine + --tag + ghcr.io/specsnl/github-actions/e2e-cli:1-alpine + --tag + ghcr.io/specsnl/github-actions/e2e-cli:alpine + --annotation + index:org.opencontainers.image.created=2026-11-09T12:00:00Z + --annotation + manifest-descriptor:org.opencontainers.image.created=2026-11-09T12:00:00Z + --annotation + index:org.opencontainers.image.description=An\ example\ repository + --annotation + manifest-descriptor:org.opencontainers.image.description=An\ example\ repository + --annotation + index:org.opencontainers.image.licenses=MIT + --annotation + manifest-descriptor:org.opencontainers.image.licenses=MIT + --annotation + index:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 + --annotation + manifest-descriptor:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 + --annotation + index:org.opencontainers.image.source=https://github.com/specsnl/example + --annotation + manifest-descriptor:org.opencontainers.image.source=https://github.com/specsnl/example + --annotation + index:org.opencontainers.image.title=e2e\ cli + --annotation + manifest-descriptor:org.opencontainers.image.title=e2e\ cli + --annotation + index:org.opencontainers.image.url=https://github.com/specsnl/example + --annotation + manifest-descriptor:org.opencontainers.image.url=https://github.com/specsnl/example + --annotation + index:org.opencontainers.image.version=1.2.3 + --annotation + manifest-descriptor:org.opencontainers.image.version=1.2.3 + ghcr.io/specsnl/github-actions/e2e-cli@sha256:cli-alpine-linux-amd64 +docker + buildx + imagetools + inspect + ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine +docker + buildx + imagetools + create + --tag + ghcr.io/specsnl/github-actions/e2e-cli:1.2.3 + --tag + ghcr.io/specsnl/github-actions/e2e-cli:1.2 + --tag + ghcr.io/specsnl/github-actions/e2e-cli:1 + --tag + ghcr.io/specsnl/github-actions/e2e-cli:latest + --annotation + index:org.opencontainers.image.created=2026-11-09T12:00:00Z + --annotation + manifest-descriptor:org.opencontainers.image.created=2026-11-09T12:00:00Z + --annotation + index:org.opencontainers.image.description=An\ example\ repository + --annotation + manifest-descriptor:org.opencontainers.image.description=An\ example\ repository + --annotation + index:org.opencontainers.image.licenses=MIT + --annotation + manifest-descriptor:org.opencontainers.image.licenses=MIT + --annotation + index:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 + --annotation + manifest-descriptor:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 + --annotation + index:org.opencontainers.image.source=https://github.com/specsnl/example + --annotation + manifest-descriptor:org.opencontainers.image.source=https://github.com/specsnl/example + --annotation + index:org.opencontainers.image.title=e2e\ cli + --annotation + manifest-descriptor:org.opencontainers.image.title=e2e\ cli + --annotation + index:org.opencontainers.image.url=https://github.com/specsnl/example + --annotation + manifest-descriptor:org.opencontainers.image.url=https://github.com/specsnl/example + --annotation + index:org.opencontainers.image.version=1.2.3 + --annotation + manifest-descriptor:org.opencontainers.image.version=1.2.3 + ghcr.io/specsnl/github-actions/e2e-cli@sha256:cli-debian-linux-amd64 + ghcr.io/specsnl/github-actions/e2e-cli@sha256:cli-debian-linux-arm64 +docker + buildx + imagetools + inspect + ghcr.io/specsnl/github-actions/e2e-cli:1.2.3 diff --git a/bake/test/secrets.sh b/bake/test/secrets.sh new file mode 100755 index 0000000..c26cfa0 --- /dev/null +++ b/bake/test/secrets.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash +# Runs bake/secrets/secrets.sh on a set of build-secrets inputs and checks the variables it exports and masks. +set -euo pipefail + +cd "$(dirname "$0")/../.." + +failed=0 + +# check <description> <expected> <build secrets> +check() { + local description="$1" expected="$2" secrets="$3" + + local env stdout status=0 actual + env=$(mktemp) + stdout=$(env -i PATH="$PATH" GITHUB_ENV="$env" BUILD_SECRETS="$secrets" bake/secrets/secrets.sh 2>&1) || status=$? + + if [ "$status" -ne 0 ]; then + actual="exit=$status $stdout" + else + actual=$( + { + printf '%s\n' "$stdout" + awk '/<<EOF_/ { key = substr($0, 1, index($0, "<<") - 1); getline value; print key "=" value; getline }' "$env" + } | sed '/^$/d' | paste -sd ' ' - + ) + fi + rm -f "$env" + + if [ "$actual" = "$expected" ]; then + echo "ok $description" + else + echo "FAILED $description" + echo " expected: $expected" + echo " actual: $actual" + failed=1 + fi +} + +check 'no secrets' \ + '' \ + '' +check 'one secret' \ + '::add-mask::s3cret TOKEN=s3cret' \ + 'TOKEN=s3cret' +check 'blank lines and a last line without a newline' \ + '::add-mask::a ::add-mask::b A=a B=b' \ + $'\n \nA=a\n\nB=b' +check 'a value with = in it' \ + '::add-mask::x=y==z KEY=x=y==z' \ + 'KEY=x=y==z' +check 'an empty value is exported but not masked' \ + 'EMPTY=' \ + 'EMPTY=' +check 'a line without =' \ + 'exit=1 ::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores.' \ + 'TOKEN' +check 'a name with a dash' \ + 'exit=1 ::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores.' \ + 'MY-TOKEN=x' +check 'a name starting with a digit' \ + 'exit=1 ::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores.' \ + '1TOKEN=x' +for name in GITHUB_TOKEN RUNNER_TEMP ACTIONS_RUNTIME_TOKEN BUILDX_BUILDER DOCKER_HOST PATH HOME BASH_ENV ENV \ + NODE_OPTIONS LD_PRELOAD; do + check "the reserved name $name" \ + "exit=1 ::error::build-secrets may not set $name." \ + "$name=x" +done + +exit "$failed" diff --git a/bake/test/specs-hash.sh b/bake/test/specs-hash.sh deleted file mode 100755 index 833b85b..0000000 --- a/bake/test/specs-hash.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env bash -# Checks that bake.yml's SPECS_HCL_SHA256 is the hash of bake/specs.hcl. Pass --update to rewrite it instead. -set -euo pipefail - -cd "$(dirname "$0")/../.." - -workflow=.github/workflows/bake.yml -path='.jobs.plan.steps[] | select(.name == "Compare specs.hcl") | .env.SPECS_HCL_SHA256' - -if command -v sha256sum > /dev/null; then - actual=$(sha256sum bake/specs.hcl | cut -d' ' -f1) -else - actual=$(shasum -a 256 bake/specs.hcl | cut -d' ' -f1) -fi -expected=$(yq "$path" "$workflow") - -if [ "${1:-}" = "--update" ]; then - sed -i.bak "s/SPECS_HCL_SHA256: $expected/SPECS_HCL_SHA256: $actual/" "$workflow" && rm "$workflow.bak" - echo "SPECS_HCL_SHA256 is now $actual" -elif [ "$actual" != "$expected" ]; then - echo "SPECS_HCL_SHA256 in $workflow is $expected, but bake/specs.hcl hashes to $actual. Run: task test:update" - exit 1 -else - echo "ok SPECS_HCL_SHA256" -fi diff --git a/bake/test/plan.sh b/bake/test/vars.sh similarity index 93% rename from bake/test/plan.sh rename to bake/test/vars.sh index b53108b..7316915 100755 --- a/bake/test/plan.sh +++ b/bake/test/vars.sh @@ -1,10 +1,9 @@ #!/usr/bin/env bash -# Runs the "vars" step of bake.yml's plan job for a set of GitHub contexts and checks its outputs. +# Runs bake/plan/vars.sh for a set of GitHub contexts and checks its outputs. set -euo pipefail cd "$(dirname "$0")/../.." -script=$(yq '.jobs.plan.steps[] | select(.id == "vars") | .run' .github/workflows/bake.yml) failed=0 # check <description> <expected outputs> <environment...> @@ -14,15 +13,14 @@ check() { local output status=0 actual output=$(mktemp) - env -i PATH="$PATH" GITHUB_OUTPUT="$output" GITHUB_REPOSITORY=specsnl/example "$@" bash -e -c "$script" > /dev/null 2>&1 || status=$? + env -i PATH="$PATH" GITHUB_OUTPUT="$output" GITHUB_REPOSITORY=specsnl/example "$@" bake/plan/vars.sh > /dev/null 2>&1 || status=$? if [ "$status" -ne 0 ]; then actual="exit=$status" else actual=$(awk ' + /^created<</ { getline; getline; next } /<<EOF_/ { key = substr($0, 1, index($0, "<<") - 1); getline value; printf "%s=%s ", key, value; getline; next } - /^created=/ { next } - { printf "%s ", $0 } ' "$output" | sed 's/ $//') fi rm -f "$output" From 2cd1b7ab47853219494b03d8f1e4cbea01ffc16b Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Fri, 20 Nov 2026 21:57:44 +0100 Subject: [PATCH 06/13] Test publishing with a real push from bake.yml's test instead of golden files test-bake.yml now pushes on pull requests from this repository and checks the published indexes, which replaces bake/test/pipeline.sh and its 1,080 lines of expected output. --- .github/workflows/lint.yml | 2 - .github/workflows/test-bake.yml | 46 ++- Taskfile.dist.yml | 7 +- bake/test/pipeline.sh | 143 ------- bake/test/pipeline/pr.txt | 452 --------------------- bake/test/pipeline/tag-stable.txt | 628 ------------------------------ 6 files changed, 47 insertions(+), 1231 deletions(-) delete mode 100755 bake/test/pipeline.sh delete mode 100644 bake/test/pipeline/pr.txt delete mode 100644 bake/test/pipeline/tag-stable.txt diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 696955b..af433e3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -39,8 +39,6 @@ jobs: run: bake/test/vars.sh - name: Run the build secrets tests run: bake/test/secrets.sh - - name: Run the pipeline tests - run: bake/test/pipeline.sh - name: Run shellcheck run: >- docker run --rm --volume "$PWD:/mnt" --workdir /mnt koalaman/shellcheck:v0.11.0 diff --git a/.github/workflows/test-bake.yml b/.github/workflows/test-bake.yml index 20be1a8..156217a 100644 --- a/.github/workflows/test-bake.yml +++ b/.github/workflows/test-bake.yml @@ -27,10 +27,54 @@ jobs: packages: write with: files: bake/test/e2e/docker-bake.hcl - push: ${{ inputs.push && 'true' || 'false' }} + # Empty outside workflow_dispatch, so bake.yml's own push rules apply: a pull request from this repository + # pushes, one from a fork or dependabot doesn't. + push: ${{ github.event_name == 'workflow_dispatch' && (inputs.push && 'true' || 'false') || '' }} secrets: build-secrets: E2E_SECRET=e2e-secret + verify: + name: Verify + needs: bake + if: ${{ needs.bake.outputs.push == 'true' }} + runs-on: ubuntu-26.04 + timeout-minutes: 5 + permissions: + packages: read + steps: + + - name: Log in to the Container registry + uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Check the published images + env: + IMAGE: ghcr.io/specsnl/github-actions/e2e + VERSION: ${{ needs.bake.outputs.version }} + run: | + # check <reference> <platforms> <title>: the index has exactly these platforms and carries the labels. + check() { + local raw + raw=$(docker buildx imagetools inspect --raw "$1") + if ! jq -e --arg platforms "$2" --arg title "$3" --arg version "$VERSION" ' + ([.manifests[].platform | "\(.os)/\(.architecture)"] | sort | join(" ")) == $platforms + and .annotations["org.opencontainers.image.title"] == $title + and .annotations["org.opencontainers.image.version"] == $version + ' <<< "$raw" > /dev/null; then + echo "::error::$1 doesn't have the expected platforms ($2) or annotations." + jq . <<< "$raw" + return 1 + fi + echo "ok $1" + } + + check "$IMAGE:$VERSION" 'linux/amd64 linux/arm64' 'e2e app' + check "$IMAGE-cli:$VERSION" 'linux/amd64 linux/arm64' 'e2e cli' + check "$IMAGE-cli:$VERSION-alpine" 'linux/amd64' 'e2e cli' + load: name: Load runs-on: ubuntu-26.04 diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index 1d0edd6..ee15e42 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -26,10 +26,7 @@ tasks: - bake/test/run.sh - bake/test/vars.sh - bake/test/secrets.sh - - bake/test/pipeline.sh test:update: - desc: Rewrite the expected output of the specs.hcl fixture tests and the pipeline tests - cmds: - - bake/test/run.sh --update - - bake/test/pipeline.sh --update + desc: Rewrite the expected output of the specs.hcl fixture tests + cmd: bake/test/run.sh --update diff --git a/bake/test/pipeline.sh b/bake/test/pipeline.sh deleted file mode 100755 index 008d81d..0000000 --- a/bake/test/pipeline.sh +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env bash -# Runs the scripts of the bake actions in the order bake.yml does (freeze, narrow, digests, publish) on -# test/e2e/docker-bake.hcl, with fake build digests and a docker that only records the imagetools calls. Compares -# everything they write with test/pipeline/<case>.txt; pass --update to rewrite those files instead. Also checks that -# freeze.sh refuses bake files it can't build. -set -euo pipefail - -cd "$(dirname "$0")/../.." - -update=false -[ "${1:-}" = "--update" ] && update=true - -work=$(mktemp -d) -trap 'rm -rf "$work"' EXIT - -# A docker that records the imagetools calls and passes everything else to the real one. -mkdir "$work/bin" -cat > "$work/bin/docker" <<STUB -#!/usr/bin/env bash -if [ "\$1 \$2" = "buildx imagetools" ]; then - { echo docker; printf ' %q\\n' "\$@"; } >> "\$DOCKER_LOG" - exit 0 -fi -exec $(command -v docker) "\$@" -STUB -chmod +x "$work/bin/docker" - -# run <case env> <dir> <variable=value...>: the environment of a step, with the case's bake variables. -run() { - local case_file="$1" dir="$2" - shift 2 - local vars=() - while IFS= read -r line || [ -n "$line" ]; do - case "$line" in '' | '#'*) continue ;; esac - vars+=("$line") - done < "$case_file" - env -i PATH="$work/bin:$PATH" HOME="$HOME" RUNNER_TEMP="$dir" GITHUB_OUTPUT="$dir/output" \ - GITHUB_STEP_SUMMARY="$dir/summary" DOCKER_LOG="$dir/docker" "${vars[@]}" "$@" -} - -# section <title> <file...> -section() { - local title="$1" file - shift - for file in "$@"; do - echo "== $title${file:+ $(basename "$file")}" - if [[ $file == *.json ]]; then jq --sort-keys . "$file"; else cat "$file"; fi - echo - done -} - -# pipeline <case env> <push>: everything the scripts write, as one document. -pipeline() { - local case_file="$1" push="$2" dir slug - dir="$work/$(basename "$case_file" .env)" - mkdir -p "$dir" - : > "$dir/docker" - - run "$case_file" "$dir" FILES=$'\n bake/test/e2e/docker-bake.hcl\n' PUSH="$push" \ - RUNNERS='{"linux/arm64": "arm-runner"}' bake/plan/freeze.sh - sed 's/^\(.*\)<<EOF_.*/\1<<EOF/; s/^EOF_.*/EOF/' "$dir/output" > "$dir/outputs.txt" - : > "$dir/output" - - for slug in $(jq -r '.[].slug' "$dir/bake/matrix.json"); do - run "$case_file" "$dir" PLATFORM="$(jq -r --arg s "$slug" '.[] | select(.slug == $s) | .platform' "$dir/bake/matrix.json")" \ - SLUG="$slug" bake/narrow/narrow.sh - # What docker/bake-action reports: an object per target, and keys that aren't targets. - run "$case_file" "$dir" SLUG="$slug" METADATA="$(jq --arg slug "$slug" ' - .target | with_entries(.value = {"containerimage.digest": "sha256:\(.key)-\($slug)"}) - | . + {"buildx.build.warnings": []} - ' "$dir/bake/definition-$slug.json")" bake/digests/digests.sh > /dev/null - done - - if [ "$push" = true ]; then - run "$case_file" "$dir" bake/publish/publish.sh > /dev/null - fi - - section outputs "$dir/outputs.txt" - section summary "$dir/summary" - section bake "$dir"/bake/definition.json "$dir"/bake/publish.json "$dir"/bake/matrix.json \ - "$dir"/bake/definition-*.json - if [ "$push" = true ]; then - section digests "$dir"/digests/*.json - section docker "$dir/docker" - fi -} - -failed=0 - -for spec in tag-stable:true pr:false; do - name="${spec%%:*}" - expected="bake/test/pipeline/$name.txt" - actual=$(pipeline "bake/test/cases/$name.env" "${spec#*:}") - if $update; then - printf '%s\n' "$actual" > "$expected" - echo "updated pipeline $name" - elif diff -u --label "$expected" --label actual "$expected" <(printf '%s\n' "$actual"); then - echo "ok pipeline $name" - else - echo "FAILED pipeline $name" - failed=1 - fi -done - -# refuse <description> <expected error> <case env> <bake file content> <variable=value...> -refuse() { - local description="$1" expected="$2" case_file="$3" content="$4" dir status=0 actual - shift 4 - dir=$(mktemp -d "$work/refuse.XXXXXX") - printf '%s\n' "$content" > "$dir/docker-bake.hcl" - actual=$(run "$case_file" "$dir" FILES="$dir/docker-bake.hcl" "$@" bake/plan/freeze.sh 2>&1) || status=$? - if [ "$status" -ne 0 ] && [[ $actual == *"$expected"* ]]; then - echo "ok refuses $description" - else - echo "FAILED refuses $description" - echo " expected: $expected" - echo " actual: exit=$status $actual" - failed=1 - fi -} - -refuse 'bake files without targets' \ - 'The bake files define no targets to build.' \ - bake/test/cases/tag-stable.env 'group "default" { targets = [] }' PUSH=true -refuse 'a target without platforms' \ - 'target default has no platforms' \ - bake/test/cases/tag-stable.env 'target "default" { tags = specs_tags(["ghcr.io/specsnl/app"], "") }' PUSH=true -refuse 'pushing a target without tags' \ - 'target default has no tags for this event' \ - bake/test/cases/unknown-event.env \ - 'target "default" { - platforms = ["linux/amd64"] - tags = specs_tags(["ghcr.io/specsnl/app"], "") - }' PUSH=true -refuse 'a platform without a runner' \ - 'no runner for platform linux/riscv64' \ - bake/test/cases/tag-stable.env \ - 'target "default" { - platforms = ["linux/riscv64"] - tags = specs_tags(["ghcr.io/specsnl/app"], "") - }' PUSH=true - -exit "$failed" diff --git a/bake/test/pipeline/pr.txt b/bake/test/pipeline/pr.txt deleted file mode 100644 index 9d1cc5f..0000000 --- a/bake/test/pipeline/pr.txt +++ /dev/null @@ -1,452 +0,0 @@ -== outputs outputs.txt -matrix<<EOF -[{"platform":"linux/amd64","slug":"linux-amd64","runner":"ubuntu-26.04"},{"platform":"linux/arm64","slug":"linux-arm64","runner":"arm-runner"}] -EOF -artifact<<EOF -bake-84f32ca7fae9 -EOF - -== summary summary -### Bake definition - -Version `pr-42`, push `false`. - -| Target | Platforms | Tags | -|--------|-----------|------| -| `app` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e:pr-42` | -| `cli-alpine` | linux/amd64 | `ghcr.io/specsnl/github-actions/e2e-cli:pr-42-alpine` | -| `cli-debian` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e-cli:pr-42` | - -== bake definition.json -{ - "group": { - "default": { - "targets": [ - "app", - "cli-alpine", - "cli-debian" - ] - } - }, - "target": { - "app": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e app", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "secret": [ - { - "env": "E2E_SECRET", - "id": "e2e" - } - ], - "target": "app" - }, - "cli-alpine": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "args": { - "E2E_VERSION": "pr-42" - }, - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/amd64" - ], - "target": "alpine" - }, - "cli-debian": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "args": { - "E2E_VERSION": "pr-42" - }, - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "target": "debian" - } - } -} - -== bake publish.json -{ - "app": { - "image": "ghcr.io/specsnl/github-actions/e2e", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "tags": [ - "ghcr.io/specsnl/github-actions/e2e:pr-42" - ] - }, - "cli-alpine": { - "image": "ghcr.io/specsnl/github-actions/e2e-cli", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "platforms": [ - "linux/amd64" - ], - "tags": [ - "ghcr.io/specsnl/github-actions/e2e-cli:pr-42-alpine" - ] - }, - "cli-debian": { - "image": "ghcr.io/specsnl/github-actions/e2e-cli", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "tags": [ - "ghcr.io/specsnl/github-actions/e2e-cli:pr-42" - ] - } -} - -== bake matrix.json -[ - { - "platform": "linux/amd64", - "runner": "ubuntu-26.04", - "slug": "linux-amd64" - }, - { - "platform": "linux/arm64", - "runner": "arm-runner", - "slug": "linux-arm64" - } -] - -== bake definition-linux-amd64.json -{ - "group": { - "default": { - "targets": [ - "app", - "cli-alpine", - "cli-debian" - ] - } - }, - "target": { - "app": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e app", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/amd64" - ], - "secret": [ - { - "env": "E2E_SECRET", - "id": "e2e" - } - ], - "target": "app" - }, - "cli-alpine": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "args": { - "E2E_VERSION": "pr-42" - }, - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/amd64" - ], - "target": "alpine" - }, - "cli-debian": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "args": { - "E2E_VERSION": "pr-42" - }, - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/amd64" - ], - "target": "debian" - } - } -} - -== bake definition-linux-arm64.json -{ - "group": { - "default": { - "targets": [ - "app", - "cli-debian" - ] - } - }, - "target": { - "app": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e app", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/arm64" - ], - "secret": [ - { - "env": "E2E_SECRET", - "id": "e2e" - } - ], - "target": "app" - }, - "cli-debian": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=pr-42" - ], - "args": { - "E2E_VERSION": "pr-42" - }, - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "pr-42" - }, - "output": [ - "type=cacheonly" - ], - "platforms": [ - "linux/arm64" - ], - "target": "debian" - } - } -} diff --git a/bake/test/pipeline/tag-stable.txt b/bake/test/pipeline/tag-stable.txt deleted file mode 100644 index 278c1d6..0000000 --- a/bake/test/pipeline/tag-stable.txt +++ /dev/null @@ -1,628 +0,0 @@ -== outputs outputs.txt -matrix<<EOF -[{"platform":"linux/amd64","slug":"linux-amd64","runner":"ubuntu-26.04"},{"platform":"linux/arm64","slug":"linux-arm64","runner":"arm-runner"}] -EOF -artifact<<EOF -bake-84f32ca7fae9 -EOF - -== summary summary -### Bake definition - -Version `1.2.3`, push `true`. - -| Target | Platforms | Tags | -|--------|-----------|------| -| `app` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e:1.2.3`<br>`ghcr.io/specsnl/github-actions/e2e:1.2`<br>`ghcr.io/specsnl/github-actions/e2e:1`<br>`ghcr.io/specsnl/github-actions/e2e:latest` | -| `cli-alpine` | linux/amd64 | `ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1.2-alpine`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1-alpine`<br>`ghcr.io/specsnl/github-actions/e2e-cli:alpine` | -| `cli-debian` | linux/amd64, linux/arm64 | `ghcr.io/specsnl/github-actions/e2e-cli:1.2.3`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1.2`<br>`ghcr.io/specsnl/github-actions/e2e-cli:1`<br>`ghcr.io/specsnl/github-actions/e2e-cli:latest` | - -== bake definition.json -{ - "group": { - "default": { - "targets": [ - "app", - "cli-alpine", - "cli-debian" - ] - } - }, - "target": { - "app": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e app", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "secret": [ - { - "env": "E2E_SECRET", - "id": "e2e" - } - ], - "target": "app" - }, - "cli-alpine": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "args": { - "E2E_VERSION": "1.2.3" - }, - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/amd64" - ], - "target": "alpine" - }, - "cli-debian": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "args": { - "E2E_VERSION": "1.2.3" - }, - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "target": "debian" - } - } -} - -== bake publish.json -{ - "app": { - "image": "ghcr.io/specsnl/github-actions/e2e", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "tags": [ - "ghcr.io/specsnl/github-actions/e2e:1.2.3", - "ghcr.io/specsnl/github-actions/e2e:1.2", - "ghcr.io/specsnl/github-actions/e2e:1", - "ghcr.io/specsnl/github-actions/e2e:latest" - ] - }, - "cli-alpine": { - "image": "ghcr.io/specsnl/github-actions/e2e-cli", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "platforms": [ - "linux/amd64" - ], - "tags": [ - "ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine", - "ghcr.io/specsnl/github-actions/e2e-cli:1.2-alpine", - "ghcr.io/specsnl/github-actions/e2e-cli:1-alpine", - "ghcr.io/specsnl/github-actions/e2e-cli:alpine" - ] - }, - "cli-debian": { - "image": "ghcr.io/specsnl/github-actions/e2e-cli", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "platforms": [ - "linux/amd64", - "linux/arm64" - ], - "tags": [ - "ghcr.io/specsnl/github-actions/e2e-cli:1.2.3", - "ghcr.io/specsnl/github-actions/e2e-cli:1.2", - "ghcr.io/specsnl/github-actions/e2e-cli:1", - "ghcr.io/specsnl/github-actions/e2e-cli:latest" - ] - } -} - -== bake matrix.json -[ - { - "platform": "linux/amd64", - "runner": "ubuntu-26.04", - "slug": "linux-amd64" - }, - { - "platform": "linux/arm64", - "runner": "arm-runner", - "slug": "linux-arm64" - } -] - -== bake definition-linux-amd64.json -{ - "group": { - "default": { - "targets": [ - "app", - "cli-alpine", - "cli-debian" - ] - } - }, - "target": { - "app": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e app", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-amd64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/amd64" - ], - "secret": [ - { - "env": "E2E_SECRET", - "id": "e2e" - } - ], - "target": "app" - }, - "cli-alpine": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "args": { - "E2E_VERSION": "1.2.3" - }, - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-alpine-linux-amd64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/amd64" - ], - "target": "alpine" - }, - "cli-debian": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "args": { - "E2E_VERSION": "1.2.3" - }, - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-amd64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/amd64" - ], - "target": "debian" - } - } -} - -== bake definition-linux-arm64.json -{ - "group": { - "default": { - "targets": [ - "app", - "cli-debian" - ] - } - }, - "target": { - "app": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=End-to-end test image of specsnl/github-actions", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e app", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-app-linux-arm64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "End-to-end test image of specsnl/github-actions", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e app", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/arm64" - ], - "secret": [ - { - "env": "E2E_SECRET", - "id": "e2e" - } - ], - "target": "app" - }, - "cli-debian": { - "annotations": [ - "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", - "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", - "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=e2e cli", - "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.version=1.2.3" - ], - "args": { - "E2E_VERSION": "1.2.3" - }, - "cache-from": [ - "type=gha,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" - ], - "cache-to": [ - "type=gha,mode=max,scope=ghcr-io-specsnl-github-actions-e2e-cli-cli-debian-linux-arm64" - ], - "context": "bake/test/e2e", - "dockerfile": "Dockerfile", - "labels": { - "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", - "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", - "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "e2e cli", - "org.opencontainers.image.url": "https://github.com/specsnl/example", - "org.opencontainers.image.version": "1.2.3" - }, - "output": [ - "type=image,name=ghcr.io/specsnl/github-actions/e2e-cli,push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - ], - "platforms": [ - "linux/arm64" - ], - "target": "debian" - } - } -} - -== digests digests-linux-amd64.json -{ - "app": "sha256:app-linux-amd64", - "cli-alpine": "sha256:cli-alpine-linux-amd64", - "cli-debian": "sha256:cli-debian-linux-amd64" -} - -== digests digests-linux-arm64.json -{ - "app": "sha256:app-linux-arm64", - "cli-debian": "sha256:cli-debian-linux-arm64" -} - -== docker docker -docker - buildx - imagetools - create - --tag - ghcr.io/specsnl/github-actions/e2e:1.2.3 - --tag - ghcr.io/specsnl/github-actions/e2e:1.2 - --tag - ghcr.io/specsnl/github-actions/e2e:1 - --tag - ghcr.io/specsnl/github-actions/e2e:latest - --annotation - index:org.opencontainers.image.created=2026-11-09T12:00:00Z - --annotation - manifest-descriptor:org.opencontainers.image.created=2026-11-09T12:00:00Z - --annotation - index:org.opencontainers.image.description=End-to-end\ test\ image\ of\ specsnl/github-actions - --annotation - manifest-descriptor:org.opencontainers.image.description=End-to-end\ test\ image\ of\ specsnl/github-actions - --annotation - index:org.opencontainers.image.licenses=MIT - --annotation - manifest-descriptor:org.opencontainers.image.licenses=MIT - --annotation - index:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 - --annotation - manifest-descriptor:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 - --annotation - index:org.opencontainers.image.source=https://github.com/specsnl/example - --annotation - manifest-descriptor:org.opencontainers.image.source=https://github.com/specsnl/example - --annotation - index:org.opencontainers.image.title=e2e\ app - --annotation - manifest-descriptor:org.opencontainers.image.title=e2e\ app - --annotation - index:org.opencontainers.image.url=https://github.com/specsnl/example - --annotation - manifest-descriptor:org.opencontainers.image.url=https://github.com/specsnl/example - --annotation - index:org.opencontainers.image.version=1.2.3 - --annotation - manifest-descriptor:org.opencontainers.image.version=1.2.3 - ghcr.io/specsnl/github-actions/e2e@sha256:app-linux-amd64 - ghcr.io/specsnl/github-actions/e2e@sha256:app-linux-arm64 -docker - buildx - imagetools - inspect - ghcr.io/specsnl/github-actions/e2e:1.2.3 -docker - buildx - imagetools - create - --tag - ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine - --tag - ghcr.io/specsnl/github-actions/e2e-cli:1.2-alpine - --tag - ghcr.io/specsnl/github-actions/e2e-cli:1-alpine - --tag - ghcr.io/specsnl/github-actions/e2e-cli:alpine - --annotation - index:org.opencontainers.image.created=2026-11-09T12:00:00Z - --annotation - manifest-descriptor:org.opencontainers.image.created=2026-11-09T12:00:00Z - --annotation - index:org.opencontainers.image.description=An\ example\ repository - --annotation - manifest-descriptor:org.opencontainers.image.description=An\ example\ repository - --annotation - index:org.opencontainers.image.licenses=MIT - --annotation - manifest-descriptor:org.opencontainers.image.licenses=MIT - --annotation - index:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 - --annotation - manifest-descriptor:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 - --annotation - index:org.opencontainers.image.source=https://github.com/specsnl/example - --annotation - manifest-descriptor:org.opencontainers.image.source=https://github.com/specsnl/example - --annotation - index:org.opencontainers.image.title=e2e\ cli - --annotation - manifest-descriptor:org.opencontainers.image.title=e2e\ cli - --annotation - index:org.opencontainers.image.url=https://github.com/specsnl/example - --annotation - manifest-descriptor:org.opencontainers.image.url=https://github.com/specsnl/example - --annotation - index:org.opencontainers.image.version=1.2.3 - --annotation - manifest-descriptor:org.opencontainers.image.version=1.2.3 - ghcr.io/specsnl/github-actions/e2e-cli@sha256:cli-alpine-linux-amd64 -docker - buildx - imagetools - inspect - ghcr.io/specsnl/github-actions/e2e-cli:1.2.3-alpine -docker - buildx - imagetools - create - --tag - ghcr.io/specsnl/github-actions/e2e-cli:1.2.3 - --tag - ghcr.io/specsnl/github-actions/e2e-cli:1.2 - --tag - ghcr.io/specsnl/github-actions/e2e-cli:1 - --tag - ghcr.io/specsnl/github-actions/e2e-cli:latest - --annotation - index:org.opencontainers.image.created=2026-11-09T12:00:00Z - --annotation - manifest-descriptor:org.opencontainers.image.created=2026-11-09T12:00:00Z - --annotation - index:org.opencontainers.image.description=An\ example\ repository - --annotation - manifest-descriptor:org.opencontainers.image.description=An\ example\ repository - --annotation - index:org.opencontainers.image.licenses=MIT - --annotation - manifest-descriptor:org.opencontainers.image.licenses=MIT - --annotation - index:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 - --annotation - manifest-descriptor:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567 - --annotation - index:org.opencontainers.image.source=https://github.com/specsnl/example - --annotation - manifest-descriptor:org.opencontainers.image.source=https://github.com/specsnl/example - --annotation - index:org.opencontainers.image.title=e2e\ cli - --annotation - manifest-descriptor:org.opencontainers.image.title=e2e\ cli - --annotation - index:org.opencontainers.image.url=https://github.com/specsnl/example - --annotation - manifest-descriptor:org.opencontainers.image.url=https://github.com/specsnl/example - --annotation - index:org.opencontainers.image.version=1.2.3 - --annotation - manifest-descriptor:org.opencontainers.image.version=1.2.3 - ghcr.io/specsnl/github-actions/e2e-cli@sha256:cli-debian-linux-amd64 - ghcr.io/specsnl/github-actions/e2e-cli@sha256:cli-debian-linux-arm64 -docker - buildx - imagetools - inspect - ghcr.io/specsnl/github-actions/e2e-cli:1.2.3 From 23959c5607ae760cbe0be98a1a1684fce2481483 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Fri, 20 Nov 2026 21:59:20 +0100 Subject: [PATCH 07/13] Freeze one bake definition per platform in the plan job The plan job writes bake --print as bake.json and a definition per platform next to it, so the narrow and digests actions go. The build jobs upload bake's metadata as is, and publish reads the tags, labels and digests from bake.json and that metadata. --- .github/workflows/bake.yml | 37 +++++++++++++++---------------------- bake/digests/action.yml | 22 ---------------------- bake/digests/digests.sh | 14 -------------- bake/narrow/action.yml | 27 --------------------------- bake/narrow/narrow.jq | 9 --------- bake/narrow/narrow.sh | 14 -------------- bake/plan/action.yml | 2 +- bake/plan/definition.jq | 35 ++++++++++++++++++----------------- bake/plan/freeze.sh | 25 +++++++++++++------------ bake/plan/matrix.jq | 12 ++++++++++-- bake/plan/publish.jq | 8 -------- bake/publish/action.yml | 2 +- bake/publish/publish.sh | 25 ++++++++++++++----------- 13 files changed, 72 insertions(+), 160 deletions(-) delete mode 100644 bake/digests/action.yml delete mode 100755 bake/digests/digests.sh delete mode 100644 bake/narrow/action.yml delete mode 100644 bake/narrow/narrow.jq delete mode 100755 bake/narrow/narrow.sh delete mode 100644 bake/plan/publish.jq diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 4cac39a..fa89ea9 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -95,9 +95,7 @@ jobs: uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: name: ${{ steps.plan.outputs.artifact }}-definition - path: | - ${{ runner.temp }}/bake/definition.json - ${{ runner.temp }}/bake/publish.json + path: ${{ runner.temp }}/bake/*.json if-no-files-found: error retention-days: 1 @@ -126,13 +124,6 @@ jobs: name: ${{ needs.plan.outputs.artifact }}-definition path: ${{ runner.temp }}/bake - - name: Narrow the definition to ${{ matrix.platform }} - id: definition - uses: $/bake/narrow - with: - platform: ${{ matrix.platform }} - slug: ${{ matrix.slug }} - - name: Export the build secrets uses: $/bake/secrets with: @@ -160,21 +151,23 @@ jobs: BUILDX_NO_DEFAULT_ATTESTATIONS: 1 with: source: . - files: ${{ steps.definition.outputs.file }} + files: ${{ runner.temp }}/bake/definition-${{ matrix.slug }}.json - - name: Export the digests + - name: Save the build metadata if: ${{ needs.plan.outputs.push == 'true' }} - uses: $/bake/digests - with: - metadata: ${{ steps.bake.outputs.metadata }} - slug: ${{ matrix.slug }} + env: + METADATA: ${{ steps.bake.outputs.metadata }} + SLUG: ${{ matrix.slug }} + run: | + mkdir -p "$RUNNER_TEMP/metadata" + printf '%s\n' "$METADATA" > "$RUNNER_TEMP/metadata/$SLUG.json" - - name: Upload the digests + - name: Upload the build metadata if: ${{ needs.plan.outputs.push == 'true' }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ${{ needs.plan.outputs.artifact }}-digests-${{ matrix.slug }} - path: ${{ runner.temp }}/digests/digests-${{ matrix.slug }}.json + name: ${{ needs.plan.outputs.artifact }}-metadata-${{ matrix.slug }} + path: ${{ runner.temp }}/metadata/${{ matrix.slug }}.json if-no-files-found: error retention-days: 1 @@ -194,11 +187,11 @@ jobs: name: ${{ needs.plan.outputs.artifact }}-definition path: ${{ runner.temp }}/bake - - name: Download the digests + - name: Download the build metadata uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: - pattern: ${{ needs.plan.outputs.artifact }}-digests-* - path: ${{ runner.temp }}/digests + pattern: ${{ needs.plan.outputs.artifact }}-metadata-* + path: ${{ runner.temp }}/metadata merge-multiple: true - name: Log in to the Container registry diff --git a/bake/digests/action.yml b/bake/digests/action.yml deleted file mode 100644 index 0a16aa1..0000000 --- a/bake/digests/action.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: Bake digests -description: >- - Internal to .github/workflows/bake.yml. Writes the digests of a build job's images to - $RUNNER_TEMP/digests/digests-<slug>.json. - -inputs: - metadata: - description: The metadata output of docker/bake-action. - required: true - slug: - description: The platform as a name, i.e. "linux-amd64". - required: true - -runs: - using: composite - steps: - - name: Export the digests - shell: bash - env: - METADATA: ${{ inputs.metadata }} - SLUG: ${{ inputs.slug }} - run: bash "$GITHUB_ACTION_PATH/digests.sh" diff --git a/bake/digests/digests.sh b/bake/digests/digests.sh deleted file mode 100755 index 07abe3f..0000000 --- a/bake/digests/digests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# Writes the image digest of every target in bake's build metadata to $RUNNER_TEMP/digests/digests-$SLUG.json, as -# {"<target>": "<digest>"}. -# -# Reads METADATA and SLUG. -set -euo pipefail - -dir="$RUNNER_TEMP/digests" -mkdir -p "$dir" -jq ' - with_entries(select(.value | type == "object")) - | map_values(.["containerimage.digest"] // error("no digest in the build metadata")) -' <<< "$METADATA" > "$dir/digests-$SLUG.json" -cat "$dir/digests-$SLUG.json" diff --git a/bake/narrow/action.yml b/bake/narrow/action.yml deleted file mode 100644 index c611cb3..0000000 --- a/bake/narrow/action.yml +++ /dev/null @@ -1,27 +0,0 @@ -name: Bake narrow -description: >- - Internal to .github/workflows/bake.yml. Narrows the bake definition in $RUNNER_TEMP/bake to one platform. - -inputs: - platform: - description: The platform to build, i.e. "linux/amd64". - required: true - slug: - description: The platform as a name, i.e. "linux-amd64". - required: true - -outputs: - file: - description: The narrowed bake definition. - value: ${{ steps.narrow.outputs.file }} - -runs: - using: composite - steps: - - name: Narrow the definition - id: narrow - shell: bash - env: - PLATFORM: ${{ inputs.platform }} - SLUG: ${{ inputs.slug }} - run: bash "$GITHUB_ACTION_PATH/narrow.sh" diff --git a/bake/narrow/narrow.jq b/bake/narrow/narrow.jq deleted file mode 100644 index 7849747..0000000 --- a/bake/narrow/narrow.jq +++ /dev/null @@ -1,9 +0,0 @@ -# The targets that build for $platform, narrowed to it, each with its own GitHub Actions cache scope. -.target |= with_entries( - select(.value.platforms | index($platform)) - | ("\($publish[0][.key].image | gsub("[^A-Za-z0-9]+"; "-"))-\(.key)-\($slug)") as $scope - | .value.platforms = [$platform] - | .value["cache-from"] = ["type=gha,scope=\($scope)"] - | .value["cache-to"] = ["type=gha,mode=max,scope=\($scope)"] -) -| .group = {default: {targets: (.target | keys)}} diff --git a/bake/narrow/narrow.sh b/bake/narrow/narrow.sh deleted file mode 100755 index 1f6ea62..0000000 --- a/bake/narrow/narrow.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -# Narrows $RUNNER_TEMP/bake/definition.json to one platform, see narrow.jq. -# -# Reads PLATFORM and SLUG. Sets the output file to the narrowed definition. -set -euo pipefail - -here=$(cd "$(dirname "$0")" && pwd) -# shellcheck source=../lib.sh -source "$here/../lib.sh" - -dir="$RUNNER_TEMP/bake" -jq --arg platform "$PLATFORM" --arg slug "$SLUG" --slurpfile publish "$dir/publish.json" -f "$here/narrow.jq" \ - "$dir/definition.json" > "$dir/definition-$SLUG.json" -output file "$dir/definition-$SLUG.json" diff --git a/bake/plan/action.yml b/bake/plan/action.yml index 9f444c4..c07f7ad 100644 --- a/bake/plan/action.yml +++ b/bake/plan/action.yml @@ -1,7 +1,7 @@ name: Bake plan description: >- Internal to .github/workflows/bake.yml. Works out the run's variables and resolves the bake files, with this - repository's bake/specs.hcl first, into the definition, publish list and build matrix in $RUNNER_TEMP/bake. + repository's bake/specs.hcl first, into the build matrix and the frozen definitions in $RUNNER_TEMP/bake. inputs: files: diff --git a/bake/plan/definition.jq b/bake/plan/definition.jq index 92ac948..4b471ca 100644 --- a/bake/plan/definition.jq +++ b/bake/plan/definition.jq @@ -1,21 +1,22 @@ -# The targets as the build jobs build them: pushed by digest when $push is "true", otherwise only to the cache. The -# tags and cache settings are left out; the publish job tags the images, and each build job sets its own cache. -def image: .tags[0] | sub(":[^:/]*$"; ""); +# The targets that build for $platform, as its build job builds them: narrowed to $platform, pushed by digest when +# $push is "true" and otherwise only to the cache, with a cache scope per image, target and platform. The tags are left +# out; the publish job tags the images. +def image: .tags[0] // "" | sub(":[^:/]*$"; ""); .target |= with_entries( - if (.value.platforms // []) == [] then - error("target \(.key) has no platforms; set platforms in the bake file") - elif $push == "true" and (.value.tags // []) == [] then - error("target \(.key) has no tags for this event, so there is nothing to push") - else . end + select(.value.platforms | index($platform)) + | "\(.value | image | gsub("[^A-Za-z0-9]+"; "-"))-\(.key)-\($slug)" as $scope + | .value |= ( + (if $push == "true" then + "type=image,name=\(image),push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" + else + "type=cacheonly" + end) as $output + | del(.tags, .load, .push) + | .platforms = [$platform] + | .output = [$output] + | .["cache-from"] = ["type=gha,scope=\($scope)"] + | .["cache-to"] = ["type=gha,mode=max,scope=\($scope)"] + ) ) -| .target |= map_values( - (if $push == "true" then - "type=image,name=\(image),push-by-digest=true,name-canonical=true,oci-mediatypes=true,push=true" - else - "type=cacheonly" - end) as $output - | del(.tags, .output, .["cache-from"], .["cache-to"], .load, .push) - | .output = [$output] - ) | .group = {default: {targets: (.target | keys)}} diff --git a/bake/plan/freeze.sh b/bake/plan/freeze.sh index 1ef0875..762f17a 100755 --- a/bake/plan/freeze.sh +++ b/bake/plan/freeze.sh @@ -1,9 +1,8 @@ #!/usr/bin/env bash # Resolves the bake files, with specs.hcl first, into fixed JSON in $RUNNER_TEMP/bake for the build and publish jobs: # -# definition.json the targets to build, see definition.jq -# publish.json the images, tags, labels and platforms to publish, see publish.jq -# matrix.json the build jobs, see matrix.jq +# bake.json the output of bake --print; the publish job reads the tags, labels and platforms from it +# definition-<slug>.json what the build job for one platform builds, see definition.jq # # Reads FILES, TARGETS, RUNNERS and PUSH, and passes the environment on to bake for its variables (VERSION, EVENT, # ...). Sets the outputs matrix and artifact, and writes the step summary. @@ -25,17 +24,19 @@ mapfile -t targets < <(printf '%s\n' "${TARGETS:-}" | trim_lines) dir="$RUNNER_TEMP/bake" mkdir -p "$dir" -docker buildx bake --progress=quiet "${files[@]}" --print "${targets[@]}" > "$dir/print.json" -if jq -e '(.target // {}) == {}' "$dir/print.json" > /dev/null; then +docker buildx bake --progress=quiet "${files[@]}" --print "${targets[@]}" > "$dir/bake.json" +if jq -e '(.target // {}) == {}' "$dir/bake.json" > /dev/null; then echo "::error::The bake files define no targets to build." exit 1 fi -jq --arg push "$PUSH" -f "$here/definition.jq" "$dir/print.json" > "$dir/definition.json" -jq -f "$here/publish.jq" "$dir/print.json" > "$dir/publish.json" -jq --argjson override "${RUNNERS:-"{}"}" -f "$here/matrix.jq" "$dir/print.json" > "$dir/matrix.json" +matrix=$(jq -c --argjson override "${RUNNERS:-"{}"}" --arg push "$PUSH" -f "$here/matrix.jq" "$dir/bake.json") +for slug in $(jq -r '.[].slug' <<< "$matrix"); do + jq --arg platform "$(jq -r --arg slug "$slug" '.[] | select(.slug == $slug) | .platform' <<< "$matrix")" \ + --arg slug "$slug" --arg push "$PUSH" -f "$here/definition.jq" "$dir/bake.json" > "$dir/definition-$slug.json" +done -output matrix "$(jq -c . "$dir/matrix.json")" +output matrix "$matrix" # Unique per call, so a caller can use bake.yml more than once in a run. output artifact "bake-$(printf '%s\n' "${FILES:-}" "${TARGETS:-}" | sha256sum | cut -c1-12)" @@ -47,7 +48,7 @@ output artifact "bake-$(printf '%s\n' "${FILES:-}" "${TARGETS:-}" | sha256sum | echo '| Target | Platforms | Tags |' echo '|--------|-----------|------|' jq -r ' - to_entries[] - | "| `\(.key)` | \(.value.platforms | join(", ")) | \(.value.tags | map("`\(.)`") | join("<br>")) |" - ' "$dir/publish.json" + .target | to_entries[] + | "| `\(.key)` | \(.value.platforms | join(", ")) | \(.value.tags // [] | map("`\(.)`") | join("<br>")) |" + ' "$dir/bake.json" } >> "$GITHUB_STEP_SUMMARY" diff --git a/bake/plan/matrix.jq b/bake/plan/matrix.jq index 7e3b076..0364ac7 100644 --- a/bake/plan/matrix.jq +++ b/bake/plan/matrix.jq @@ -1,6 +1,14 @@ -# One build job per platform, on the runner $override maps it to, or the default one. +# Checks the targets, then plans one build job per platform, on the runner $override maps it to, or the default one. ({"linux/amd64": "ubuntu-26.04", "linux/arm64": "ubuntu-26.04-arm"} + $override) as $runners -| [.target[].platforms[]] | unique +| [ + .target | to_entries[] + | if (.value.platforms // []) == [] then + error("target \(.key) has no platforms; set platforms in the bake file") + elif $push == "true" and (.value.tags // []) == [] then + error("target \(.key) has no tags for this event, so there is nothing to push") + else .value.platforms[] end + ] +| unique | map({ platform: ., slug: gsub("[^A-Za-z0-9]+"; "-"), diff --git a/bake/plan/publish.jq b/bake/plan/publish.jq deleted file mode 100644 index 13ce6cf..0000000 --- a/bake/plan/publish.jq +++ /dev/null @@ -1,8 +0,0 @@ -# Per target, what the publish job needs: the image name, its tags, the labels it copies into annotations, and the -# platforms it expects a digest for. -.target | map_values({ - image: (.tags[0] // "" | sub(":[^:/]*$"; "")), - tags: (.tags // []), - labels: (.labels // {}), - platforms -}) diff --git a/bake/publish/action.yml b/bake/publish/action.yml index 45fc145..3546e2e 100644 --- a/bake/publish/action.yml +++ b/bake/publish/action.yml @@ -1,7 +1,7 @@ name: Bake publish description: >- Internal to .github/workflows/bake.yml. Creates, tags and annotates the multi-platform manifests from the bake - definition in $RUNNER_TEMP/bake and the digests in $RUNNER_TEMP/digests. + definition in $RUNNER_TEMP/bake and the build metadata in $RUNNER_TEMP/metadata. runs: using: composite diff --git a/bake/publish/publish.sh b/bake/publish/publish.sh index a9c3060..0d2e910 100755 --- a/bake/publish/publish.sh +++ b/bake/publish/publish.sh @@ -1,22 +1,25 @@ #!/usr/bin/env bash -# Creates a multi-platform manifest list for every target in $RUNNER_TEMP/bake/publish.json from the build jobs' -# digests in $RUNNER_TEMP/digests, tags it, and copies the target's labels onto it as annotations. +# Creates a multi-platform manifest list for every target in $RUNNER_TEMP/bake/bake.json from the digests in the build +# jobs' metadata in $RUNNER_TEMP/metadata, tags it, and copies the target's labels onto it as annotations. set -euo pipefail -publish="$RUNNER_TEMP/bake/publish.json" +bake="$RUNNER_TEMP/bake/bake.json" +# {"<target>": ["<digest>", ...]}. Bake's metadata has an object per target, and keys that aren't targets. digests=$(jq -s ' - map(to_entries) | add | group_by(.key) | map({key: .[0].key, value: map(.value)}) | from_entries -' "$RUNNER_TEMP"/digests/digests-*.json) + map(with_entries(select(.value | type == "object")) | to_entries) | add | group_by(.key) + | map({key: .[0].key, value: map(.value["containerimage.digest"] // error("no digest in the build metadata"))}) + | from_entries +' "$RUNNER_TEMP"/metadata/*.json) -for target in $(jq -r 'keys[]' "$publish"); do - image=$(jq -r --arg t "$target" '.[$t].image' "$publish") - mapfile -t tags < <(jq -r --arg t "$target" '.[$t].tags[]' "$publish") +for target in $(jq -r '.target | keys[]' "$bake"); do + image=$(jq -r --arg t "$target" '.target[$t].tags[0] | sub(":[^:/]*$"; "")' "$bake") + mapfile -t tags < <(jq -r --arg t "$target" '.target[$t].tags[]' "$bake") mapfile -t annotations < <(jq -r --arg t "$target" ' - .[$t].labels | to_entries[] | "index:\(.key)=\(.value)", "manifest-descriptor:\(.key)=\(.value)" - ' "$publish") + .target[$t].labels // {} | to_entries[] | "index:\(.key)=\(.value)", "manifest-descriptor:\(.key)=\(.value)" + ' "$bake") mapfile -t sources < <(jq -r --arg t "$target" --arg image "$image" '(.[$t] // [])[] | "\($image)@\(.)"' <<< "$digests") - expected=$(jq -r --arg t "$target" '.[$t].platforms | length' "$publish") + expected=$(jq -r --arg t "$target" '.target[$t].platforms | length' "$bake") if [ "${#sources[@]}" -ne "$expected" ]; then echo "::error::$target has ${#sources[@]} digests for $expected platforms." exit 1 From e534623a03fe700e8788fe05fff958d57968bc96 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Fri, 20 Nov 2026 21:59:39 +0100 Subject: [PATCH 08/13] Use fixed artifact names in bake.yml A repository calls bake.yml once per run, so the per-call artifact prefix and the output that carried it go. --- .github/workflows/bake.yml | 11 +++++------ bake/plan/action.yml | 3 --- bake/plan/freeze.sh | 4 +--- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index fa89ea9..9417017 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -72,7 +72,6 @@ jobs: version: ${{ steps.plan.outputs.version }} push: ${{ steps.plan.outputs.push }} matrix: ${{ steps.plan.outputs.matrix }} - artifact: ${{ steps.plan.outputs.artifact }} steps: - name: Checkout @@ -94,7 +93,7 @@ jobs: - name: Upload the bake definition uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ${{ steps.plan.outputs.artifact }}-definition + name: bake-definition path: ${{ runner.temp }}/bake/*.json if-no-files-found: error retention-days: 1 @@ -121,7 +120,7 @@ jobs: - name: Download the bake definition uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: - name: ${{ needs.plan.outputs.artifact }}-definition + name: bake-definition path: ${{ runner.temp }}/bake - name: Export the build secrets @@ -166,7 +165,7 @@ jobs: if: ${{ needs.plan.outputs.push == 'true' }} uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 with: - name: ${{ needs.plan.outputs.artifact }}-metadata-${{ matrix.slug }} + name: bake-metadata-${{ matrix.slug }} path: ${{ runner.temp }}/metadata/${{ matrix.slug }}.json if-no-files-found: error retention-days: 1 @@ -184,13 +183,13 @@ jobs: - name: Download the bake definition uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: - name: ${{ needs.plan.outputs.artifact }}-definition + name: bake-definition path: ${{ runner.temp }}/bake - name: Download the build metadata uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 with: - pattern: ${{ needs.plan.outputs.artifact }}-metadata-* + pattern: bake-metadata-* path: ${{ runner.temp }}/metadata merge-multiple: true diff --git a/bake/plan/action.yml b/bake/plan/action.yml index c07f7ad..38e3ea1 100644 --- a/bake/plan/action.yml +++ b/bake/plan/action.yml @@ -36,9 +36,6 @@ outputs: matrix: description: The build jobs, as a JSON array of {platform, slug, runner}. value: ${{ steps.freeze.outputs.matrix }} - artifact: - description: The prefix of this call's artifact names. - value: ${{ steps.freeze.outputs.artifact }} runs: using: composite diff --git a/bake/plan/freeze.sh b/bake/plan/freeze.sh index 762f17a..5f48ca6 100755 --- a/bake/plan/freeze.sh +++ b/bake/plan/freeze.sh @@ -5,7 +5,7 @@ # definition-<slug>.json what the build job for one platform builds, see definition.jq # # Reads FILES, TARGETS, RUNNERS and PUSH, and passes the environment on to bake for its variables (VERSION, EVENT, -# ...). Sets the outputs matrix and artifact, and writes the step summary. +# ...). Sets the output matrix and writes the step summary. set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) @@ -37,8 +37,6 @@ for slug in $(jq -r '.[].slug' <<< "$matrix"); do done output matrix "$matrix" -# Unique per call, so a caller can use bake.yml more than once in a run. -output artifact "bake-$(printf '%s\n' "${FILES:-}" "${TARGETS:-}" | sha256sum | cut -c1-12)" { echo '### Bake definition' From 9e2208d5e7c9f80459f6195a38f55206465882e0 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Fri, 20 Nov 2026 22:01:00 +0100 Subject: [PATCH 09/13] Export the build secrets inline, without a list of reserved names The caller already controls its own workflow, so refusing names like PATH protects nothing. The step keeps the NAME=value check and the masking, and lib.sh moves next to the plan scripts, its only users. --- .github/workflows/bake.yml | 18 ++++++++-- .github/workflows/lint.yml | 4 +-- Taskfile.dist.yml | 5 ++- bake/lib.sh | 24 ------------- bake/plan/freeze.sh | 4 +-- bake/plan/lib.sh | 15 ++++++++ bake/plan/repository.sh | 4 +-- bake/plan/vars.sh | 4 +-- bake/secrets/action.yml | 17 --------- bake/secrets/secrets.sh | 27 --------------- bake/test/secrets.sh | 70 -------------------------------------- 11 files changed, 39 insertions(+), 153 deletions(-) delete mode 100644 bake/lib.sh create mode 100644 bake/plan/lib.sh delete mode 100644 bake/secrets/action.yml delete mode 100755 bake/secrets/secrets.sh delete mode 100755 bake/test/secrets.sh diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml index 9417017..79363b6 100644 --- a/.github/workflows/bake.yml +++ b/.github/workflows/bake.yml @@ -124,9 +124,21 @@ jobs: path: ${{ runner.temp }}/bake - name: Export the build secrets - uses: $/bake/secrets - with: - secrets: ${{ secrets.build-secrets }} + env: + BUILD_SECRETS: ${{ secrets.build-secrets }} + run: | + while IFS= read -r line; do + [ -z "${line//[[:space:]]/}" ] && continue + if [[ ! $line =~ ^[A-Za-z_][A-Za-z0-9_]*= ]]; then + echo "::error::build-secrets lines must be NAME=value, with a NAME of letters, digits and underscores." + exit 1 + fi + value="${line#*=}" + [ -n "$value" ] && echo "::add-mask::$value" + # The random delimiter keeps a value from ending the block early or injecting more variables. + delimiter="EOF_$(openssl rand -hex 16)" + printf '%s<<%s\n%s\n%s\n' "${line%%=*}" "$delimiter" "$value" "$delimiter" >> "$GITHUB_ENV" + done <<< "$BUILD_SECRETS" - name: Log in to the Container registry if: ${{ needs.plan.outputs.push == 'true' }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index af433e3..74588fc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -37,9 +37,7 @@ jobs: run: bake/test/run.sh - name: Run the plan tests run: bake/test/vars.sh - - name: Run the build secrets tests - run: bake/test/secrets.sh - name: Run shellcheck run: >- docker run --rm --volume "$PWD:/mnt" --workdir /mnt koalaman/shellcheck:v0.11.0 - bake/lib.sh bake/*/*.sh bake/test/*.sh + bake/*/*.sh bake/test/*.sh diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index ee15e42..752cc1b 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -18,14 +18,13 @@ tasks: --volume "{{.ROOT_DIR}}:/workdir" --workdir /workdir koalaman/shellcheck:{{.SHELLCHECK_TAG_VERSION}} - bake/lib.sh bake/*/*.sh bake/test/*.sh + bake/*/*.sh bake/test/*.sh test: - desc: Run the bake/specs.hcl fixture tests and the tests of the bake actions' scripts + desc: Run the bake/specs.hcl fixture tests and the plan tests cmds: - bake/test/run.sh - bake/test/vars.sh - - bake/test/secrets.sh test:update: desc: Rewrite the expected output of the specs.hcl fixture tests diff --git a/bake/lib.sh b/bake/lib.sh deleted file mode 100644 index f0c67e4..0000000 --- a/bake/lib.sh +++ /dev/null @@ -1,24 +0,0 @@ -# shellcheck shell=bash -# Helpers for the scripts of the bake actions. Source it, don't run it. - -# output <name> <value>: set a step output. The value may span several lines. -output() { - _bake_write "$GITHUB_OUTPUT" "$1" "$2" -} - -# export_env <name> <value>: set an environment variable for the job's later steps. -export_env() { - _bake_write "$GITHUB_ENV" "$1" "$2" -} - -# The random delimiter keeps a value from ending the block early or injecting more variables. -_bake_write() { - local delimiter - delimiter="EOF_$(openssl rand -hex 16)" - printf '%s<<%s\n%s\n%s\n' "$2" "$delimiter" "$3" "$delimiter" >> "$1" -} - -# Reads lines from stdin and writes them trimmed, without the empty ones. -trim_lines() { - sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' -} diff --git a/bake/plan/freeze.sh b/bake/plan/freeze.sh index 5f48ca6..be0ea4d 100755 --- a/bake/plan/freeze.sh +++ b/bake/plan/freeze.sh @@ -9,8 +9,8 @@ set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) -# shellcheck source=../lib.sh -source "$here/../lib.sh" +# shellcheck source=lib.sh +source "$here/lib.sh" specs="$here/../specs.hcl" if [ ! -f "$specs" ]; then diff --git a/bake/plan/lib.sh b/bake/plan/lib.sh new file mode 100644 index 0000000..2b0ca36 --- /dev/null +++ b/bake/plan/lib.sh @@ -0,0 +1,15 @@ +# shellcheck shell=bash +# Helpers for the scripts of the plan action. Source it, don't run it. + +# output <name> <value>: set a step output. The value may span several lines; the random delimiter keeps it from +# ending the block early or injecting more outputs. +output() { + local delimiter + delimiter="EOF_$(openssl rand -hex 16)" + printf '%s<<%s\n%s\n%s\n' "$1" "$delimiter" "$2" "$delimiter" >> "$GITHUB_OUTPUT" +} + +# Reads lines from stdin and writes them trimmed, without the empty ones. +trim_lines() { + sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' -e '/^$/d' +} diff --git a/bake/plan/repository.sh b/bake/plan/repository.sh index b5a1f2b..c7a2da5 100755 --- a/bake/plan/repository.sh +++ b/bake/plan/repository.sh @@ -4,8 +4,8 @@ # Reads GH_TOKEN and GITHUB_REPOSITORY. Sets the outputs name, description and license. set -euo pipefail -# shellcheck source=../lib.sh -source "$(dirname "$0")/../lib.sh" +# shellcheck source=lib.sh +source "$(dirname "$0")/lib.sh" repository=$(gh api "repos/$GITHUB_REPOSITORY") diff --git a/bake/plan/vars.sh b/bake/plan/vars.sh index d4a0f55..6c08091 100755 --- a/bake/plan/vars.sh +++ b/bake/plan/vars.sh @@ -5,8 +5,8 @@ # variables of the event. Sets the outputs version, dispatch-tag, is-stable, push and created. set -euo pipefail -# shellcheck source=../lib.sh -source "$(dirname "$0")/../lib.sh" +# shellcheck source=lib.sh +source "$(dirname "$0")/lib.sh" dispatch_tag="${INPUT_DISPATCH_TAG:-}" dispatch_tag="${dispatch_tag,,}" diff --git a/bake/secrets/action.yml b/bake/secrets/action.yml deleted file mode 100644 index 8545c42..0000000 --- a/bake/secrets/action.yml +++ /dev/null @@ -1,17 +0,0 @@ -name: Bake secrets -description: >- - Internal to .github/workflows/bake.yml. Masks the build secrets and exports them as environment variables. - -inputs: - secrets: - description: Build secrets as "NAME=value" lines. - required: false - -runs: - using: composite - steps: - - name: Export the build secrets - shell: bash - env: - BUILD_SECRETS: ${{ inputs.secrets }} - run: bash "$GITHUB_ACTION_PATH/secrets.sh" diff --git a/bake/secrets/secrets.sh b/bake/secrets/secrets.sh deleted file mode 100755 index f4c0223..0000000 --- a/bake/secrets/secrets.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash -# Masks every build secret and exports it as an environment variable for the build. -# -# Reads BUILD_SECRETS, "NAME=value" lines. Blank lines are skipped. A NAME the runner or the build tooling depends on -# is refused, so a secret can't change how the job runs. -set -euo pipefail - -# shellcheck source=../lib.sh -source "$(dirname "$0")/../lib.sh" - -while IFS= read -r line || [ -n "$line" ]; do - [ -z "${line//[[:space:]]/}" ] && continue - name="${line%%=*}" - value="${line#*=}" - if [ "$name" = "$line" ] || [[ ! $name =~ ^[A-Za-z_][A-Za-z0-9_]*$ ]]; then - echo "::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores." - exit 1 - fi - case "$name" in - GITHUB_* | RUNNER_* | ACTIONS_* | BUILDX_* | DOCKER_* | PATH | HOME | BASH_ENV | ENV | NODE_OPTIONS | LD_*) - echo "::error::build-secrets may not set $name." - exit 1 - ;; - esac - [ -n "$value" ] && echo "::add-mask::$value" - export_env "$name" "$value" -done <<< "${BUILD_SECRETS:-}" diff --git a/bake/test/secrets.sh b/bake/test/secrets.sh deleted file mode 100755 index c26cfa0..0000000 --- a/bake/test/secrets.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash -# Runs bake/secrets/secrets.sh on a set of build-secrets inputs and checks the variables it exports and masks. -set -euo pipefail - -cd "$(dirname "$0")/../.." - -failed=0 - -# check <description> <expected> <build secrets> -check() { - local description="$1" expected="$2" secrets="$3" - - local env stdout status=0 actual - env=$(mktemp) - stdout=$(env -i PATH="$PATH" GITHUB_ENV="$env" BUILD_SECRETS="$secrets" bake/secrets/secrets.sh 2>&1) || status=$? - - if [ "$status" -ne 0 ]; then - actual="exit=$status $stdout" - else - actual=$( - { - printf '%s\n' "$stdout" - awk '/<<EOF_/ { key = substr($0, 1, index($0, "<<") - 1); getline value; print key "=" value; getline }' "$env" - } | sed '/^$/d' | paste -sd ' ' - - ) - fi - rm -f "$env" - - if [ "$actual" = "$expected" ]; then - echo "ok $description" - else - echo "FAILED $description" - echo " expected: $expected" - echo " actual: $actual" - failed=1 - fi -} - -check 'no secrets' \ - '' \ - '' -check 'one secret' \ - '::add-mask::s3cret TOKEN=s3cret' \ - 'TOKEN=s3cret' -check 'blank lines and a last line without a newline' \ - '::add-mask::a ::add-mask::b A=a B=b' \ - $'\n \nA=a\n\nB=b' -check 'a value with = in it' \ - '::add-mask::x=y==z KEY=x=y==z' \ - 'KEY=x=y==z' -check 'an empty value is exported but not masked' \ - 'EMPTY=' \ - 'EMPTY=' -check 'a line without =' \ - 'exit=1 ::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores.' \ - 'TOKEN' -check 'a name with a dash' \ - 'exit=1 ::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores.' \ - 'MY-TOKEN=x' -check 'a name starting with a digit' \ - 'exit=1 ::error::Every line of build-secrets must be NAME=value, with a NAME of letters, digits and underscores.' \ - '1TOKEN=x' -for name in GITHUB_TOKEN RUNNER_TEMP ACTIONS_RUNTIME_TOKEN BUILDX_BUILDER DOCKER_HOST PATH HOME BASH_ENV ENV \ - NODE_OPTIONS LD_PRELOAD; do - check "the reserved name $name" \ - "exit=1 ::error::build-secrets may not set $name." \ - "$name=x" -done - -exit "$failed" From d10c39e539e911e27429d983ef238e5e30ac7074 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Fri, 20 Nov 2026 22:01:36 +0100 Subject: [PATCH 10/13] Drop the repository fallbacks for the title, description and licenses labels The plan job no longer reads the repository from the GitHub API. Targets pass their title and description to specs_labels, and an empty one is left out like any other empty value. --- bake/plan/action.yml | 13 ------------ bake/plan/repository.sh | 15 -------------- bake/specs.hcl | 23 ++++------------------ bake/test/cases/branch.env | 3 --- bake/test/cases/branch.json | 16 --------------- bake/test/cases/dispatch.env | 3 --- bake/test/cases/dispatch.json | 16 --------------- bake/test/cases/pr.env | 3 --- bake/test/cases/pr.json | 16 --------------- bake/test/cases/schedule.env | 3 --- bake/test/cases/schedule.json | 16 --------------- bake/test/cases/tag-not-semver.env | 3 --- bake/test/cases/tag-not-semver.json | 16 --------------- bake/test/cases/tag-prerelease.env | 3 --- bake/test/cases/tag-prerelease.json | 16 --------------- bake/test/cases/tag-stable-not-semver.env | 3 --- bake/test/cases/tag-stable-not-semver.json | 16 --------------- bake/test/cases/tag-stable.env | 3 --- bake/test/cases/tag-stable.json | 16 --------------- bake/test/cases/tag-v0.0.env | 3 --- bake/test/cases/tag-v0.0.json | 16 --------------- bake/test/cases/tag-v0.env | 3 --- bake/test/cases/tag-v0.json | 16 --------------- bake/test/cases/unknown-event.env | 3 --- bake/test/cases/unknown-event.json | 16 --------------- bake/test/run.sh | 2 +- 26 files changed, 5 insertions(+), 257 deletions(-) delete mode 100755 bake/plan/repository.sh diff --git a/bake/plan/action.yml b/bake/plan/action.yml index 38e3ea1..4f5a3e5 100644 --- a/bake/plan/action.yml +++ b/bake/plan/action.yml @@ -22,9 +22,6 @@ inputs: runners: description: JSON object mapping a platform to its runner. required: false - token: - description: Token to read the repository's metadata with. - default: ${{ github.token }} outputs: version: @@ -53,13 +50,6 @@ runs: PR_HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }} run: bash "$GITHUB_ACTION_PATH/vars.sh" - - name: Read the repository - id: repository - shell: bash - env: - GH_TOKEN: ${{ inputs.token }} - run: bash "$GITHUB_ACTION_PATH/repository.sh" - - name: Freeze the bake definition id: freeze shell: bash @@ -78,7 +68,4 @@ runs: PR_NUMBER: ${{ github.event.pull_request.number }} REVISION: ${{ github.sha }} SOURCE: ${{ github.server_url }}/${{ github.repository }} - REPOSITORY_NAME: ${{ steps.repository.outputs.name }} - REPOSITORY_DESCRIPTION: ${{ steps.repository.outputs.description }} - LICENSES: ${{ steps.repository.outputs.license }} run: bash "$GITHUB_ACTION_PATH/freeze.sh" diff --git a/bake/plan/repository.sh b/bake/plan/repository.sh deleted file mode 100755 index c7a2da5..0000000 --- a/bake/plan/repository.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -# Reads the repository's name, description and SPDX license from the GitHub API, the fallbacks specs_labels uses. -# -# Reads GH_TOKEN and GITHUB_REPOSITORY. Sets the outputs name, description and license. -set -euo pipefail - -# shellcheck source=lib.sh -source "$(dirname "$0")/lib.sh" - -repository=$(gh api "repos/$GITHUB_REPOSITORY") - -output name "$(jq -r '.name' <<< "$repository")" -output description "$(jq -r '.description // ""' <<< "$repository")" -# GitHub reports a license it doesn't recognise as NOASSERTION, which isn't a license. -output license "$(jq -r '.license.spdx_id // "" | select(. != "NOASSERTION")' <<< "$repository")" diff --git a/bake/specs.hcl b/bake/specs.hcl index b010036..3def37e 100644 --- a/bake/specs.hcl +++ b/bake/specs.hcl @@ -54,19 +54,6 @@ variable "CREATED" { default = "" } -# The repository's name, description and SPDX license, the fallbacks for the title, description and licenses labels. -variable "REPOSITORY_NAME" { - default = "" -} - -variable "REPOSITORY_DESCRIPTION" { - default = "" -} - -variable "LICENSES" { - default = "" -} - # The full tag list for a target: every image name crossed with the tags this run publishes. A non-empty variant is # appended as a suffix ("1.2.3-alpine"), and on a stable release the bare variant name takes the place of "latest". # @@ -89,9 +76,8 @@ function "specs_tag_names" { ) } -# The org.opencontainers.image.* labels: version, revision, source, url, created, licenses, and the given title and -# description. An empty title or description falls back to the repository's name or description. Empty values are -# left out rather than written as "". +# The org.opencontainers.image.* labels: version, revision, source, url, created, and the given title and description. +# Empty values are left out rather than written as "". # # labels = specs_labels("PHP 8.4", "") function "specs_labels" { @@ -103,9 +89,8 @@ function "specs_labels" { "org.opencontainers.image.source" = SOURCE "org.opencontainers.image.url" = SOURCE "org.opencontainers.image.created" = CREATED - "org.opencontainers.image.licenses" = LICENSES - "org.opencontainers.image.title" = title != "" ? title : REPOSITORY_NAME - "org.opencontainers.image.description" = description != "" ? description : REPOSITORY_DESCRIPTION + "org.opencontainers.image.title" = title + "org.opencontainers.image.description" = description } : key => value if value != "" } } diff --git a/bake/test/cases/branch.env b/bake/test/cases/branch.env index d94c6d9..1ae6dc7 100644 --- a/bake/test/cases/branch.env +++ b/bake/test/cases/branch.env @@ -5,6 +5,3 @@ VERSION=Feature/Some_thing REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/branch.json b/bake/test/cases/branch.json index c566ced..74f2bcc 100644 --- a/bake/test/cases/branch.json +++ b/bake/test/cases/branch.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -30,8 +26,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -48,8 +42,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -64,7 +56,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -74,7 +65,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -88,21 +78,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=Feature/Some_thing" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "Feature/Some_thing" }, diff --git a/bake/test/cases/dispatch.env b/bake/test/cases/dispatch.env index a0f0606..c474fc7 100644 --- a/bake/test/cases/dispatch.env +++ b/bake/test/cases/dispatch.env @@ -6,6 +6,3 @@ VERSION=testing REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/dispatch.json b/bake/test/cases/dispatch.json index 8d5421c..3b0a875 100644 --- a/bake/test/cases/dispatch.json +++ b/bake/test/cases/dispatch.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -30,8 +26,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -48,8 +42,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -64,7 +56,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -74,7 +65,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -88,21 +78,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=testing" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "testing" }, diff --git a/bake/test/cases/pr.env b/bake/test/cases/pr.env index de26a7a..11fd510 100644 --- a/bake/test/cases/pr.env +++ b/bake/test/cases/pr.env @@ -6,6 +6,3 @@ VERSION=pr-42 REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/pr.json b/bake/test/cases/pr.json index 26d9960..838fbc4 100644 --- a/bake/test/cases/pr.json +++ b/bake/test/cases/pr.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -30,8 +26,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -48,8 +42,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -64,7 +56,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -74,7 +65,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -88,21 +78,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=pr-42" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "pr-42" }, diff --git a/bake/test/cases/schedule.env b/bake/test/cases/schedule.env index 453893d..91a185d 100644 --- a/bake/test/cases/schedule.env +++ b/bake/test/cases/schedule.env @@ -5,6 +5,3 @@ VERSION=nightly REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/schedule.json b/bake/test/cases/schedule.json index 3a845ec..fbed941 100644 --- a/bake/test/cases/schedule.json +++ b/bake/test/cases/schedule.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -30,8 +26,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -48,8 +42,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -64,7 +56,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -74,7 +65,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -88,21 +78,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=nightly" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "nightly" }, diff --git a/bake/test/cases/tag-not-semver.env b/bake/test/cases/tag-not-semver.env index 42c13d2..541f36f 100644 --- a/bake/test/cases/tag-not-semver.env +++ b/bake/test/cases/tag-not-semver.env @@ -6,6 +6,3 @@ IS_STABLE=false REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/tag-not-semver.json b/bake/test/cases/tag-not-semver.json index be6de96..c53f2d1 100644 --- a/bake/test/cases/tag-not-semver.json +++ b/bake/test/cases/tag-not-semver.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -30,8 +26,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -48,8 +42,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -64,7 +56,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -74,7 +65,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -88,21 +78,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=version-2" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "version-2" }, diff --git a/bake/test/cases/tag-prerelease.env b/bake/test/cases/tag-prerelease.env index 29b87be..d935d22 100644 --- a/bake/test/cases/tag-prerelease.env +++ b/bake/test/cases/tag-prerelease.env @@ -6,6 +6,3 @@ IS_STABLE=false REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/tag-prerelease.json b/bake/test/cases/tag-prerelease.json index 9787d6e..736ae26 100644 --- a/bake/test/cases/tag-prerelease.json +++ b/bake/test/cases/tag-prerelease.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -30,8 +26,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -48,8 +42,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -64,7 +56,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -74,7 +65,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -88,21 +78,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=1.2.3-rc.1" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "1.2.3-rc.1" }, diff --git a/bake/test/cases/tag-stable-not-semver.env b/bake/test/cases/tag-stable-not-semver.env index abb36ec..ba86e67 100644 --- a/bake/test/cases/tag-stable-not-semver.env +++ b/bake/test/cases/tag-stable-not-semver.env @@ -6,6 +6,3 @@ IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/tag-stable-not-semver.json b/bake/test/cases/tag-stable-not-semver.json index b15f7e4..5b33ab4 100644 --- a/bake/test/cases/tag-stable-not-semver.json +++ b/bake/test/cases/tag-stable-not-semver.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -31,8 +27,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -50,8 +44,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -67,7 +59,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -77,7 +68,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -92,21 +82,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=2026.11" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "2026.11" }, diff --git a/bake/test/cases/tag-stable.env b/bake/test/cases/tag-stable.env index fc85983..c680111 100644 --- a/bake/test/cases/tag-stable.env +++ b/bake/test/cases/tag-stable.env @@ -6,6 +6,3 @@ IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/tag-stable.json b/bake/test/cases/tag-stable.json index eea40f0..9b0a24a 100644 --- a/bake/test/cases/tag-stable.json +++ b/bake/test/cases/tag-stable.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -33,8 +29,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -54,8 +48,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -73,7 +65,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -83,7 +74,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -100,21 +90,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=1.2.3" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "1.2.3" }, diff --git a/bake/test/cases/tag-v0.0.env b/bake/test/cases/tag-v0.0.env index 57c0747..b3165e9 100644 --- a/bake/test/cases/tag-v0.0.env +++ b/bake/test/cases/tag-v0.0.env @@ -6,6 +6,3 @@ IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/tag-v0.0.json b/bake/test/cases/tag-v0.0.json index 4a902c0..e0e67aa 100644 --- a/bake/test/cases/tag-v0.0.json +++ b/bake/test/cases/tag-v0.0.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -31,8 +27,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -50,8 +44,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -67,7 +59,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -77,7 +68,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -92,21 +82,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=0.0.5" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "0.0.5" }, diff --git a/bake/test/cases/tag-v0.env b/bake/test/cases/tag-v0.env index bc8b345..4fa01cf 100644 --- a/bake/test/cases/tag-v0.env +++ b/bake/test/cases/tag-v0.env @@ -6,6 +6,3 @@ IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/tag-v0.json b/bake/test/cases/tag-v0.json index 15369ac..1ab9ce3 100644 --- a/bake/test/cases/tag-v0.json +++ b/bake/test/cases/tag-v0.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -12,8 +10,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -32,8 +28,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -52,8 +46,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -70,7 +62,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -80,7 +71,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -96,21 +86,15 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example", "manifest:org.opencontainers.image.version=0.1.0" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example", "org.opencontainers.image.version": "0.1.0" }, diff --git a/bake/test/cases/unknown-event.env b/bake/test/cases/unknown-event.env index 9a789cb..b1abf29 100644 --- a/bake/test/cases/unknown-event.env +++ b/bake/test/cases/unknown-event.env @@ -5,6 +5,3 @@ VERSION= REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z -REPOSITORY_NAME=example -REPOSITORY_DESCRIPTION=An example repository -LICENSES=MIT diff --git a/bake/test/cases/unknown-event.json b/bake/test/cases/unknown-event.json index 408ab85..d2dd493 100644 --- a/bake/test/cases/unknown-event.json +++ b/bake/test/cases/unknown-event.json @@ -2,8 +2,6 @@ "builder": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4 builder", @@ -11,8 +9,6 @@ ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4 builder", @@ -25,8 +21,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -39,8 +33,6 @@ }, "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "specs-cli", @@ -51,7 +43,6 @@ "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", "manifest:org.opencontainers.image.description=PHP 8.4 runtime", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", "manifest:org.opencontainers.image.title=PHP 8.4", @@ -60,7 +51,6 @@ "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", "org.opencontainers.image.description": "PHP 8.4 runtime", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", "org.opencontainers.image.title": "PHP 8.4", @@ -70,20 +60,14 @@ "utils": { "annotations": [ "manifest:org.opencontainers.image.created=2026-11-09T12:00:00Z", - "manifest:org.opencontainers.image.description=An example repository", - "manifest:org.opencontainers.image.licenses=MIT", "manifest:org.opencontainers.image.revision=0123456789abcdef0123456789abcdef01234567", "manifest:org.opencontainers.image.source=https://github.com/specsnl/example", - "manifest:org.opencontainers.image.title=example", "manifest:org.opencontainers.image.url=https://github.com/specsnl/example" ], "labels": { "org.opencontainers.image.created": "2026-11-09T12:00:00Z", - "org.opencontainers.image.description": "An example repository", - "org.opencontainers.image.licenses": "MIT", "org.opencontainers.image.revision": "0123456789abcdef0123456789abcdef01234567", "org.opencontainers.image.source": "https://github.com/specsnl/example", - "org.opencontainers.image.title": "example", "org.opencontainers.image.url": "https://github.com/specsnl/example" } } diff --git a/bake/test/run.sh b/bake/test/run.sh index f43d955..7a03ce6 100755 --- a/bake/test/run.sh +++ b/bake/test/run.sh @@ -5,7 +5,7 @@ set -euo pipefail cd "$(dirname "$0")" -variables=(VERSION EVENT REF_TYPE REF_NAME PR_NUMBER DISPATCH_TAG IS_STABLE REVISION SOURCE CREATED REPOSITORY_NAME REPOSITORY_DESCRIPTION LICENSES) +variables=(VERSION EVENT REF_TYPE REF_NAME PR_NUMBER DISPATCH_TAG IS_STABLE REVISION SOURCE CREATED) update=false [ "${1:-}" = "--update" ] && update=true From 1dfb973184258936f02814c963e54038cf7ded60 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Fri, 20 Nov 2026 22:02:10 +0100 Subject: [PATCH 11/13] Work out whether a release is stable in specs.hcl specs.hcl derives it from EVENT, REF_TYPE and VERSION, so the tag rules live in one place and a local build no longer needs IS_STABLE set to preview a release. --- bake/plan/action.yml | 1 - bake/plan/vars.sh | 10 ++----- bake/specs.hcl | 15 +++++----- bake/test/cases/tag-not-semver.env | 1 - bake/test/cases/tag-prerelease.env | 1 - bake/test/cases/tag-stable-not-semver.env | 1 - bake/test/cases/tag-stable.env | 1 - bake/test/cases/tag-v0.0.env | 1 - bake/test/cases/tag-v0.env | 1 - bake/test/run.sh | 2 +- bake/test/vars.sh | 34 +++++++++++------------ 11 files changed, 28 insertions(+), 40 deletions(-) diff --git a/bake/plan/action.yml b/bake/plan/action.yml index 4f5a3e5..5b1ce79 100644 --- a/bake/plan/action.yml +++ b/bake/plan/action.yml @@ -60,7 +60,6 @@ runs: PUSH: ${{ steps.vars.outputs.push }} VERSION: ${{ steps.vars.outputs.version }} DISPATCH_TAG: ${{ steps.vars.outputs.dispatch-tag }} - IS_STABLE: ${{ steps.vars.outputs.is-stable }} CREATED: ${{ steps.vars.outputs.created }} EVENT: ${{ github.event_name }} REF_TYPE: ${{ github.ref_type }} diff --git a/bake/plan/vars.sh b/bake/plan/vars.sh index 6c08091..da64151 100755 --- a/bake/plan/vars.sh +++ b/bake/plan/vars.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -# Works out the run's version, dispatch tag, stability and whether to push, from the event and the inputs. +# Works out the run's version, dispatch tag and whether to push, from the event and the inputs. # # Reads INPUT_VERSION, INPUT_DISPATCH_TAG, INPUT_PUSH, PR_NUMBER, PR_AUTHOR, PR_HEAD_REPOSITORY and the GITHUB_* -# variables of the event. Sets the outputs version, dispatch-tag, is-stable, push and created. +# variables of the event. Sets the outputs version, dispatch-tag, push and created. set -euo pipefail # shellcheck source=lib.sh @@ -27,11 +27,6 @@ if [ -z "$version" ]; then esac fi -is_stable=false -if [ "${GITHUB_EVENT_NAME:-}" = push ] && [ "${GITHUB_REF_TYPE:-}" = tag ] && [[ $version != *-* ]]; then - is_stable=true -fi - push="${INPUT_PUSH:-}" if [ -z "$push" ]; then push=true @@ -57,6 +52,5 @@ fi output version "$version" output dispatch-tag "$dispatch_tag" -output is-stable "$is_stable" output push "$push" output created "$(date -u +%Y-%m-%dT%H:%M:%SZ)" diff --git a/bake/specs.hcl b/bake/specs.hcl index 3def37e..c1d47f4 100644 --- a/bake/specs.hcl +++ b/bake/specs.hcl @@ -37,11 +37,6 @@ variable "DISPATCH_TAG" { default = "latest" } -# "true" on a tag push whose version has no "-" in it. Only then do the moving tags (1.2, 1, latest) move. -variable "IS_STABLE" { - default = "false" -} - variable "REVISION" { default = "" } @@ -72,7 +67,7 @@ function "specs_tag_names" { params = [variant] result = concat( [for tag in _specs_base_tags() : _specs_sanitize(variant == "" ? tag : "${tag}-${variant}")], - EVENT == "push" && REF_TYPE == "tag" && IS_STABLE == "true" ? [variant == "" ? "latest" : variant] : [], + _specs_is_stable() ? [variant == "" ? "latest" : variant] : [], ) } @@ -117,12 +112,18 @@ function "_specs_base_tags" { ) } +# A tag push whose version has no "-" in it. Only then do the moving tags (1.2, 1, latest) move. +function "_specs_is_stable" { + params = [] + result = EVENT == "push" && REF_TYPE == "tag" && length(regexall("-", VERSION)) == 0 +} + # 1.2.3, plus 1.2 unless it is 0.0.x and 1 unless it is 0.x. A prerelease, or a version that isn't semver, publishes # only itself. function "_specs_release_tags" { params = [] result = ( - IS_STABLE == "true" && length(_specs_semver()) == 1 ? _specs_semver_tags(_specs_semver()[0]) : [VERSION] + _specs_is_stable() && length(_specs_semver()) == 1 ? _specs_semver_tags(_specs_semver()[0]) : [VERSION] ) } diff --git a/bake/test/cases/tag-not-semver.env b/bake/test/cases/tag-not-semver.env index 541f36f..07f2fe9 100644 --- a/bake/test/cases/tag-not-semver.env +++ b/bake/test/cases/tag-not-semver.env @@ -2,7 +2,6 @@ EVENT=push REF_TYPE=tag REF_NAME=version-2 VERSION=version-2 -IS_STABLE=false REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z diff --git a/bake/test/cases/tag-prerelease.env b/bake/test/cases/tag-prerelease.env index d935d22..d6ec8bc 100644 --- a/bake/test/cases/tag-prerelease.env +++ b/bake/test/cases/tag-prerelease.env @@ -2,7 +2,6 @@ EVENT=push REF_TYPE=tag REF_NAME=v1.2.3-rc.1 VERSION=1.2.3-rc.1 -IS_STABLE=false REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z diff --git a/bake/test/cases/tag-stable-not-semver.env b/bake/test/cases/tag-stable-not-semver.env index ba86e67..fe9cac0 100644 --- a/bake/test/cases/tag-stable-not-semver.env +++ b/bake/test/cases/tag-stable-not-semver.env @@ -2,7 +2,6 @@ EVENT=push REF_TYPE=tag REF_NAME=2026.11 VERSION=2026.11 -IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z diff --git a/bake/test/cases/tag-stable.env b/bake/test/cases/tag-stable.env index c680111..9d10307 100644 --- a/bake/test/cases/tag-stable.env +++ b/bake/test/cases/tag-stable.env @@ -2,7 +2,6 @@ EVENT=push REF_TYPE=tag REF_NAME=v1.2.3 VERSION=1.2.3 -IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z diff --git a/bake/test/cases/tag-v0.0.env b/bake/test/cases/tag-v0.0.env index b3165e9..1575078 100644 --- a/bake/test/cases/tag-v0.0.env +++ b/bake/test/cases/tag-v0.0.env @@ -2,7 +2,6 @@ EVENT=push REF_TYPE=tag REF_NAME=v0.0.5 VERSION=0.0.5 -IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z diff --git a/bake/test/cases/tag-v0.env b/bake/test/cases/tag-v0.env index 4fa01cf..ef9c72b 100644 --- a/bake/test/cases/tag-v0.env +++ b/bake/test/cases/tag-v0.env @@ -2,7 +2,6 @@ EVENT=push REF_TYPE=tag REF_NAME=v0.1.0 VERSION=0.1.0 -IS_STABLE=true REVISION=0123456789abcdef0123456789abcdef01234567 SOURCE=https://github.com/specsnl/example CREATED=2026-11-09T12:00:00Z diff --git a/bake/test/run.sh b/bake/test/run.sh index 7a03ce6..8f9bd5e 100755 --- a/bake/test/run.sh +++ b/bake/test/run.sh @@ -5,7 +5,7 @@ set -euo pipefail cd "$(dirname "$0")" -variables=(VERSION EVENT REF_TYPE REF_NAME PR_NUMBER DISPATCH_TAG IS_STABLE REVISION SOURCE CREATED) +variables=(VERSION EVENT REF_TYPE REF_NAME PR_NUMBER DISPATCH_TAG REVISION SOURCE CREATED) update=false [ "${1:-}" = "--update" ] && update=true diff --git a/bake/test/vars.sh b/bake/test/vars.sh index 7316915..7e3536c 100755 --- a/bake/test/vars.sh +++ b/bake/test/vars.sh @@ -36,62 +36,62 @@ check() { } check 'stable tag' \ - 'version=1.2.3 dispatch-tag=latest is-stable=true push=true' \ + 'version=1.2.3 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=tag GITHUB_REF_NAME=v1.2.3 check 'prerelease tag' \ - 'version=1.2.3-rc.1 dispatch-tag=latest is-stable=false push=true' \ + 'version=1.2.3-rc.1 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=tag GITHUB_REF_NAME=v1.2.3-rc.1 check 'tag without v' \ - 'version=2.0.0 dispatch-tag=latest is-stable=true push=true' \ + 'version=2.0.0 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=tag GITHUB_REF_NAME=2.0.0 check 'tag starting with v and a letter' \ - 'version=version-2 dispatch-tag=latest is-stable=false push=true' \ + 'version=version-2 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=tag GITHUB_REF_NAME=version-2 check 'branch push' \ - 'version=main dispatch-tag=latest is-stable=false push=true' \ + 'version=main dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main check 'branch named like a version' \ - 'version=v1.2.3 dispatch-tag=latest is-stable=false push=true' \ + 'version=v1.2.3 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=branch GITHUB_REF_NAME=v1.2.3 check 'push to a dependabot branch' \ - 'version=dependabot/docker/foo dispatch-tag=latest is-stable=false push=false' \ + 'version=dependabot/docker/foo dispatch-tag=latest push=false' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=branch GITHUB_REF_NAME=dependabot/docker/foo check 'pull request' \ - 'version=pr-42 dispatch-tag=latest is-stable=false push=true' \ + 'version=pr-42 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=pull_request GITHUB_REF_TYPE=branch GITHUB_REF_NAME=42/merge \ PR_NUMBER=42 PR_AUTHOR=someone PR_HEAD_REPOSITORY=specsnl/example check 'pull request from dependabot, also when a person re-runs it' \ - 'version=pr-42 dispatch-tag=latest is-stable=false push=false' \ + 'version=pr-42 dispatch-tag=latest push=false' \ GITHUB_EVENT_NAME=pull_request GITHUB_REF_TYPE=branch GITHUB_REF_NAME=42/merge GITHUB_ACTOR=someone \ PR_NUMBER=42 'PR_AUTHOR=dependabot[bot]' PR_HEAD_REPOSITORY=specsnl/example check 'pull request from a fork' \ - 'version=pr-42 dispatch-tag=latest is-stable=false push=false' \ + 'version=pr-42 dispatch-tag=latest push=false' \ GITHUB_EVENT_NAME=pull_request GITHUB_REF_TYPE=branch GITHUB_REF_NAME=42/merge \ PR_NUMBER=42 PR_AUTHOR=someone PR_HEAD_REPOSITORY=someone/example check 'schedule' \ - 'version=nightly dispatch-tag=latest is-stable=false push=true' \ + 'version=nightly dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=schedule GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main check 'workflow_dispatch' \ - 'version=testing dispatch-tag=testing is-stable=false push=true' \ + 'version=testing dispatch-tag=testing push=true' \ GITHUB_EVENT_NAME=workflow_dispatch GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main INPUT_DISPATCH_TAG=Testing check 'workflow_dispatch without a dispatch tag' \ - 'version=latest dispatch-tag=latest is-stable=false push=true' \ + 'version=latest dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=workflow_dispatch GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main check 'explicit version' \ - 'version=9.9.9 dispatch-tag=latest is-stable=false push=true' \ + 'version=9.9.9 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main INPUT_VERSION=9.9.9 check 'explicit push on a dependabot pull request' \ - 'version=pr-42 dispatch-tag=latest is-stable=false push=true' \ + 'version=pr-42 dispatch-tag=latest push=true' \ GITHUB_EVENT_NAME=pull_request GITHUB_REF_TYPE=branch GITHUB_REF_NAME=42/merge \ PR_NUMBER=42 'PR_AUTHOR=dependabot[bot]' PR_HEAD_REPOSITORY=specsnl/example INPUT_PUSH=true check 'explicit push=false' \ - 'version=main dispatch-tag=latest is-stable=false push=false' \ + 'version=main dispatch-tag=latest push=false' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main INPUT_PUSH=false check 'invalid push' \ 'exit=1' \ GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main INPUT_PUSH=yes check 'event the tag rules do not cover' \ - 'version= dispatch-tag=latest is-stable=false push=false' \ + 'version= dispatch-tag=latest push=false' \ GITHUB_EVENT_NAME=merge_group GITHUB_REF_TYPE=branch GITHUB_REF_NAME=gh-readonly-queue/main/pr-1 exit "$failed" From 77d9bdf7546893c159af1128b56ff6cdbbebacb0 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Sat, 21 Nov 2026 00:31:09 +0100 Subject: [PATCH 12/13] Delete the e2e images of closed pull requests every night cleanup-e2e.yml removes the pr-<N> images test-bake.yml published once the pull request is closed, and the untagged platform images nothing refers to any more. --- .github/workflows/cleanup-e2e.yml | 40 ++++++++++++++++++++++ bake/test/cleanup-e2e.sh | 57 +++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .github/workflows/cleanup-e2e.yml create mode 100755 bake/test/cleanup-e2e.sh diff --git a/.github/workflows/cleanup-e2e.yml b/.github/workflows/cleanup-e2e.yml new file mode 100644 index 0000000..4c6bd04 --- /dev/null +++ b/.github/workflows/cleanup-e2e.yml @@ -0,0 +1,40 @@ +name: Clean up the e2e images + +on: + schedule: + - cron: '23 4 * * *' + workflow_dispatch: + inputs: + dry-run: + description: Only list what would be deleted + type: boolean + default: false + +permissions: {} + +concurrency: + group: ${{ github.workflow }} + +jobs: + + cleanup: + name: Clean up + runs-on: ubuntu-26.04 + timeout-minutes: 15 + permissions: + contents: read + packages: write + pull-requests: read + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Delete the images of closed pull requests + env: + GH_TOKEN: ${{ github.token }} + PACKAGES: github-actions/e2e github-actions/e2e-cli + DRY_RUN: ${{ inputs.dry-run || false }} + run: bake/test/cleanup-e2e.sh diff --git a/bake/test/cleanup-e2e.sh b/bake/test/cleanup-e2e.sh new file mode 100755 index 0000000..31ad572 --- /dev/null +++ b/bake/test/cleanup-e2e.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# Deletes the e2e test images of closed pull requests from GHCR. Per package, it deletes every version whose tags all +# belong to closed pull requests (pr-<N> or pr-<N>-<variant>), then every untagged version that no tagged image refers +# to any more: the platform images of those, and of indexes a later push replaced. Untagged versions younger than a day +# are kept, so a run whose platform images aren't in an index yet keeps them. +# +# Reads GH_TOKEN, GITHUB_REPOSITORY, PACKAGES (space-separated, i.e. "github-actions/e2e") and DRY_RUN ("true" only +# lists what it would delete). +set -euo pipefail + +owner="${GITHUB_REPOSITORY%%/*}" +cutoff=$(jq -nr 'now - 86400 | todate') +declare -A closed=() + +# is_closed <number>: whether the pull request is closed, merged included. +is_closed() { + [ -n "${closed[$1]:-}" ] || closed[$1]=$(gh api "repos/$GITHUB_REPOSITORY/pulls/$1" --jq '.state == "closed"') + [ "${closed[$1]}" = true ] +} + +# delete <package api> <id> <description> +delete() { + echo "delete $3" + [ "${DRY_RUN:-false}" = true ] || gh api --method DELETE "$1/$2" --silent +} + +# versions <package api>: [{id, name, updated_at, tags}] +versions() { + gh api --paginate "$1" --jq '.[] | {id, name, updated_at, tags: .metadata.container.tags}' | jq -s . +} + +for package in $PACKAGES; do + api="orgs/$owner/packages/container/${package//\//%2F}/versions" + image="ghcr.io/$owner/$package" + + while IFS=$'\t' read -r id tags; do + stale=true + for tag in $tags; do + [[ $tag =~ ^pr-([0-9]+)(-.+)?$ ]] && is_closed "${BASH_REMATCH[1]}" || stale=false + done + if $stale; then delete "$api" "$id" "$image:${tags// /, }"; fi + done < <(versions "$api" | jq -r '.[] | select(.tags != []) | [.id, (.tags | join(" "))] | @tsv') + + # In a dry run the tagged versions above are still there, so their platform images count as referenced. + versions=$(versions "$api") + referenced=$( + for digest in $(jq -r '.[] | select(.tags != []) | .name' <<< "$versions"); do + docker buildx imagetools inspect --raw "$image@$digest" | jq -r '.manifests[]?.digest' + done + ) + while IFS=$'\t' read -r id digest; do + delete "$api" "$id" "$image@$digest" + done < <(jq -r --arg cutoff "$cutoff" --arg referenced "$referenced" ' + ($referenced | split("\n")) as $referenced + | .[] | select(.tags == [] and .updated_at < $cutoff and (.name | IN($referenced[]) | not)) | [.id, .name] | @tsv + ' <<< "$versions") +done From db34a0a6aa238b7a0eb8874016a646e335aa9cb7 Mon Sep 17 00:00:00 2001 From: Ilyes512 <ilyes.ahidar@gmail.com> Date: Sat, 21 Nov 2026 00:43:09 +0100 Subject: [PATCH 13/13] Retry the inspect after publishing while GHCR catches up imagetools inspect right after imagetools create can get a 404 from GHCR, which failed a publish that had succeeded. --- bake/publish/publish.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bake/publish/publish.sh b/bake/publish/publish.sh index 0d2e910..0de2b59 100755 --- a/bake/publish/publish.sh +++ b/bake/publish/publish.sh @@ -31,6 +31,10 @@ for target in $(jq -r '.target | keys[]' "$bake"); do echo "::group::$target" docker buildx imagetools create "${args[@]}" "${sources[@]}" - docker buildx imagetools inspect "${tags[0]}" + # GHCR can answer "not found" for a moment after it accepted a tag; the inspect is only there for the log. + for attempt in 1 2 3 4; do + docker buildx imagetools inspect "${tags[0]}" && break + sleep "$attempt" + done echo "::endgroup::" done