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' diff --git a/.github/workflows/bake.yml b/.github/workflows/bake.yml new file mode 100644 index 0000000..79363b6 --- /dev/null +++ b/.github/workflows/bake.yml @@ -0,0 +1,230 @@ +name: Bake + +on: + workflow_call: + inputs: + files: + description: >- + 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: docker-bake.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-26.04", "linux/arm64": "ubuntu-26.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-26.04 + timeout-minutes: 10 + permissions: + contents: read + outputs: + version: ${{ steps.plan.outputs.version }} + push: ${{ steps.plan.outputs.push }} + matrix: ${{ steps.plan.outputs.matrix }} + steps: + + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - 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: bake-definition + path: ${{ runner.temp }}/bake/*.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: bake-definition + path: ${{ runner.temp }}/bake + + - name: Export the 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' }} + 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: ${{ runner.temp }}/bake/definition-${{ matrix.slug }}.json + + - name: Save the build metadata + if: ${{ needs.plan.outputs.push == 'true' }} + 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 build metadata + if: ${{ needs.plan.outputs.push == 'true' }} + uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 + with: + name: bake-metadata-${{ matrix.slug }} + path: ${{ runner.temp }}/metadata/${{ 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-26.04 + timeout-minutes: 15 + permissions: + packages: write + steps: + + - name: Download the bake definition + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + name: bake-definition + path: ${{ runner.temp }}/bake + + - name: Download the build metadata + uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2 + with: + pattern: bake-metadata-* + path: ${{ runner.temp }}/metadata + 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 + uses: $/bake/publish + + status: + name: Image + needs: [plan, build, publish] + if: ${{ always() }} + runs-on: ubuntu-26.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/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/.github/workflows/lint.yml b/.github/workflows/lint.yml index a4989e2..74588fc 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -35,3 +35,9 @@ jobs: persist-credentials: false - name: Run the specs.hcl fixture tests run: bake/test/run.sh + - name: Run the plan tests + run: bake/test/vars.sh + - name: Run shellcheck + run: >- + docker run --rm --volume "$PWD:/mnt" --workdir /mnt koalaman/shellcheck:v0.11.0 + bake/*/*.sh bake/test/*.sh diff --git a/.github/workflows/test-bake.yml b/.github/workflows/test-bake.yml new file mode 100644 index 0000000..156217a --- /dev/null +++ b/.github/workflows/test-bake.yml @@ -0,0 +1,108 @@ +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 + # 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 : 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 + 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/.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 fe7103b..752cc1b 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -4,19 +4,28 @@ 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/*/*.sh bake/test/*.sh test: - desc: Run the bake/specs.hcl fixture tests - cmd: bake/test/run.sh + desc: Run the bake/specs.hcl fixture tests and the plan tests + cmds: + - bake/test/run.sh + - bake/test/vars.sh test:update: - desc: Rewrite the expected output of the bake/specs.hcl fixture tests + desc: Rewrite the expected output of the specs.hcl fixture tests cmd: bake/test/run.sh --update diff --git a/bake/plan/action.yml b/bake/plan/action.yml new file mode 100644 index 0000000..5b1ce79 --- /dev/null +++ b/bake/plan/action.yml @@ -0,0 +1,70 @@ +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 build matrix and the frozen definitions 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 + +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 }} + +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: 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 }} + 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: bash "$GITHUB_ACTION_PATH/freeze.sh" diff --git a/bake/plan/definition.jq b/bake/plan/definition.jq new file mode 100644 index 0000000..4b471ca --- /dev/null +++ b/bake/plan/definition.jq @@ -0,0 +1,22 @@ +# 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( + 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)"] + ) +) +| .group = {default: {targets: (.target | keys)}} diff --git a/bake/plan/freeze.sh b/bake/plan/freeze.sh new file mode 100755 index 0000000..be0ea4d --- /dev/null +++ b/bake/plan/freeze.sh @@ -0,0 +1,52 @@ +#!/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: +# +# 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 output matrix 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/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 + +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 "$matrix" + +{ + echo '### Bake definition' + echo + echo "Version \`${VERSION:-}\`, push \`$PUSH\`." + echo + echo '| Target | Platforms | Tags |' + echo '|--------|-----------|------|' + jq -r ' + .target | to_entries[] + | "| `\(.key)` | \(.value.platforms | join(", ")) | \(.value.tags // [] | map("`\(.)`") | join("<br>")) |" + ' "$dir/bake.json" +} >> "$GITHUB_STEP_SUMMARY" 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/matrix.jq b/bake/plan/matrix.jq new file mode 100644 index 0000000..0364ac7 --- /dev/null +++ b/bake/plan/matrix.jq @@ -0,0 +1,16 @@ +# 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 | 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]+"; "-"), + runner: ($runners[.] // error("no runner for platform \(.); add it to the runners input")) + }) diff --git a/bake/plan/vars.sh b/bake/plan/vars.sh new file mode 100755 index 0000000..da64151 --- /dev/null +++ b/bake/plan/vars.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# 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, 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 + +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 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..3546e2e --- /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 build metadata in $RUNNER_TEMP/metadata. + +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..0de2b59 --- /dev/null +++ b/bake/publish/publish.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# 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 + +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(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 '.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" ' + .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" '.target[$t].platforms | length' "$bake") + 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[@]}" + # 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 diff --git a/bake/specs.hcl b/bake/specs.hcl index 963a913..c1d47f4 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@<sha>` 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/<sha>/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. @@ -35,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 = "" } @@ -52,19 +49,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". # @@ -83,13 +67,12 @@ 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] : [], ) } -# 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" { @@ -101,9 +84,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 != "" } } @@ -130,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/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..07f2fe9 100644 --- a/bake/test/cases/tag-not-semver.env +++ b/bake/test/cases/tag-not-semver.env @@ -2,10 +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 -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..d6ec8bc 100644 --- a/bake/test/cases/tag-prerelease.env +++ b/bake/test/cases/tag-prerelease.env @@ -2,10 +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 -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..fe9cac0 100644 --- a/bake/test/cases/tag-stable-not-semver.env +++ b/bake/test/cases/tag-stable-not-semver.env @@ -2,10 +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 -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..9d10307 100644 --- a/bake/test/cases/tag-stable.env +++ b/bake/test/cases/tag-stable.env @@ -2,10 +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 -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..1575078 100644 --- a/bake/test/cases/tag-v0.0.env +++ b/bake/test/cases/tag-v0.0.env @@ -2,10 +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 -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..ef9c72b 100644 --- a/bake/test/cases/tag-v0.env +++ b/bake/test/cases/tag-v0.env @@ -2,10 +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 -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/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 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/run.sh b/bake/test/run.sh index f43d955..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 REPOSITORY_NAME REPOSITORY_DESCRIPTION LICENSES) +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 new file mode 100755 index 0000000..7e3536c --- /dev/null +++ b/bake/test/vars.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +# Runs bake/plan/vars.sh for a set of GitHub contexts and checks its outputs. +set -euo pipefail + +cd "$(dirname "$0")/../.." + +failed=0 + +# check <description> <expected outputs> <environment...> +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 "$@" 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 } + ' "$output" | sed 's/ $//') + fi + rm -f "$output" + + if [ "$actual" = "$expected" ]; then + echo "ok $description" + else + echo "FAILED $description" + echo " expected: $expected" + echo " actual: $actual" + failed=1 + fi +} + +check 'stable tag' \ + '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 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 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 push=true' \ + GITHUB_EVENT_NAME=push GITHUB_REF_TYPE=tag GITHUB_REF_NAME=version-2 +check 'branch push' \ + '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 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 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 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 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 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 push=true' \ + GITHUB_EVENT_NAME=schedule GITHUB_REF_TYPE=branch GITHUB_REF_NAME=main +check 'workflow_dispatch' \ + '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 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 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 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 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 push=false' \ + GITHUB_EVENT_NAME=merge_group GITHUB_REF_TYPE=branch GITHUB_REF_NAME=gh-readonly-queue/main/pr-1 + +exit "$failed"