From 4c0e4fc1d320c54cdd5aabf3fa8be2721eb94c0b Mon Sep 17 00:00:00 2001 From: Pekka Nurmi Date: Mon, 20 Nov 2023 16:20:01 +0200 Subject: [PATCH] chore(release): autogenerate release notes (#98) --- .github/workflows/release.yaml | 5 ++++- .gitignore | 2 ++ Makefile | 10 ++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 45a7170c..3b89bb96 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -20,11 +20,14 @@ jobs: with: go-version: '1.20' + - name: Get release notes + run: make release-notes > .release_notes + - name: Create release uses: goreleaser/goreleaser-action@v4 with: distribution: goreleaser version: latest - args: -f .goreleaser.yaml release --clean + args: -f .goreleaser.yaml release --clean --release-notes=.release_notes env: GITHUB_TOKEN: ${{ secrets.GH_PAT }} diff --git a/.gitignore b/.gitignore index 58104c88..0b7578fd 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ temp/ .DS_Store vendor/ dist/ +# Generated release notes +.release_notes diff --git a/Makefile b/Makefile index 213899cd..b0a89f5b 100644 --- a/Makefile +++ b/Makefile @@ -44,3 +44,13 @@ build-plugin: .PHONY: build build: build-plugin + +.PHONY: release-notes +release-notes: CHANGELOG_HEADER = ^\#\# \[ +release-notes: CHANGELOG_VERSION = $(subst v,,$(TAG)) +release-notes: + @awk \ + '/${CHANGELOG_HEADER}${CHANGELOG_VERSION}/ { flag = 1; next } \ + /${CHANGELOG_HEADER}/ { if ( flag ) { exit; } } \ + flag { if ( n ) { print prev; } n++; prev = $$0 }' \ + CHANGELOG.md