Generate release notes using the new API

https://docs.github.com/en/rest/reference/repos#generate-release-notes-content-for-a-release
This commit is contained in:
Mislav Marohnić 2021-10-13 20:51:37 +02:00
parent 78ac77180e
commit 1464a8a0f3
3 changed files with 10 additions and 28 deletions

View file

@ -1,24 +0,0 @@
#!/bin/bash
set -e
current_tag="${GITHUB_REF#refs/tags/}"
start_ref="HEAD"
# Find the previous release on the same branch, skipping prereleases if the
# current tag is a full release
previous_tag=""
while [[ -z $previous_tag || ( $previous_tag == *-* && $current_tag != *-* ) ]]; do
previous_tag="$(git describe --tags "$start_ref"^ --abbrev=0)"
start_ref="$previous_tag"
done
git log "$previous_tag".. --reverse --first-parent --oneline | \
while read -r sha title; do
if [[ $title == "Merge pull request #"* ]]; then
pr_num="$(grep -o '#[[:digit:]]\+' <<<"$title")"
pr_desc="$(git show -s --format=%b "$sha" | sed -n '1,/^$/p' | tr $'\n' ' ')"
printf "* %s %s\n\n" "$pr_desc" "$pr_num"
else
printf "* %s\n\n" "$title"
fi
done