Generate unstable changelogs using towncrier (#1340)

Replace the current stack of hugo templates with a towncrier invocation. The main advantage of this is that it means that the "Changes since last release" section is consistent with the changelogs for the actual releases.

This also changes the release process so that the changelog is generated before tagging, which means that the thing tagged v1.5 is actually the v1.5 spec.

Fixes #908.
This commit is contained in:
Richard van der Hoff 2022-11-15 23:26:55 +00:00 committed by GitHub
parent 678f8b96f0
commit 08fde5f257
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 85 additions and 125 deletions

40
scripts/generate-changelog.sh Normal file → Executable file
View file

@ -1,15 +1,17 @@
# /bin/bash
# Usage: ./generate.sh v1.2 "April 01, 2021"
# Usage: ./scripts/generate-changelog.sh v1.2 "April 01, 2021"
# or: ./scripts/generate-changelog.sh vUNSTABLE
set -e
MAGIC_STRING="<!-- DO NOT REMOVE OR CHANGE - Release script puts next release here -->"
VERSION="$1"
DATE="$2"
cd changelogs
cd `dirname $0`/../changelogs
# Pre-cleanup just in case it wasn't done on the last run
rm -f rendered.*
rm -f rendered.md
# Reversed order so that room versions ends up on the bottom
towncrier --name "Internal Changes/Tooling" --dir "./internal" --config "./pyproject.toml" --yes
@ -21,18 +23,24 @@ towncrier --name "Application Service API" --dir "./application_service" --confi
towncrier --name "Server-Server API" --dir "./server_server" --config "./pyproject.toml" --yes
towncrier --name "Client-Server API" --dir "./client_server" --config "./pyproject.toml" --yes
# Prepare the header
cp header.md rendered.header.md
sed -i "s/VERSION/$1/g" rendered.header.md
sed -i "s/DATE/$2/g" rendered.header.md
cat rendered.header.md rendered.md > rendered.final.md
{
# Prepare the header
# We include the generation date in the front matter so that we can use it
# to sort the changelogs at build time.
cat <<EOF
---
date: $(date -Iseconds)
---
EOF
if [ "$VERSION" = "vUNSTABLE" ]; then
echo "## Changes since last release"
else
sed -e "s/VERSION/$1/g" -e "s/DATE/$2/g" header.md
fi
# Remove trailing whitespace (such as our intentionally blank RST headings)
sed -i "s/[ ]*$//" rendered.final.md
# Put the changelog in place
mv rendered.final.md ../layouts/partials/changelogs/$1.md
sed -i "s/$MAGIC_STRING/$MAGIC_STRING\n{{% changelog\\/changelog-rendered p=\"changelogs\\/$1.md\" %}}/" ../content/changelog.md
# Remove trailing whitespace (such as our intentionally blank RST headings)
sed -e "s/[ ]*$//" rendered.md
} > ../content/changelog/$VERSION.md
# Cleanup
rm -v rendered.*
rm -v rendered.md