diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 45a7170..3b89bb9 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 58104c8..0b7578f 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 213899c..b0a89f5 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