Generate release notes using the new API

https://docs.github.com/en/rest/reference/repos#generate-release-notes-content-for-a-release
This commit is contained in:
Mislav Marohnić 2021-10-13 20:51:37 +02:00
parent 78ac77180e
commit 1464a8a0f3
3 changed files with 10 additions and 28 deletions

View file

@ -16,10 +16,15 @@ jobs:
with:
go-version: 1.16
- name: Generate changelog
id: changelog
run: |
echo "GORELEASER_CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
git fetch --unshallow
script/changelog | tee CHANGELOG.md
echo "::set-output name=tag-name::${GITHUB_REF#refs/tags/}"
gh api repos/$GITHUB_REPOSITORY/releases/generate-notes \
-f tag_name="${GITHUB_REF#refs/tags/}" \
-f target_commitish=trunk \
-q .body > CHANGELOG.md
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
@ -27,6 +32,7 @@ jobs:
args: release --release-notes=CHANGELOG.md
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
GORELEASER_CURRENT_TAG: ${{steps.changelog.outputs.tag-name}}
- name: Checkout documentation site
uses: actions/checkout@v2
with:

View file

@ -1,6 +1,6 @@
# Releasing
Our build system automatically compiles and attaches cross-platform binaries to any git tag named `vX.Y.Z`. The automated changelog is generated from commit messages starting with “Merge pull request …” that landed between this tag and the previous one (as determined topologically by git).
Our build system automatically compiles and attaches cross-platform binaries to any git tag named `vX.Y.Z`. The changelog is [generated from git commit log](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes).
Users who run official builds of `gh` on their machines will get notified about the new version within a 24 hour period.

View file

@ -1,24 +0,0 @@
#!/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 --first-parent --oneline | \
while read -r sha title; do
if [[ $title == "Merge pull request #"* ]]; then
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"
else
printf "* %s\n\n" "$title"
fi
done