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

View file

@ -1,90 +0,0 @@
{{/*
This template is used to render the set of changes in the changelog page.
It expects to find a directory "changelogs" containing a subdirectory for
each of the 5 APIs in the specification. Inside each of these directories
it expects to find newsfragments describing changes to that API.
If the `version.status` setting in config.toml is anything other than
"unstable", then it also expects to find additional settings under
`version` in config.toml:
- `major`: the major version number of the release
- `minor`: the minor version number of the release
- `release_date`: the date of the release
The release tag is calculated as `v<major>.<minor>`; for example `v1.5`.
It then renders this into a table displayed before the list of changes.
*/}}
{{ $path := path.Join "changelogs" }}
{{ $status := .Site.Params.version.status }}
{{ $release_tag := delimit (slice "v" .Site.Params.version.major "." .Site.Params.version.minor) "" }}
{{ if ne $status "unstable" }}
<table class="release-info">
<tr><th>Git commit</th><td><a href="https://github.com/matrix-org/matrix-spec/tree/{{ $release_tag }}">https://github.com/matrix-org/matrix-spec/tree/{{ $release_tag }}</a></td>
<tr><th>Release date</th><td>{{ .Site.Params.version.release_date }}</td>
</table>
{{ end }}
<h2 id=api-changes>Changes since last release</h2>
{{ partial "render-api-changes" (dict "title" "Client-Server API" "id" "client-server-api" "path" (path.Join $path "client_server")) }}
{{ partial "render-api-changes" (dict "title" "Server-Server API" "id" "server-server-api" "path" (path.Join $path "server_server")) }}
{{ partial "render-api-changes" (dict "title" "Application Service API" "id" "application-service-api" "path" (path.Join $path "application_service")) }}
{{ partial "render-api-changes" (dict "title" "Identity Service API" "id" "identity-service-api" "path" (path.Join $path "identity_service")) }}
{{ partial "render-api-changes" (dict "title" "Push Gateway API" "id" "push-gateway-api" "path" (path.Join $path "push_gateway")) }}
{{ partial "render-api-changes" (dict "title" "Room Versions" "id" "room-versions" "path" (path.Join $path "room_versions")) }}
{{ partial "render-api-changes" (dict "title" "Appendices" "id" "appendices" "path" (path.Join $path "appendices")) }}
{{ partial "render-api-changes" (dict "title" "Internal Changes/Tooling" "id" "internal" "path" (path.Join $path "internal")) }}
{{ define "partials/render-api-changes" }}
<h3 id="{{.id}}">{{ .title }}</h3>
{{ $api_path := .path }}
{{ $config_file := path.Join $api_path ".." "pyproject.toml" }}
{{ $config := readFile $config_file | transform.Unmarshal }}
{{ $news_path := path.Join $api_path "newsfragments" }}
{{ partial "render-newsfragments" (dict "config" $config "news_path" $news_path )}}
{{ end }}
{{ define "partials/render-newsfragments" }}
{{ $config := .config }}
{{ $news_path := .news_path }}
{{ $types := dict }}
{{ range $config.tool.towncrier.type }}
{{ $types = merge $types (dict .directory (slice)) }}
{{ end }}
{{ range (readDir $news_path) }}
{{ $pieces := split .Name "." }}
{{ $ticket := index $pieces 0 }}
{{ $description := readFile (path.Join $news_path .Name ) }}
{{ $change_info := (dict "ticket" $ticket "description" $description )}}
{{ $type := index $pieces 1 }}
{{ $instances := index $types $type }}
{{ $instances = $instances | append $change_info }}
{{ $types = merge $types (dict $type $instances) }}
{{ end }}
<ul>
{{ range $config.tool.towncrier.type }}
{{ $changes_of_type := (index $types .directory) }}
{{ if $changes_of_type }}
<li>{{.name | safeHTML}}
<p><ul>
{{ range $changes_of_type }}
<li><a href="https://github.com/matrix-org/matrix-spec/issues/{{.ticket}}"><strong>{{ .ticket }}: </strong></a>{{ .description | markdownify }}</li>
{{ end }}
</ul></p>
</li>
{{ end }}
{{ end }}
</ul>
{{ end }}

View file

@ -1,2 +0,0 @@
{{ $partial := .Params.p }}
{{ partial $partial . }}

View file

@ -0,0 +1,10 @@
{{/*
This template is used to render all of the changelog sections under
"content/changelogs"
*/}}
{{ with .Page.Resources.Match "*.md" }}
{{ range ((sort . "Params.date" "desc")) }}
{{ .Content }}
{{ end }}
{{ end }}