From dd476fbb3178364527cfedb1c907a4966307dcd1 Mon Sep 17 00:00:00 2001 From: Ilyes512 Date: Tue, 10 Nov 2026 17:30:38 +0100 Subject: [PATCH] Add bake/specs.hcl with the shared tag, label and annotation rules The functions specs_tags, specs_labels and specs_annotations work out an image's metadata from the variables bake.yml's plan job will set, so a consumer's docker-bake.hcl describes what to build and this file decides how it is tagged. Local builds get the defaults: a :local tag and version dev. bake/test/run.sh runs docker buildx bake --print on an example HCL file for a set of events and compares the result with the expected JSON; lint.yml runs it on every push. --- .editorconfig | 3 + .github/actionlint.yaml | 5 + .github/workflows/lint.yml | 11 ++ Taskfile.dist.yml | 8 ++ bake/specs.hcl | 160 +++++++++++++++++++++ bake/test/cases/branch.env | 10 ++ bake/test/cases/branch.json | 113 +++++++++++++++ bake/test/cases/dispatch.env | 11 ++ bake/test/cases/dispatch.json | 113 +++++++++++++++ bake/test/cases/local.env | 0 bake/test/cases/local.json | 65 +++++++++ bake/test/cases/pr.env | 11 ++ bake/test/cases/pr.json | 113 +++++++++++++++ bake/test/cases/schedule.env | 10 ++ bake/test/cases/schedule.json | 113 +++++++++++++++ bake/test/cases/tag-not-semver.env | 11 ++ bake/test/cases/tag-not-semver.json | 113 +++++++++++++++ bake/test/cases/tag-prerelease.env | 11 ++ bake/test/cases/tag-prerelease.json | 113 +++++++++++++++ bake/test/cases/tag-stable-not-semver.env | 11 ++ bake/test/cases/tag-stable-not-semver.json | 118 +++++++++++++++ bake/test/cases/tag-stable.env | 11 ++ bake/test/cases/tag-stable.json | 128 +++++++++++++++++ bake/test/cases/tag-v0.0.env | 11 ++ bake/test/cases/tag-v0.0.json | 118 +++++++++++++++ bake/test/cases/tag-v0.env | 11 ++ bake/test/cases/tag-v0.json | 123 ++++++++++++++++ bake/test/cases/unknown-event.env | 10 ++ bake/test/cases/unknown-event.json | 90 ++++++++++++ bake/test/docker-bake.hcl | 41 ++++++ bake/test/run.sh | 38 +++++ 31 files changed, 1704 insertions(+) create mode 100644 .github/actionlint.yaml create mode 100644 bake/specs.hcl create mode 100644 bake/test/cases/branch.env create mode 100644 bake/test/cases/branch.json create mode 100644 bake/test/cases/dispatch.env create mode 100644 bake/test/cases/dispatch.json create mode 100644 bake/test/cases/local.env create mode 100644 bake/test/cases/local.json create mode 100644 bake/test/cases/pr.env create mode 100644 bake/test/cases/pr.json create mode 100644 bake/test/cases/schedule.env create mode 100644 bake/test/cases/schedule.json create mode 100644 bake/test/cases/tag-not-semver.env create mode 100644 bake/test/cases/tag-not-semver.json create mode 100644 bake/test/cases/tag-prerelease.env create mode 100644 bake/test/cases/tag-prerelease.json create mode 100644 bake/test/cases/tag-stable-not-semver.env create mode 100644 bake/test/cases/tag-stable-not-semver.json create mode 100644 bake/test/cases/tag-stable.env create mode 100644 bake/test/cases/tag-stable.json create mode 100644 bake/test/cases/tag-v0.0.env create mode 100644 bake/test/cases/tag-v0.0.json create mode 100644 bake/test/cases/tag-v0.env create mode 100644 bake/test/cases/tag-v0.json create mode 100644 bake/test/cases/unknown-event.env create mode 100644 bake/test/cases/unknown-event.json create mode 100644 bake/test/docker-bake.hcl create mode 100755 bake/test/run.sh diff --git a/.editorconfig b/.editorconfig index a82c83c..e6a802f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,3 +13,6 @@ trim_trailing_whitespace = false [{*,*.dist}.{yml,yaml}] indent_size = 2 + +[*.{hcl,sh}] +indent_size = 2 diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 0000000..a621881 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,5 @@ +# actionlint 1.7.12 predates these GitHub-hosted runner labels. +self-hosted-runner: + labels: + - ubuntu-26.04 + - ubuntu-26.04-arm diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f125c7a..a4989e2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -24,3 +24,14 @@ jobs: uses: docker://rhysd/actionlint:latest with: args: -color + + bake-tests: + name: Bake tests + runs-on: ubuntu-26.04 + steps: + - name: Checkout + uses: actions/checkout@v7 + with: + persist-credentials: false + - name: Run the specs.hcl fixture tests + run: bake/test/run.sh diff --git a/Taskfile.dist.yml b/Taskfile.dist.yml index 4855407..fe7103b 100644 --- a/Taskfile.dist.yml +++ b/Taskfile.dist.yml @@ -12,3 +12,11 @@ tasks: --volume "{{.ROOT_DIR}}:/workdir" --workdir /workdir rhysd/actionlint:{{.ACTIONLINT_TAG_VERSION}} + + test: + desc: Run the bake/specs.hcl fixture tests + cmd: bake/test/run.sh + + test:update: + desc: Rewrite the expected output of the bake/specs.hcl fixture tests + cmd: bake/test/run.sh --update diff --git a/bake/specs.hcl b/bake/specs.hcl new file mode 100644 index 0000000..963a913 --- /dev/null +++ b/bake/specs.hcl @@ -0,0 +1,160 @@ +# 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: +# +# 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. + +variable "VERSION" { + default = "dev" +} + +# The GitHub event name, i.e. "push", "pull_request", "schedule" or "workflow_dispatch". Empty for a local build. +variable "EVENT" { + default = "" +} + +# "tag" or "branch". +variable "REF_TYPE" { + default = "" +} + +# The branch or tag name. +variable "REF_NAME" { + default = "" +} + +variable "PR_NUMBER" { + default = "" +} + +# The tag a workflow_dispatch run publishes under, already lowercased. +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 = "" +} + +variable "SOURCE" { + default = "" +} + +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". +# +# tags = specs_tags(["ghcr.io/specsnl/specs-cli"], "alpine") +function "specs_tags" { + params = [images, variant] + result = flatten([ + for image in images : [ + for tag in specs_tag_names(variant) : "${lower(image)}:${tag}" + ] + ]) +} + +# The tags without the image name, see specs_tags. +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] : [], + ) +} + +# 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 "". +# +# labels = specs_labels("PHP 8.4", "") +function "specs_labels" { + params = [title, description] + result = { + for key, value in { + "org.opencontainers.image.version" = VERSION + "org.opencontainers.image.revision" = REVISION + "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 + } : key => value if value != "" + } +} + +# The same values as specs_labels, as annotations on the platform image manifest. The publish job copies them onto the +# index and its descriptors. +# +# annotations = specs_annotations("PHP 8.4", "") +function "specs_annotations" { + params = [title, description] + result = [for key, value in specs_labels(title, description) : "manifest:${key}=${value}"] +} + +function "_specs_base_tags" { + params = [] + result = ( + EVENT == "" ? ["local"] : + EVENT == "push" && REF_TYPE == "tag" ? _specs_release_tags() : + EVENT == "push" && REF_TYPE == "branch" ? [REF_NAME] : + EVENT == "pull_request" || EVENT == "pull_request_target" ? ["pr-${PR_NUMBER}"] : + EVENT == "schedule" ? ["nightly"] : + EVENT == "workflow_dispatch" ? [DISPATCH_TAG] : + [] + ) +} + +# 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] + ) +} + +function "_specs_semver_tags" { + params = [v] + result = concat( + ["${v[0]}.${v[1]}.${v[2]}"], + v[0] == "0" && v[1] == "0" ? [] : ["${v[0]}.${v[1]}"], + v[0] == "0" ? [] : [v[0]], + ) +} + +function "_specs_semver" { + params = [] + result = regexall("^(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)\\.(0|[1-9][0-9]*)$", VERSION) +} + +# A tag may only contain [A-Za-z0-9_.-], may not start with "." or "-", and is at most 128 characters. +function "_specs_sanitize" { + params = [tag] + result = substr(regex_replace(regex_replace(tag, "[^A-Za-z0-9_.-]", "-"), "^[.-]+", ""), 0, 128) +} diff --git a/bake/test/cases/branch.env b/bake/test/cases/branch.env new file mode 100644 index 0000000..d94c6d9 --- /dev/null +++ b/bake/test/cases/branch.env @@ -0,0 +1,10 @@ +EVENT=push +REF_TYPE=branch +REF_NAME=Feature/Some_thing +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 new file mode 100644 index 0000000..c566ced --- /dev/null +++ b/bake/test/cases/branch.json @@ -0,0 +1,113 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "Feature/Some_thing" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:Feature-Some_thing" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "Feature/Some_thing" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:Feature-Some_thing-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "Feature/Some_thing" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:Feature-Some_thing" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "Feature/Some_thing" + }, + "tags": [ + "ghcr.io/specsnl/php84:Feature-Some_thing" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:Feature-Some_thing" + ] + } +} diff --git a/bake/test/cases/dispatch.env b/bake/test/cases/dispatch.env new file mode 100644 index 0000000..a0f0606 --- /dev/null +++ b/bake/test/cases/dispatch.env @@ -0,0 +1,11 @@ +EVENT=workflow_dispatch +REF_TYPE=branch +REF_NAME=main +DISPATCH_TAG=testing +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 new file mode 100644 index 0000000..8d5421c --- /dev/null +++ b/bake/test/cases/dispatch.json @@ -0,0 +1,113 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "testing" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:testing" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "testing" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:testing-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "testing" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:testing" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "testing" + }, + "tags": [ + "ghcr.io/specsnl/php84:testing" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:testing" + ] + } +} diff --git a/bake/test/cases/local.env b/bake/test/cases/local.env new file mode 100644 index 0000000..e69de29 diff --git a/bake/test/cases/local.json b/bake/test/cases/local.json new file mode 100644 index 0000000..7cd4d2f --- /dev/null +++ b/bake/test/cases/local.json @@ -0,0 +1,65 @@ +{ + "builder": { + "annotations": [ + "manifest:org.opencontainers.image.title=PHP 8.4 builder", + "manifest:org.opencontainers.image.version=dev" + ], + "labels": { + "org.opencontainers.image.title": "PHP 8.4 builder", + "org.opencontainers.image.version": "dev" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:local" + ] + }, + "cli-alpine": { + "args": { + "SPECS_VERSION": "dev" + }, + "labels": { + "org.opencontainers.image.title": "specs-cli", + "org.opencontainers.image.version": "dev" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:local-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_VERSION": "dev" + }, + "labels": { + "org.opencontainers.image.title": "specs-cli", + "org.opencontainers.image.version": "dev" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:local" + ] + }, + "runtime": { + "annotations": [ + "manifest:org.opencontainers.image.description=PHP 8.4 runtime", + "manifest:org.opencontainers.image.title=PHP 8.4", + "manifest:org.opencontainers.image.version=dev" + ], + "labels": { + "org.opencontainers.image.description": "PHP 8.4 runtime", + "org.opencontainers.image.title": "PHP 8.4", + "org.opencontainers.image.version": "dev" + }, + "tags": [ + "ghcr.io/specsnl/php84:local" + ] + }, + "utils": { + "annotations": [ + "manifest:org.opencontainers.image.version=dev" + ], + "labels": { + "org.opencontainers.image.version": "dev" + }, + "tags": [ + "ghcr.io/specsnl/utils:local" + ] + } +} diff --git a/bake/test/cases/pr.env b/bake/test/cases/pr.env new file mode 100644 index 0000000..de26a7a --- /dev/null +++ b/bake/test/cases/pr.env @@ -0,0 +1,11 @@ +EVENT=pull_request +REF_TYPE=branch +REF_NAME=42/merge +PR_NUMBER=42 +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 new file mode 100644 index 0000000..26d9960 --- /dev/null +++ b/bake/test/cases/pr.json @@ -0,0 +1,113 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:pr-42" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:pr-42-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:pr-42" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "pr-42" + }, + "tags": [ + "ghcr.io/specsnl/php84:pr-42" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:pr-42" + ] + } +} diff --git a/bake/test/cases/schedule.env b/bake/test/cases/schedule.env new file mode 100644 index 0000000..453893d --- /dev/null +++ b/bake/test/cases/schedule.env @@ -0,0 +1,10 @@ +EVENT=schedule +REF_TYPE=branch +REF_NAME=main +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 new file mode 100644 index 0000000..3a845ec --- /dev/null +++ b/bake/test/cases/schedule.json @@ -0,0 +1,113 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "nightly" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:nightly" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "nightly" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:nightly-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "nightly" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:nightly" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "nightly" + }, + "tags": [ + "ghcr.io/specsnl/php84:nightly" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:nightly" + ] + } +} diff --git a/bake/test/cases/tag-not-semver.env b/bake/test/cases/tag-not-semver.env new file mode 100644 index 0000000..42c13d2 --- /dev/null +++ b/bake/test/cases/tag-not-semver.env @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..be6de96 --- /dev/null +++ b/bake/test/cases/tag-not-semver.json @@ -0,0 +1,113 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "version-2" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:version-2" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "version-2" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:version-2-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "version-2" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:version-2" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "version-2" + }, + "tags": [ + "ghcr.io/specsnl/php84:version-2" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:version-2" + ] + } +} diff --git a/bake/test/cases/tag-prerelease.env b/bake/test/cases/tag-prerelease.env new file mode 100644 index 0000000..29b87be --- /dev/null +++ b/bake/test/cases/tag-prerelease.env @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..9787d6e --- /dev/null +++ b/bake/test/cases/tag-prerelease.json @@ -0,0 +1,113 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3-rc.1" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:1.2.3-rc.1" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3-rc.1" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:1.2.3-rc.1-alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3-rc.1" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:1.2.3-rc.1" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3-rc.1" + }, + "tags": [ + "ghcr.io/specsnl/php84:1.2.3-rc.1" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils: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 new file mode 100644 index 0000000..abb36ec --- /dev/null +++ b/bake/test/cases/tag-stable-not-semver.env @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..b15f7e4 --- /dev/null +++ b/bake/test/cases/tag-stable-not-semver.json @@ -0,0 +1,118 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "2026.11" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:2026.11", + "ghcr.io/specsnl/php84/builder:latest" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "2026.11" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:2026.11-alpine", + "ghcr.io/specsnl/specs-cli:alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "2026.11" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:2026.11", + "ghcr.io/specsnl/specs-cli:latest" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "2026.11" + }, + "tags": [ + "ghcr.io/specsnl/php84:2026.11", + "ghcr.io/specsnl/php84:latest" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:2026.11", + "ghcr.io/specsnl/utils:latest" + ] + } +} diff --git a/bake/test/cases/tag-stable.env b/bake/test/cases/tag-stable.env new file mode 100644 index 0000000..fc85983 --- /dev/null +++ b/bake/test/cases/tag-stable.env @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..eea40f0 --- /dev/null +++ b/bake/test/cases/tag-stable.json @@ -0,0 +1,128 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:1.2.3", + "ghcr.io/specsnl/php84/builder:1.2", + "ghcr.io/specsnl/php84/builder:1", + "ghcr.io/specsnl/php84/builder:latest" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:1.2.3-alpine", + "ghcr.io/specsnl/specs-cli:1.2-alpine", + "ghcr.io/specsnl/specs-cli:1-alpine", + "ghcr.io/specsnl/specs-cli:alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:1.2.3", + "ghcr.io/specsnl/specs-cli:1.2", + "ghcr.io/specsnl/specs-cli:1", + "ghcr.io/specsnl/specs-cli:latest" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "1.2.3" + }, + "tags": [ + "ghcr.io/specsnl/php84:1.2.3", + "ghcr.io/specsnl/php84:1.2", + "ghcr.io/specsnl/php84:1", + "ghcr.io/specsnl/php84:latest" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:1.2.3", + "ghcr.io/specsnl/utils:1.2", + "ghcr.io/specsnl/utils:1", + "ghcr.io/specsnl/utils:latest" + ] + } +} diff --git a/bake/test/cases/tag-v0.0.env b/bake/test/cases/tag-v0.0.env new file mode 100644 index 0000000..57c0747 --- /dev/null +++ b/bake/test/cases/tag-v0.0.env @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..4a902c0 --- /dev/null +++ b/bake/test/cases/tag-v0.0.json @@ -0,0 +1,118 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.0.5" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:0.0.5", + "ghcr.io/specsnl/php84/builder:latest" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.0.5" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:0.0.5-alpine", + "ghcr.io/specsnl/specs-cli:alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.0.5" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:0.0.5", + "ghcr.io/specsnl/specs-cli:latest" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.0.5" + }, + "tags": [ + "ghcr.io/specsnl/php84:0.0.5", + "ghcr.io/specsnl/php84:latest" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:0.0.5", + "ghcr.io/specsnl/utils:latest" + ] + } +} diff --git a/bake/test/cases/tag-v0.env b/bake/test/cases/tag-v0.env new file mode 100644 index 0000000..bc8b345 --- /dev/null +++ b/bake/test/cases/tag-v0.env @@ -0,0 +1,11 @@ +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 new file mode 100644 index 0000000..15369ac --- /dev/null +++ b/bake/test/cases/tag-v0.json @@ -0,0 +1,123 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.1.0" + }, + "tags": [ + "ghcr.io/specsnl/php84/builder:0.1.0", + "ghcr.io/specsnl/php84/builder:0.1", + "ghcr.io/specsnl/php84/builder:latest" + ] + }, + "cli-alpine": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.1.0" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:0.1.0-alpine", + "ghcr.io/specsnl/specs-cli:0.1-alpine", + "ghcr.io/specsnl/specs-cli:alpine" + ] + }, + "cli-debian": { + "args": { + "SPECS_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": "specs-cli", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.1.0" + }, + "tags": [ + "ghcr.io/specsnl/specs-cli:0.1.0", + "ghcr.io/specsnl/specs-cli:0.1", + "ghcr.io/specsnl/specs-cli:latest" + ] + }, + "runtime": { + "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", + "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": "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example", + "org.opencontainers.image.version": "0.1.0" + }, + "tags": [ + "ghcr.io/specsnl/php84:0.1.0", + "ghcr.io/specsnl/php84:0.1", + "ghcr.io/specsnl/php84:latest" + ] + }, + "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" + }, + "tags": [ + "ghcr.io/specsnl/utils:0.1.0", + "ghcr.io/specsnl/utils:0.1", + "ghcr.io/specsnl/utils:latest" + ] + } +} diff --git a/bake/test/cases/unknown-event.env b/bake/test/cases/unknown-event.env new file mode 100644 index 0000000..9a789cb --- /dev/null +++ b/bake/test/cases/unknown-event.env @@ -0,0 +1,10 @@ +EVENT=merge_group +REF_TYPE=branch +REF_NAME=gh-readonly-queue/main/pr-1 +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 new file mode 100644 index 0000000..408ab85 --- /dev/null +++ b/bake/test/cases/unknown-event.json @@ -0,0 +1,90 @@ +{ + "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", + "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": "PHP 8.4 builder", + "org.opencontainers.image.url": "https://github.com/specsnl/example" + } + }, + "cli-alpine": { + "args": { + "SPECS_VERSION": "" + }, + "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example" + } + }, + "cli-debian": { + "args": { + "SPECS_VERSION": "" + }, + "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example" + } + }, + "runtime": { + "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", + "manifest:org.opencontainers.image.url=https://github.com/specsnl/example" + ], + "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", + "org.opencontainers.image.url": "https://github.com/specsnl/example" + } + }, + "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/docker-bake.hcl b/bake/test/docker-bake.hcl new file mode 100644 index 0000000..2cadf84 --- /dev/null +++ b/bake/test/docker-bake.hcl @@ -0,0 +1,41 @@ +group "default" { + targets = ["utils", "runtime", "builder", "cli"] +} + +target "utils" { + platforms = ["linux/amd64", "linux/arm64"] + tags = specs_tags(["ghcr.io/specsnl/utils"], "") + labels = specs_labels("", "") + annotations = specs_annotations("", "") +} + +target "_php" { + dockerfile = "Dockerfile.php" + platforms = ["linux/amd64", "linux/arm64"] +} + +target "runtime" { + inherits = ["_php"] + target = "runtime" + tags = specs_tags(["ghcr.io/specsnl/php84"], "") + labels = specs_labels("PHP 8.4", "PHP 8.4 runtime") + annotations = specs_annotations("PHP 8.4", "PHP 8.4 runtime") +} + +target "builder" { + inherits = ["_php"] + target = "builder" + tags = specs_tags(["ghcr.io/specsnl/php84/builder"], "") + labels = specs_labels("PHP 8.4 builder", "") + annotations = specs_annotations("PHP 8.4 builder", "") +} + +target "cli" { + name = "cli-${variant}" + matrix = { variant = ["debian", "alpine"] } + target = variant + platforms = ["linux/amd64", "linux/arm64"] + args = { SPECS_VERSION = VERSION } + tags = specs_tags(["ghcr.io/SpecsNL/specs-cli"], variant == "debian" ? "" : variant) + labels = specs_labels("specs-cli", "") +} diff --git a/bake/test/run.sh b/bake/test/run.sh new file mode 100755 index 0000000..f43d955 --- /dev/null +++ b/bake/test/run.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# Runs `docker buildx bake --print` on test/docker-bake.hcl for every case in test/cases and compares the tags, +# labels, annotations and args with the expected JSON. Pass --update to rewrite the expected files instead. +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) +update=false +[ "${1:-}" = "--update" ] && update=true + +failed=0 +for case_file in cases/*.env; do + name=$(basename "$case_file" .env) + expected="cases/$name.json" + + actual=$( + for variable in "${variables[@]}"; do unset "$variable"; done + while IFS= read -r line || [ -n "$line" ]; do + case "$line" in '' | '#'*) continue ;; esac + export "${line?}" + done < "$case_file" + docker buildx bake --progress=quiet -f ../specs.hcl -f docker-bake.hcl --print 2> /dev/null | + jq --sort-keys '.target | map_values({tags, labels, annotations, args} | with_entries(select(.value != null)))' + ) + + if $update; then + printf '%s\n' "$actual" > "$expected" + echo "updated $name" + elif diff -u --label "$expected" --label "actual" "$expected" <(printf '%s\n' "$actual"); then + echo "ok $name" + else + echo "FAILED $name" + failed=1 + fi +done + +exit "$failed"