From 3203a45ad2b6e7fb353f6985d425a65c7998d7a3 Mon Sep 17 00:00:00 2001 From: Marco Lecheler Date: Fri, 6 Nov 2026 23:40:13 +0100 Subject: [PATCH] feat(ci): add artifacthub changes to github release notes --- .github/workflows/release.yaml | 12 ++++++++++++ scripts/release-notes.sh | 35 ++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100755 scripts/release-notes.sh diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d765703..82c9e01 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -45,6 +45,18 @@ jobs: mark_as_latest: false skip_existing: true + - name: Add changelog to release notes + if: steps.cr.outputs.changed_charts != '' + env: + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GH_REPO: "${{ github.repository }}" + CHANGED_CHARTS: "${{ steps.cr.outputs.changed_charts }}" + run: | + IFS=',' read -ra charts <<< "$CHANGED_CHARTS" + for chart in "${charts[@]}"; do + ./scripts/release-notes.sh "$chart" + done + # Mirror main's README onto gh-pages, then inject the chart table from # index.yaml into its start/end markers. main is the single source of # truth for the static content (title, badges, usage); gh-pages never diff --git a/scripts/release-notes.sh b/scripts/release-notes.sh new file mode 100755 index 0000000..b34b4e3 --- /dev/null +++ b/scripts/release-notes.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +# Writes the artifacthub.io/changes annotation of a chart as GitHub release notes. +# Usage: release-notes.sh (needs yq, gh, GH_REPO and GITHUB_SHA) +set -euo pipefail + +chart_dir="${1:?usage: release-notes.sh }" +chart_file="${chart_dir}/Chart.yaml" + +name="$(yq -r '.name' "${chart_file}")" +version="$(yq -r '.version' "${chart_file}")" +tag="${name}-${version}" + +changes="$(yq -r '.annotations["artifacthub.io/changes"] // ""' "${chart_file}")" +if [[ -z "${changes}" ]]; then + echo "${tag}: no artifacthub.io/changes annotation, leaving release notes untouched" + exit 0 +fi + +if ! gh release view "${tag}" >/dev/null 2>&1; then + echo "${tag}: release does not exist, skipping" + exit 0 +fi + +entries="$(printf '%s\n' "${changes}" | yq -r '.[] | "- **" + .kind + "**: " + .description')" + +pull_requests="$(gh api "repos/${GH_REPO}/commits/${GITHUB_SHA}/pulls" \ + --jq '.[] | "- #" + (.number | tostring) + " " + .title' 2>/dev/null || true)" + +notes="## Changes"$'\n\n'"${entries}" +if [[ -n "${pull_requests}" ]]; then + notes+=$'\n\n'"## Pull requests"$'\n\n'"${pull_requests}" +fi + +gh release edit "${tag}" --notes "${notes}" +echo "${tag}: release notes updated"