Skip to content

Commit

Permalink
Generate changelog on release
Browse files Browse the repository at this point in the history
The changelog is generated using the git log of pull request merges
since the last tagged release, and is in the following format:

    * {PR title} #{PR number}
  • Loading branch information
mislav committed Jan 7, 2020
1 parent ad6167d commit 2271f4c
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
/dist
/site
.github/**/node_modules
/CHANGELOG.md
7 changes: 0 additions & 7 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,3 @@ nfpms:
formats:
- deb
- rpm

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"
20 changes: 20 additions & 0 deletions script/changelog
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2271f4c

Please sign in to comment.