caddy/.github/scripts/release-notes.sh
Francis Lavoie 468154121d
Some checks are pending
Tests / test (./cmd/caddy/caddy, ~1.27.0, macos-latest, 0, 1.27, mac) (push) Waiting to run
Tests / test (./cmd/caddy/caddy, ~1.27.0, ubuntu-latest, 0, 1.27, linux) (push) Waiting to run
Tests / test (./cmd/caddy/caddy.exe, ~1.27.0, windows-latest, True, 1.27, windows) (push) Waiting to run
Tests / test (s390x on IBM Z) (push) Waiting to run
Tests / goreleaser-check (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, aix) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, darwin) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, dragonfly) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, freebsd) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, illumos) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, linux) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, netbsd) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, openbsd) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, solaris) (push) Waiting to run
Cross-Build / build (~1.26.0, 1.26, windows) (push) Waiting to run
Lint / lint (push) Waiting to run
Lint / lint-1 (push) Waiting to run
Lint / lint-2 (push) Waiting to run
Lint / govulncheck (push) Waiting to run
Lint / dependency-review (push) Waiting to run
OpenSSF Scorecard supply-chain security / Scorecard analysis (push) Waiting to run
ci: release changelogs since the previous published release, and workflow hardening (#8341)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Mohammed Al Sahaf <msaa1990@gmail.com>
2026-11-03 23:07:13 +00:00

43 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
# Prints GitHub's generated release notes for <tag> (What's Changed, New
# Contributors, Full Changelog), compared against <previous-tag>, without
# the PRs that already shipped in <previous-tag>.
#
# Usage: release-notes.sh <tag> <target-commit> [previous-tag]
#
# GitHub's generator lists every PR in previous...tag. When the previous
# release was cut from a maintenance branch, that includes the master PRs
# whose fixes were cherry-picked into it, so those are removed here, using
# the same rules as changelog-commits.sh. Only lines ending in a PR link can
# be removed; anything else is left alone.
#
# Requires GH_TOKEN and GITHUB_REPOSITORY in the environment.
set -euo pipefail
tag=${1:?usage: $0 <tag> <target-commit> [previous-tag]}
target=${2:?usage: $0 <tag> <target-commit> [previous-tag]}
previous=${3:-}
args=(-f "tag_name=$tag" -f "target_commitish=$(git rev-parse --verify "$target^{commit}")")
if [ -n "$previous" ]; then
args+=(-f "previous_tag_name=$previous")
fi
notes=$(gh api -X POST "repos/${GITHUB_REPOSITORY}/releases/generate-notes" "${args[@]}" --jq .body)
if [ -z "$previous" ]; then
printf '%s\n' "$notes"
exit 0
fi
scripts=$(dirname "$0")
kept=$("$scripts/changelog-commits.sh" "$previous" "$target")
skipped_prs=$(git rev-list "$previous..$target" | { grep -vxF -f <(printf '%s\n' "$kept") || true; } |
xargs -r git log --no-walk --format=%s | sed -n 's/.*(#\([0-9][0-9]*\))$/\1/p' | sort -u)
if [ -z "$skipped_prs" ]; then
printf '%s\n' "$notes"
exit 0
fi
pattern="/pull/($(paste -sd '|' <<< "$skipped_prs"))\$"
printf '%s\n' "$notes" | tr -d '\r' | grep -vE -- "$pattern"