scripts: Add `--from-version` to changelog script

This allows generating changelogs from eg. version 1.1 to 1.2 combining
any pre-releases.
This commit is contained in:
cloudhead 2024-11-27 17:25:02 +01:00
parent 47b200988c
commit bcba8f5a21
No known key found for this signature in database
1 changed files with 34 additions and 1 deletions

View File

@ -1,9 +1,42 @@
#!/bin/sh
set -e
# Version from which to generate the changelog.
from=""
while [ $# -gt 0 ]; do
case "$1" in
--from-version)
if [ -z "$2" ]; then
echo "error: '--from-version' requires a version number" >&2
exit 1
fi
shift
from=$(echo "$1" | sed 's/^v//')
break
;;
*)
echo "error: unknown argument '$1'" >&2
exit 1
;;
esac
done
# Current/latest tag.
tag=$(git describe)
version=$(echo $tag | sed 's/^v//')
if [ -z "$from" ]; then
previous="$(git describe --abbrev=0 HEAD^)"
else
previous="v$from"
fi
if ! git rev-parse --verify "$previous^{tag}" >/dev/null 2>&1; then
echo "error: '$from' is not a valid version, tag '$previous' not found" >&2
exit 1
fi
echo "# 👾 Radicle $version"
echo
echo "Radicle $version ($(git rev-parse --short HEAD)) is released."
@ -21,7 +54,7 @@ echo
echo "## Changelog"
echo
git log --pretty=format:'* `%h` **%s** *<%ae>*' $(git describe --abbrev=0 HEAD^)..HEAD
git log --pretty=format:'* `%h` **%s** *<%ae>*' $previous..HEAD
echo
echo "## Checksums"