Generate changelog release info with Hugo rather than when generating changelog

Allows to have more control on the output, like showing a link to the checklist on the unstable changelog,
and using only markdown in the checklist output format.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
This commit is contained in:
Kévin Commaille 2024-12-15 16:51:31 +01:00
parent 35c3ddb33b
commit a34a89a073
No known key found for this signature in database
GPG key ID: 0C971D9DBC9D678D
19 changed files with 109 additions and 219 deletions

View file

@ -1,15 +0,0 @@
<!--
This is a header file for the generated changelog.
Variables:
VERSION = Replaced by the version number (eg: v1.2)
DATE = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/VERSION">https://github.com/matrix-org/matrix-spec/tree/VERSION</a></td>
<tr><th>Release date</th><td>DATE</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/VERSION" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->

View file

@ -4,4 +4,4 @@ type: docs
weight: 1000
---
{{% changelog/changelogs %}}
<!-- This page will be redirected to the latest version's changelog -->

View file

@ -2,26 +2,13 @@
title: v1.1 Changelog
linkTitle: v1.1
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2021-11-09T00:00:00+0000
date: 2021-11-09
---
<!--
This is a header file for the generated changelog.
Variables:
v1.1 = Replaced by the version number (eg: v1.2)
November 09, 2021 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-doc/tree/v1.1">https://github.com/matrix-org/matrix-doc/tree/v1.1</a></td>
<tr><th>Release date</th><td>November 09, 2021</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.1" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,12 @@
title: v1.10 Changelog
linkTitle: v1.10
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2024-03-22T09:59:45-06:00
date: 2024-03-22
---
<!--
This is a header file for the generated changelog.
Variables:
v1.10 = Replaced by the version number (eg: v1.2)
March 22, 2024 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.10">https://github.com/matrix-org/matrix-spec/tree/v1.10</a></td>
<tr><th>Release date</th><td>March 22, 2024</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.10" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,12 @@
title: v1.11 Changelog
linkTitle: v1.11
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2024-06-20T10:20:43-06:00
date: 2024-06-20
---
<!--
This is a header file for the generated changelog.
Variables:
v1.11 = Replaced by the version number (eg: v1.2)
June 20, 2024 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.11">https://github.com/matrix-org/matrix-spec/tree/v1.11</a></td>
<tr><th>Release date</th><td>June 20, 2024</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.11" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,12 @@
title: v1.12 Changelog
linkTitle: v1.12
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2024-10-07T13:32:03-06:00
date: 2024-10-07
---
<!--
This is a header file for the generated changelog.
Variables:
v1.12 = Replaced by the version number (eg: v1.2)
October 07, 2024 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.12">https://github.com/matrix-org/matrix-spec/tree/v1.12</a></td>
<tr><th>Release date</th><td>October 07, 2024</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.12" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,13 @@
title: v1.2 Changelog
linkTitle: v1.2
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2022-02-02T00:00:00+0000
date: 2022-02-02
---
<!--
This is a header file for the generated changelog.
Variables:
v1.2 = Replaced by the version number (eg: v1.2)
February 02, 2022 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-doc/tree/v1.2">https://github.com/matrix-org/matrix-doc/tree/v1.2</a></td>
<tr><th>Release date</th><td>February 02, 2022</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.2" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,13 @@
title: v1.3 Changelog
linkTitle: v1.3
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2022-06-15T00:00:00+0100
date: 2022-06-15
---
<!--
This is a header file for the generated changelog.
Variables:
v1.3 = Replaced by the version number (eg: v1.2)
June 15, 2022 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.3">https://github.com/matrix-org/matrix-spec/tree/v1.3</a></td>
<tr><th>Release date</th><td>June 15, 2022</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.3" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,13 @@
title: v1.4 Changelog
linkTitle: v1.4
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2022-09-29T00:00:00+0100
date: 2022-09-29
---
<!--
This is a header file for the generated changelog.
Variables:
v1.4 = Replaced by the version number (eg: v1.2)
September 29, 2022 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.4">https://github.com/matrix-org/matrix-spec/tree/v1.4</a></td>
<tr><th>Release date</th><td>September 29, 2022</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.4" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,13 @@
title: v1.5 Changelog
linkTitle: v1.5
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2022-11-17T08:22:11-07:00
date: 2022-11-17
---
<!--
This is a header file for the generated changelog.
Variables:
v1.5 = Replaced by the version number (eg: v1.2)
November 17, 2022 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.5">https://github.com/matrix-org/matrix-spec/tree/v1.5</a></td>
<tr><th>Release date</th><td>November 17, 2022</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.5" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,13 @@
title: v1.6 Changelog
linkTitle: v1.6
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2023-02-14T08:25:40-07:00
date: 2023-02-14
---
<!--
This is a header file for the generated changelog.
Variables:
v1.6 = Replaced by the version number (eg: v1.2)
February 14, 2023 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.6">https://github.com/matrix-org/matrix-spec/tree/v1.6</a></td>
<tr><th>Release date</th><td>February 14, 2023</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.6" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,13 @@
title: v1.7 Changelog
linkTitle: v1.7
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2023-05-25T09:47:21-06:00
date: 2023-05-25
---
<!--
This is a header file for the generated changelog.
Variables:
v1.7 = Replaced by the version number (eg: v1.2)
May 25, 2023 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.7">https://github.com/matrix-org/matrix-spec/tree/v1.7</a></td>
<tr><th>Release date</th><td>May 25, 2023</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.7" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,12 @@
title: v1.8 Changelog
linkTitle: v1.8
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2023-08-23T09:23:53-06:00
date: 2023-08-23
---
<!--
This is a header file for the generated changelog.
Variables:
v1.8 = Replaced by the version number (eg: v1.2)
August 23, 2023 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.8">https://github.com/matrix-org/matrix-spec/tree/v1.8</a></td>
<tr><th>Release date</th><td>August 23, 2023</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.8" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -2,26 +2,12 @@
title: v1.9 Changelog
linkTitle: v1.9
type: docs
layout: changelog
outputs:
- html
- checklist
date: 2023-11-29T10:04:26-07:00
date: 2023-11-29
---
<!--
This is a header file for the generated changelog.
Variables:
v1.9 = Replaced by the version number (eg: v1.2)
November 29, 2023 = Replaced by the date (eg: April 01, 2021)
-->
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/v1.9">https://github.com/matrix-org/matrix-spec/tree/v1.9</a></td>
<tr><th>Release date</th><td>November 29, 2023</td>
<tr><th>Checklist</th><td><a href="{{< relref path="changelog/v1.9" outputFormat="Checklist" >}}">checklist.md</a></td>
</table>
<!-- Intentionally blank line to ensure headers work in the concatenated changelog -->
## Client-Server API

View file

@ -1,4 +0,0 @@
{{ .RawContent
| replaceRE "\n- " "\n- [ ] "
| replaceRE "<!--(.|\\s)*?-->\n?" ""
| replaceRE "<tr><th>Checklist.*\n" "" }}

View file

@ -0,0 +1,34 @@
{{- /*
Template to render a page with a `changelog` layout as a markdown checklist.
This transforms the markdown source of the changelog to change list items to
checklist items.
If it is not the unstable changelog, this also adds a table at the top of
the page with information about the Matrix spec release:
* A link to the matrix-spec repository at the time of the release, with the
version taken from the `linkTitle` in the frontmatter of the page.
* The date of the release, taken from the `date` in the frontmatter of the
page.
*/ -}}
{{ $version := lower .LinkTitle -}}
# Matrix Specification {{ .Title }}
{{ if ne $version "unstable" -}}
{{- /*
Most markdown parsers require the header to recognize a markdown table,
so add an empty header.
*/ -}}
| | |
|---|---|
| Git commit | {{ printf "https://github.com/matrix-org/matrix-spec/tree/%s" $version }} |
| Release date | {{ .Date | time.Format ":date_long" }} |
{{ end -}}
{{ .RawContent | replaceRE "\n- " "\n- [ ] " }}

View file

@ -0,0 +1,46 @@
{{- /*
Template to render a page with a `changelog` layout or the `changelog`
section page. This conflation seems to be a limitation of Hugo currently, it
uses this template for both cases.
For the `changelog` section page, this redirects the page to the latest
version's changelog page.
For a page with a `changelog` layout, this adds a table at the top of the
page with informations about the release:
* A link to the matrix-spec repository at the time of the release, with the
version taken from the `linkTitle` in the frontmatter of the page, unless
it is the unstable changelog.
* The date of the release, taken from the `date` in the frontmatter of the
page, unless it is the unstable changelog.
* A link to the markdown checklist format of the changelog. The `outputs` in
the frontmatter of the page must include `checklist`.
*/ -}}
{{ define "main" }}
{{ if .IsSection -}}
{{ with index .RegularPages.ByDate.Reverse 0 -}}
<meta http-equiv="refresh" content="0; url={{ .RelPermalink }}">
{{ end -}}
{{ else -}}
{{ $version := lower .LinkTitle -}}
<div class="td-content">
<h1>{{ .Title }}</h1>
<table class="release-info">
{{ if ne $version "unstable" -}}
{{ $commitLink := printf "https://github.com/matrix-org/matrix-spec/tree/%s" $version -}}
<tr><th>Git commit</th><td><a href="{{ $commitLink }}">{{ $commitLink }}</a></td>
<tr><th>Release date</th><td>{{ .Date | time.Format ":date_long" }}</td>
{{ end -}}
{{ $checklist := .OutputFormats.Get "checklist" -}}
<tr><th>Checklist</th><td><a href="{{ $checklist.RelPermalink }}">checklist.md</a></td>
</table>
{{ .Content }}
</div>
{{ end -}}
{{ end }}

View file

@ -1,8 +0,0 @@
{{/*
This template is used to redirect the changelog section under
"content/changelogs" to the latest version's changelog page.
*/}}
{{ with index .Page.RegularPages.ByDate.Reverse 0 }}
<meta http-equiv="refresh" content="0; url={{ .RelPermalink }}">
{{ end }}

View file

@ -1,6 +1,6 @@
# /bin/bash
# Usage: ./scripts/generate-changelog.sh v1.2 "April 01, 2021"
# Usage: ./scripts/generate-changelog.sh v1.2 2021-04-01
# or: ./scripts/generate-changelog.sh vUNSTABLE
set -e
@ -20,6 +20,7 @@ if [ "$VERSION" = "vUNSTABLE" ]; then
TITLE="Changes since last release"
LINKTITLE="Unstable"
FILENAME="unstable.md"
DATE=$(date -Iseconds)
else
TITLE="$VERSION Changelog"
LINKTITLE="$VERSION"
@ -35,16 +36,13 @@ fi
title: $TITLE
linkTitle: $LINKTITLE
type: docs
layout: changelog
outputs:
- html
- checklist
date: $(date -Iseconds)
date: $DATE
---
EOF
if [ "$VERSION" != "vUNSTABLE" ]; then
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 -e "s/[ ]*$//" rendered.md
} > ../content/changelog/$FILENAME