From 08fde5f25730915724bedc3e26b134f1f64d5b37 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 15 Nov 2022 23:26:55 +0000 Subject: [PATCH] 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. --- .github/workflows/main.yml | 31 ++++++- .../internal/newsfragments/1340.clarification | 1 + content/{changelog.md => changelog/index.md} | 8 +- .../changelogs => content/changelog}/v1.1.md | 3 + .../changelogs => content/changelog}/v1.2.md | 3 + .../changelogs => content/changelog}/v1.3.md | 3 + .../changelogs => content/changelog}/v1.4.md | 3 + layouts/partials/changelogs/.gitkeep | 0 .../changelog/changelog-changes.html | 90 ------------------- .../changelog/changelog-rendered.html | 2 - layouts/shortcodes/changelog/changelogs.html | 10 +++ meta/releasing.md | 16 ++-- scripts/generate-changelog.sh | 42 +++++---- 13 files changed, 86 insertions(+), 126 deletions(-) create mode 100644 changelogs/internal/newsfragments/1340.clarification rename content/{changelog.md => changelog/index.md} (85%) rename {layouts/partials/changelogs => content/changelog}/v1.1.md (99%) rename {layouts/partials/changelogs => content/changelog}/v1.2.md (99%) rename {layouts/partials/changelogs => content/changelog}/v1.3.md (99%) rename {layouts/partials/changelogs => content/changelog}/v1.4.md (99%) delete mode 100644 layouts/partials/changelogs/.gitkeep delete mode 100644 layouts/shortcodes/changelog/changelog-changes.html delete mode 100644 layouts/shortcodes/changelog/changelog-rendered.html create mode 100644 layouts/shortcodes/changelog/changelogs.html mode change 100644 => 100755 scripts/generate-changelog.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ce54f976..a77191d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -99,10 +99,32 @@ jobs: name: openapi-artifact path: openapi.tar.gz + generate-changelog: + name: "📢 Run towncrier for changelog" + # skip for builds of git tags + if: "!startsWith(github.ref, 'refs/tags/')" + runs-on: ubuntu-latest + steps: + - name: "📥 Source checkout" + uses: actions/checkout@v2 + - name: "➕ Setup Python" + uses: actions/setup-python@v4 + - name: "➕ Install towncrier" + run: "pip install 'towncrier'" + - name: "Generate changelog" + run: ./scripts/generate-changelog.sh vUNSTABLE + - name: "📤 Artifact upload" + uses: actions/upload-artifact@v2 + with: + name: changelog-artifact + path: content/changelog/vUNSTABLE.md + build-spec: name: "📖 Build the spec" runs-on: ubuntu-latest - needs: [calculate-baseurl, build-openapi] + needs: [calculate-baseurl, build-openapi, generate-changelog] + # run even if generate-changelog was skipped + if: ${{ always() }} steps: - name: "➕ Setup Node" uses: actions/setup-node@v2 @@ -119,9 +141,14 @@ jobs: run: | npm i npm run get-proposals + - name: "📥 Download generated changelog" + if: "needs.generate-changelog.result == 'success'" + uses: actions/download-artifact@v3 + with: + name: changelog-artifact + path: content/changelog - name: "⚙️ hugo" run: hugo --baseURL "${{ needs.calculate-baseurl.outputs.baseURL }}" -d "spec" - # We manually unpack the spec OpenAPI definition JSON to the website tree # to make it available to the world in a canonical place: # https://spec.matrix.org/latest/client-server-api/api.json diff --git a/changelogs/internal/newsfragments/1340.clarification b/changelogs/internal/newsfragments/1340.clarification new file mode 100644 index 00000000..a3180440 --- /dev/null +++ b/changelogs/internal/newsfragments/1340.clarification @@ -0,0 +1 @@ +Generate the unstable changelogs with towncrier, for consistency. diff --git a/content/changelog.md b/content/changelog/index.md similarity index 85% rename from content/changelog.md rename to content/changelog/index.md index a84514b6..560cb43b 100644 --- a/content/changelog.md +++ b/content/changelog/index.md @@ -6,13 +6,7 @@ weight: 1000 {{% changelog/changelog-description %}} -{{% changelog/changelog-changes %}} - - -{{% changelog/changelog-rendered p="changelogs/v1.4.md" %}} -{{% changelog/changelog-rendered p="changelogs/v1.3.md" %}} -{{% changelog/changelog-rendered p="changelogs/v1.2.md" %}} -{{% changelog/changelog-rendered p="changelogs/v1.1.md" %}} +{{% changelog/changelogs %}}

Historical versions

diff --git a/layouts/partials/changelogs/v1.1.md b/content/changelog/v1.1.md similarity index 99% rename from layouts/partials/changelogs/v1.1.md rename to content/changelog/v1.1.md index b8e0832d..8cf43878 100644 --- a/layouts/partials/changelogs/v1.1.md +++ b/content/changelog/v1.1.md @@ -1,3 +1,6 @@ +--- +date: 2021-11-09T00:00:00+0000 +--- " +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 - -# 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 +{ + # 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 < ../content/changelog/$VERSION.md # Cleanup -rm -v rendered.* +rm -v rendered.md