cli/script/changelog
Mislav Marohnić 2271f4cdb6 Generate changelog on release
The changelog is generated using the git log of pull request merges
since the last tagged release, and is in the following format:

    * {PR title} #{PR number}
2020-01-07 13:55:56 +01:00

20 lines
No EOL
690 B
Bash
Executable file

#!/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 --merges --oneline --grep='Merge pull request #' | \
while read -r sha title; do
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"
done