Merge pull request #199 from github/generate-changelog

Generate changelog on release
This commit is contained in:
Mislav Marohnić 2020-01-08 17:15:06 +01:00 committed by GitHub
commit 1f2277cdd3
4 changed files with 24 additions and 8 deletions

View file

@ -16,11 +16,13 @@ jobs:
uses: actions/setup-go@v1
with:
go-version: 1.13
- name: Generate changelog
run: script/changelog | tee CHANGELOG.md
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release
args: release --release-notes=CHANGELOG.md
env:
GH_OAUTH_CLIENT_ID: 178c6fc778ccc68e1d6a
GH_OAUTH_CLIENT_SECRET: ${{secrets.OAUTH_CLIENT_SECRET}}

1
.gitignore vendored
View file

@ -4,3 +4,4 @@
/dist
/site
.github/**/node_modules
/CHANGELOG.md

View file

@ -39,10 +39,3 @@ nfpms:
formats:
- deb
- rpm
changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

20
script/changelog Executable file
View file

@ -0,0 +1,20 @@
#!/bin/bash
set -e
current_tag="${GITHUB_REF#refs/tags/}"
start_ref="HEAD"
# Find the previous release on the same branch, skipping prereleases if the
# current tag is a full release
previous_tag=""
while [[ -z $previous_tag || ( $previous_tag == *-* && $current_tag != *-* ) ]]; do
previous_tag="$(git describe --tags "$start_ref"^ --abbrev=0)"
start_ref="$previous_tag"
done
git log "$previous_tag".. --reverse --merges --oneline --grep='Merge pull request #' | \
while read -r sha title; do
pr_num="$(grep -o '#[[:digit:]]\+' <<<"$title")"
pr_desc="$(git show -s --format=%b "$sha" | sed -n '1,/^$/p' | tr $'\n' ' ')"
printf "* %s %s\n\n" "$pr_desc" "$pr_num"
done