#!/usr/bin/env bash # Prints the release notes for a tag: the images it publishes, then the matching # section of CHANGELOG.md (the commit log since the previous tag if the changelog # has no section for that version). # # scripts/release-notes.sh v1.2.3 git.example.com/owner/project set -euo pipefail tag=${1:?usage: release-notes.sh } namespace=${2:?usage: release-notes.sh } version=${tag#v} echo "## Images" echo echo '```' for service in protocols auth storage webmail migrations rspamd; do echo "$namespace/$service:$version" done echo '```' echo section="" if [ -f CHANGELOG.md ]; then section=$(awk -v head="## [$version]" ' index($0, head) == 1 { found = 1; next } found && /^## \[/ { exit } found && /^\[[^]]+\]: / { next } found { print } ' CHANGELOG.md) fi if [ -n "$(printf '%s' "$section" | tr -d '[:space:]')" ]; then printf '%s\n' "$section" else previous=$(git describe --tags --abbrev=0 "$tag^" 2>/dev/null || true) echo "## Changes${previous:+ since $previous}" echo git log --no-merges --format='- %s (%h)' "${previous:+$previous..}$tag" fi