chore: Automate changelog generation [skip ci]

This commit is contained in:
Martin Wentzel 2022-07-14 15:36:05 +02:00
parent bce9b6b17d
commit 08eed6e9cd
4 changed files with 117 additions and 5 deletions

38
.chglog/CHANGELOG.tpl.md Executable file
View file

@ -0,0 +1,38 @@
{{ 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 }})
{{ range .CommitGroups -}}
### {{ .Title }}
{{ range .Commits -}}
* {{ .Subject }}
{{ end }}
{{ end -}}
{{- if .RevertCommits -}}
### Reverts
{{ range .RevertCommits -}}
* {{ .Revert.Header }}
{{ end }}
{{ end -}}
{{- if .MergeCommits -}}
### Pull Requests
{{ range .MergeCommits -}}
* {{ .Header }}
{{ end }}
{{ end -}}
{{- if .NoteGroups -}}
{{ range .NoteGroups -}}
### {{ .Title }}
{{ range .Notes }}
{{ .Body }}
{{ end }}
{{ end -}}
{{ end -}}
{{ end -}}

27
.chglog/config.yml Executable file
View file

@ -0,0 +1,27 @@
style: github
template: CHANGELOG.tpl.md
info:
title: CHANGELOG
repository_url: https://github.com/kreuzwerker/terraform-provider-docker
options:
commits:
# filters:
# Type:
# - feat
# - fix
# - perf
# - refactor
commit_groups:
# title_maps:
# feat: Features
# fix: Bug Fixes
# perf: Performance Improvements
# refactor: Code Refactoring
header:
pattern: "^(\\w*)\\:\\s(.*)$"
pattern_maps:
- Type
- Subject
notes:
keywords:
- BREAKING CHANGE

View file

@ -28,6 +28,8 @@ Prerequisites:
- [Go 1.16+](https://golang.org/doc/install)
- [Docker](https://www.docker.com/)
- [Terraform 0.12+](https://terraform.io/)
- [git-chglog](https://github.com/git-chglog/git-chglog)
- [svu](https://github.com/caarlos0/svu)
Clone `terraform-provider-docker` anywhere:
@ -183,8 +185,16 @@ Push your branch to your `terraform-provider-docker` fork and open a
pull request against the master branch.
## Releasing
- Update the `CHANGELOG.md` by hand by [comparing](https://github.com/kreuzwerker/terraform-provider-docker/compare/v2.11.0...master) with the latest release, e.g. `v2.11.0` or via the `cli` with the command `git log v2.11.0..HEAD --oneline`
- Replace all occurrences of the latest release, e.g. `2.11.0` with the new one, e.g. `2.12.2`, except in the files `CHANGELOG.md`, `CONTRIBUTING.md`, `docs/**/*`
- regenerate the website: `make website-generation`
- commit the changes: `chore: prepare release v2.12.0`
- run `git tag v2.12.2 && git push origin master v2.12.2`
Run one of the following commands (depending on the semver version you want to release):
```sh
make patch
make minor
make major
```
Those commands will automatically:
- Replace all occurrences of the latest release, e.g. `2.11.0` with the new one, e.g. `2.12.0`: ``
- Generate the `CHANGELOG.md`
- Regenerate the website (`make website-generation`)

View file

@ -92,3 +92,40 @@ website-lint-fix:
.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile website-link-check website-lint website-lint-fix
chlog-%:
@echo "Generating CHANGELOG.md"
git-chglog --next-tag $* -o CHANGELOG.md
@echo "Version updated to $*!"
@echo
@echo "Review the changes made by this script then execute the following:"
replace-occurences-%:
@echo "Replace occurences of old version strings..."
sed -i '' "s/$(shell (svu --strip-prefix current))/$*/g" README.md docs/index.md examples/provider/provider-tf12.tf examples/provider/provider-tf13.tf
release-%:
@echo "Review the changes made by this script then execute the following:"
@${MAKE} website-generation
@echo "Review the changes made by this script then execute the following:"
@echo
@echo "git add CHANGELOG.md README.md docs/index.md examples/provider/provider-tf12.tf examples/provider/provider-tf13.tf && git commit -m 'Prepare release $*' && git tag -m 'Release $*' ${TAG_PREFIX}$*"
@echo
@echo "Finally, push the changes:"
@echo
@echo "git push; git push origin ${TAG_PREFIX}$*"
patch:
@${MAKE} chlog-$(shell (svu patch))
@${MAKE} replace-occurences-$(shell (svu --strip-prefix patch))
@${MAKE} release-$(shell (svu patch))
minor:
@${MAKE} chlog-$(shell (svu minor))
@${MAKE} replace-occurences-$(shell (svu --strip-prefix minor))
@${MAKE} release-$(shell (svu patch))
major:
@${MAKE} chlog-$(shell (svu major))
@${MAKE} replace-occurences-$(shell (svu --strip-prefix major))
@${MAKE} release-$(shell (svu patch))