Skip to content

Guideance on copyright notices and AI agent attributions (#1233) #89

Guideance on copyright notices and AI agent attributions (#1233)

Guideance on copyright notices and AI agent attributions (#1233) #89

# Copyright 2022 Google LLC
# Modifications Copyright (C) 2025-2026 OpenInfra Foundation Europe.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Build and push tagged image
on:
push:
tags:
- "functions/*/*/v*"
- "contrib/functions/*/*/v*"
jobs:
build-push-release:
runs-on: ubuntu-latest
permissions:
packages: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v6
with:
go-version-file: documentation/go.mod
cache: true
- name: Setup QEMU
uses: docker/setup-qemu-action@v4
- name: Setup Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Extract semver and image name
id: extract
uses: ./.github/actions/extract-tag-info
- name: Show outputs
run: |
echo "Version = ${{ steps.extract.outputs.version }}"
echo "Image name = ${{ steps.extract.outputs.image_name }}"
- name: Determine release type and push image
run: |
VERSION="${{ steps.extract.outputs.version }}"
IMAGE_NAME="${{ steps.extract.outputs.image_name }}"
if [[ "${GITHUB_REF#refs/tags/}" == functions/* ]]; then
echo "Detected curated functions release"
cd functions/go
make func-push TAG=$VERSION CURRENT_FUNCTION=$IMAGE_NAME DEFAULT_CR=ghcr.io/${GITHUB_REPOSITORY}
elif [[ "${GITHUB_REF#refs/tags/}" == contrib/functions/* ]]; then
echo "Detected contrib functions release"
cd contrib/functions/go
make func-push TAG=$VERSION CURRENT_FUNCTION=$IMAGE_NAME DEFAULT_CR=ghcr.io/${GITHUB_REPOSITORY}/krm-fn-contrib
else
echo "Tag does not match any known type, skipping."
exit 0
fi
- name: Read image reference from metadata
id: meta
run: |
IMAGE_NAME="${{ steps.extract.outputs.image_name }}"
VERSION="${{ steps.extract.outputs.version }}"
FUNC_DIR="functions/go/${IMAGE_NAME}"
if [[ ! -f "${FUNC_DIR}/metadata.yaml" ]]; then
echo "::error::${FUNC_DIR}/metadata.yaml not found"
exit 1
fi
IMAGE_BASE=$(grep '^image:' "${FUNC_DIR}/metadata.yaml" | awk '{print $2}' | tr -d '"')
if [[ -z "$IMAGE_BASE" ]]; then
echo "::error::No image field in ${FUNC_DIR}/metadata.yaml"
exit 1
fi
echo "image_ref=${IMAGE_BASE}:${VERSION}" >> "$GITHUB_OUTPUT"
- name: Add image reference to release notes
if: steps.meta.outputs.image_ref != ''
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="${GITHUB_REF#refs/tags/}"
IMAGE_REF="${{ steps.meta.outputs.image_ref }}"
if ! gh release view "$TAG" --repo "${{ github.repository }}" > /dev/null 2>&1; then
echo "No release found for tag $TAG, skipping."
exit 0
fi
CURRENT_BODY=$(gh release view "$TAG" --repo "${{ github.repository }}" --json body -q .body)
if [[ "$CURRENT_BODY" == *"$IMAGE_REF"* ]]; then
echo "Image reference already present in release notes, skipping."
exit 0
fi
NOTES_FILE=$(mktemp)
printf '%s\n\n## Container Image\n\n```\n%s\n```' "$CURRENT_BODY" "$IMAGE_REF" > "$NOTES_FILE"
gh release edit "$TAG" \
--repo "${{ github.repository }}" \
--notes-file "$NOTES_FILE"
rm -f "$NOTES_FILE"