@marcel91200 / caddy Mirror · read-only
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 11, 01:00 UTC

master
sh 43 lines 1.6 KB
Raw
1 #!/usr/bin/env bash
2 # Prints GitHub's generated release notes for <tag> (What's Changed, New
3 # Contributors, Full Changelog), compared against <previous-tag>, without
4 # the PRs that already shipped in <previous-tag>.
5 #
6 # Usage: release-notes.sh <tag> <target-commit> [previous-tag]
7 #
8 # GitHub's generator lists every PR in previous...tag. When the previous
9 # release was cut from a maintenance branch, that includes the master PRs
10 # whose fixes were cherry-picked into it, so those are removed here, using
11 # the same rules as changelog-commits.sh. Only lines ending in a PR link can
12 # be removed; anything else is left alone.
13 #
14 # Requires GH_TOKEN and GITHUB_REPOSITORY in the environment.
15 set -euo pipefail
16
17 tag=${1:?usage: $0 <tag> <target-commit> [previous-tag]}
18 target=${2:?usage: $0 <tag> <target-commit> [previous-tag]}
19 previous=${3:-}
20
21 args=(-f "tag_name=$tag" -f "target_commitish=$(git rev-parse --verify "$target^{commit}")")
22 if [ -n "$previous" ]; then
23 args+=(-f "previous_tag_name=$previous")
24 fi
25 notes=$(gh api -X POST "repos/${GITHUB_REPOSITORY}/releases/generate-notes" "${args[@]}" --jq .body)
26
27 if [ -z "$previous" ]; then
28 printf '%s\n' "$notes"
29 exit 0
30 fi
31
32 scripts=$(dirname "$0")
33 kept=$("$scripts/changelog-commits.sh" "$previous" "$target")
34 skipped_prs=$(git rev-list "$previous..$target" | { grep -vxF -f <(printf '%s\n' "$kept") || true; } |
35 xargs -r git log --no-walk --format=%s | sed -n 's/.*(#\([0-9][0-9]*\))$/\1/p' | sort -u)
36
37 if [ -z "$skipped_prs" ]; then
38 printf '%s\n' "$notes"
39 exit 0
40 fi
41
42 pattern="/pull/($(paste -sd '|' <<< "$skipped_prs"))\$"
43 printf '%s\n' "$notes" | tr -d '\r' | grep -vE -- "$pattern"