chore: add changelog generator

This commit is contained in:
jo 2022-07-11 12:39:56 +02:00 committed by Kyle Robbertze
parent bdc2e92454
commit e048560910
6 changed files with 84 additions and 0 deletions

22
.chglog/CHANGELOG.md.tpl Normal file
View File

@ -0,0 +1,22 @@
{{ range .Versions }}<a name="{{ .Tag.Name }}"></a>
## {{ if .Tag.Previous }}[{{ .Tag.Name }}]({{ $.Info.RepositoryURL }}/compare/{{ .Tag.Previous.Name }}...{{ .Tag.Name }}){{ else }}{{ .Tag.Name }}{{ end }} ({{ datetime "2006-01-02" .Tag.Date }})
- [Release note](https://libretime.org/docs/releases/{{ .Tag.Name }}/)
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range reverse .Commits -}}
- {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }}
{{ end }}
{{ end -}}
{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
- {{ .Revert.Header }}
{{ end }}
{{ end -}}
{{ end -}}

25
.chglog/config.yml Normal file
View File

@ -0,0 +1,25 @@
style: github
template: CHANGELOG.md.tpl
info:
title: CHANGELOG
repository_url: https://github.com/libretime/libretime
options:
commits:
filters:
Type: [feat, fix, docs, test, ci]
sort_by: Date
commit_groups:
title_maps:
feat: Features
fix: Bug Fixes
docs: Documentation
test: Tests
ci: CI
sort_by: Custom
title_order: [feat, fix, docs, test, ci]
header:
pattern: "^(\\w*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$"
pattern_maps:
- Type
- Scope
- Subject

0
CHANGELOG.md Normal file
View File

View File

@ -19,6 +19,9 @@ shell-check:
VERSION: VERSION:
tools/version.sh tools/version.sh
changelog:
tools/changelog.sh
.PHONY: tarball .PHONY: tarball
tarball: VERSION tarball: VERSION
$(MAKE) -C legacy build $(MAKE) -C legacy build

View File

@ -152,6 +152,15 @@ git show --quiet
git tag -a -m "$VERSION" "$VERSION" git tag -a -m "$VERSION" "$VERSION"
``` ```
Generate the changelog for the newly tagged version:
```bash
make changelog
git add .
git commit -m "chore: generate changelog for $VERSION"
```
Push the tag upstream to finalize the release process: Push the tag upstream to finalize the release process:
```bash ```bash

25
tools/changelog.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
set -u
error() {
echo >&2 "error: $*"
exit 1
}
command -v git > /dev/null || error "git command not found!"
command -v git-chglog > /dev/null || error "git-chglog command not found!"
changelog="CHANGELOG.md"
tag="${tag:-$(git describe --abbrev=0 --tags || error "could not extract latest tag")}"
if grep --quiet "<a name=\"$tag\"></a>" "$changelog"; then
error "changelog has already been generated for tag $tag!"
fi
cat <(git-chglog "$tag") "$changelog" > "$changelog.tmp"
mv "$changelog.tmp" "$changelog"
if command -v npx > /dev/null; then
npx prettier --write "$changelog"
fi