Skip to content

Commit c0a6ef7

Browse files
authored
feat: add OCI annotations to containers (#556)
* fix: lowercase repo owner name GitHub container registry names have to be lowercase, and repo forks might not have all-lowercase usernames, so this is necessary for the workflow to work properly on forks. * feat: add OCI annotations to containers Add annotations to module images using keys from the OCI annotations spec: https://specs.opencontainers.org/image-spec/annotations/ These annotations are used by various dependency management tools (such as renovate-bot) to find metadata associated with dependency updates.
1 parent 6d6ec2b commit c0a6ef7

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

.github/workflows/build-reusable.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@ jobs:
4646

4747
- uses: sigstore/cosign-installer@faadad0cce49287aee09b3a48701e75088a2c6ad # v4.0.0
4848

49+
- name: Lowercase container registry name
50+
id: registry
51+
shell: bash
52+
run: |
53+
echo "registry=ghcr.io/${GITHUB_REPOSITORY_OWNER,,}" >>"${GITHUB_OUTPUT}"
54+
4955
- name: Run build and push script
5056
env:
51-
REGISTRY: ghcr.io/${{ github.repository_owner }}
57+
REGISTRY: ${{ steps.registry.outputs.registry }}
5258
COSIGN_PRIVATE_KEY: ${{ secrets.SIGNING_SECRET }}
5359
GH_EVENT_NAME: ${{ github.event_name }}
5460
GH_PR_NUMBER: ${{ github.event.number }}

build-individual.nu

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,17 @@ $images | par-each { |img|
8585
...($PLATFORMS | each { $'--platform=($in)' })
8686
...($img.tags | each { |tag| ["-t", $"($env.REGISTRY)/modules/($img.name):($tag)"] } | flatten) # generate and spread list of tags
8787
--build-arg $"DIRECTORY=($img.directory)"
88-
--build-arg $"NAME=($img.name)")
88+
--build-arg $"NAME=($img.name)"
89+
--annotation $"index,manifest:org.opencontainers.image.created=(date now | date to-timezone UTC | format date '%Y-%m-%dT%H:%M:%SZ')"
90+
--annotation "index,manifest:org.opencontainers.image.url=https://github.com/blue-build/modules"
91+
--annotation $"index,manifest:org.opencontainers.image.documentation=https://blue-build.org/reference/modules/($img.name)/"
92+
--annotation "index,manifest:org.opencontainers.image.source=https://github.com/blue-build/modules"
93+
--annotation "index,manifest:org.opencontainers.image.version=nightly"
94+
--annotation $"index,manifest:org.opencontainers.image.revision=($env.GITHUB_SHA)"
95+
--annotation "index,manifest:org.opencontainers.image.licenses=Apache-2.0"
96+
--annotation $"index,manifest:org.opencontainers.image.title=BlueBuild Module: ($img.name)"
97+
--annotation "index,manifest:org.opencontainers.image.description=BlueBuild standard modules used for building your Atomic Images"
98+
)
8999

90100
let inspect_image = $'($env.REGISTRY)/modules/($img.name):($img.tags | first)'
91101
print $"(ansi cyan)Inspecting image:(ansi reset) ($inspect_image)"
@@ -102,7 +112,7 @@ $images | par-each { |img|
102112
print $"(ansi cyan)Signing image:(ansi reset) ($digest_image)"
103113
(cosign sign
104114
--new-bundle-format=false
105-
--use-signing-config=false
115+
--use-signing-config=false
106116
-y --recursive
107117
--key env://COSIGN_PRIVATE_KEY
108118
$digest_image)

build-unified.nu

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ print $"(ansi green_bold)Generated tags for image:(ansi reset) ($tag)"
4848
--push
4949
...($PLATFORMS | each { $'--platform=($in)' })
5050
-t $"($env.REGISTRY)/modules:($tag)"
51+
--annotation $"index,manifest:org.opencontainers.image.created=(date now | date to-timezone UTC | format date '%Y-%m-%dT%H:%M:%SZ')"
52+
--annotation "index,manifest:org.opencontainers.image.url=https://github.com/blue-build/modules"
53+
--annotation "index,manifest:org.opencontainers.image.documentation=https://blue-build.org/"
54+
--annotation "index,manifest:org.opencontainers.image.source=https://github.com/blue-build/modules"
55+
--annotation "index,manifest:org.opencontainers.image.version=nightly"
56+
--annotation $"index,manifest:org.opencontainers.image.revision=($env.GITHUB_SHA)"
57+
--annotation "index,manifest:org.opencontainers.image.licenses=Apache-2.0"
58+
--annotation "index,manifest:org.opencontainers.image.title=BlueBuild Modules"
59+
--annotation "index,manifest:org.opencontainers.image.description=BlueBuild standard modules used for building your Atomic Images"
5160
)
5261

5362
let inspect_image = $'($env.REGISTRY)/modules:($tag)'
@@ -65,7 +74,7 @@ let digest_image = $'($env.REGISTRY)/modules@($digest)'
6574
print $"(ansi cyan)Signing image:(ansi reset) ($digest_image)"
6675
(cosign sign
6776
--new-bundle-format=false
68-
--use-signing-config=false
77+
--use-signing-config=false
6978
-y --recursive
7079
--key env://COSIGN_PRIVATE_KEY
7180
$digest_image)

0 commit comments

Comments
 (0)