Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions scripts/release-notes.sh
Original file line number Diff line number Diff line change
@@ -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 <chart-dir> (needs yq, gh, GH_REPO and GITHUB_SHA)
set -euo pipefail

chart_dir="${1:?usage: release-notes.sh <chart-dir>}"
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"
Loading