From cf383ab630e17990809180c01df43d91af282bd0 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Fri, 14 May 2021 15:01:27 +0300 Subject: [PATCH] chore: use release-tool to generate release notes Publish release notes to the GitHub release automatically. Signed-off-by: Andrey Smirnov --- .drone.yml | 2 ++ Makefile | 4 ++++ hack/chglog/CHANGELOG.tpl.md | 22 ------------------ hack/chglog/config.yml | 28 ---------------------- hack/release.sh | 20 ++++++++++++---- hack/release.toml | 45 ++++++++++++++++++++++++++++++++++++ 6 files changed, 66 insertions(+), 55 deletions(-) delete mode 100755 hack/chglog/CHANGELOG.tpl.md delete mode 100755 hack/chglog/config.yml create mode 100644 hack/release.toml diff --git a/.drone.yml b/.drone.yml index ecc5694b6..a49454263 100644 --- a/.drone.yml +++ b/.drone.yml @@ -141,6 +141,7 @@ steps: pull: always commands: - make release + - make release-notes when: event: - tag @@ -163,6 +164,7 @@ steps: draft: true files: - _out/infrastructure-sidero/*/* + note: _out/RELEASE_NOTES.md when: event: - tag diff --git a/Makefile b/Makefile index 0150dc817..341c78722 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,10 @@ metal-controller-manager: ## Build the CAPI provider container image. metal-metadata-server: ## Build the CAPI provider container image. @$(MAKE) docker-$@ TARGET_ARGS="--push=$(PUSH)" NAME="$@" +.PHONY: release-notes +release-notes: + ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG) + # Sfyra $(ARTIFACTS)/$(TALOS_RELEASE)/%: diff --git a/hack/chglog/CHANGELOG.tpl.md b/hack/chglog/CHANGELOG.tpl.md deleted file mode 100755 index e19ffdde9..000000000 --- a/hack/chglog/CHANGELOG.tpl.md +++ /dev/null @@ -1,22 +0,0 @@ -{{ range .Versions }} - -## {{ 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 -}} -* {{ if .Scope }}**{{ .Scope }}:** {{ end }}{{ .Subject }} -{{ end }} -{{ end -}} - -{{- if .NoteGroups -}} -{{ range .NoteGroups -}} -### {{ .Title }} - -{{ range .Notes }} -{{ .Body }} -{{ end }} -{{ end -}} -{{ end -}} -{{ end -}} \ No newline at end of file diff --git a/hack/chglog/config.yml b/hack/chglog/config.yml deleted file mode 100755 index c570591d5..000000000 --- a/hack/chglog/config.yml +++ /dev/null @@ -1,28 +0,0 @@ -style: github -template: CHANGELOG.tpl.md -info: - title: CHANGELOG - repository_url: https://github.com/talos-systems/sidero -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*)(?:\\(([\\w\\$\\.\\-\\*\\s]*)\\))?\\:\\s(.*)$" - pattern_maps: - - Type - - Scope - - Subject - notes: - keywords: - - BREAKING CHANGE diff --git a/hack/release.sh b/hack/release.sh index 8aa912c74..74598929e 100755 --- a/hack/release.sh +++ b/hack/release.sh @@ -2,17 +2,26 @@ set -e +RELEASE_TOOL_IMAGE="ghcr.io/talos-systems/release-tool:latest" + +function release-tool { + docker pull "${RELEASE_TOOL_IMAGE}" >/dev/null + docker run --rm -w /src -v "${PWD}":/src:ro "${RELEASE_TOOL_IMAGE}" -l -d -n -t "${1}" ./hack/release.toml +} + function changelog { if [ "$#" -eq 1 ]; then - git-chglog --output CHANGELOG.md -c ./hack/chglog/config.yml --tag-filter-pattern "^${1}" "${1}.0-alpha.0.." - elif [ "$#" -eq 0 ]; then - git-chglog --output CHANGELOG.md -c ./hack/chglog/config.yml --sort=semver + (release-tool ${1}; echo; cat CHANGELOG.md) > CHANGELOG.md- && mv CHANGELOG.md- CHANGELOG.md else echo 1>&2 "Usage: $0 changelog [tag]" exit 1 fi } +function release-notes { + release-tool "${2}" > "${1}" +} + function cherry-pick { if [ $# -ne 2 ]; then echo 1>&2 "Usage: $0 cherry-pick " @@ -42,9 +51,10 @@ then else cat <