Skip to content

Commit 9e396cf

Browse files
jeremyJeremy Daer
andauthored
Diff stable release notes against the last stable tag, not the last rc (#598)
goreleaser's github-native changelog asks GitHub to generate notes relative to the previous tag, and goreleaser resolves that to whatever tag came last — for v0.8.0 that is v0.8.0-rc.3, which yields an empty five-line body while every real change stays stranded across the rc tags. Resolve the previous *stable* tag ourselves and hand it over via GORELEASER_PREVIOUS_TAG. The selector mirrors the idiom already used in update-nix-flake.sh:32, plus a guard against the current tag, which is itself stable and sorts first. Prereleases keep goreleaser's own detection, so rc notes still diff against the preceding rc. goreleaser#2764 asked for this natively and was closed wontfix, so the environment variable is the sanctioned route. git.ignore_tags is not an option: it would suppress rc tags as *current* too, breaking rc releases. Co-authored-by: Jeremy Daer <jeremykemper@mac.com>
1 parent 7aefeaf commit 9e396cf

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎.github/workflows/release.yml‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,21 @@ jobs:
238238
version: 'v2.15.4'
239239
install-only: true
240240

241+
- name: Resolve the previous stable tag for release notes
242+
run: |
243+
# Stable releases must diff against the last STABLE tag, not the last
244+
# rc, or the notes come out empty. Mirrors update-nix-flake.sh:32.
245+
if [[ "$GITHUB_REF_NAME" == *-* ]]; then
246+
echo "prerelease — leaving previous-tag detection to goreleaser"
247+
exit 0
248+
fi
249+
PREV=$(git tag --merged "$GITHUB_SHA" --sort=-version:refname \
250+
--list 'v[0-9]*.[0-9]*.[0-9]*' \
251+
| awk -v cur="$GITHUB_REF_NAME" '!/-/ && $0 != cur { print; exit }')
252+
[ -n "$PREV" ] || { echo "::error::no previous stable tag resolved"; exit 1; }
253+
echo "Release notes will diff against $PREV"
254+
echo "GORELEASER_PREVIOUS_TAG=$PREV" >> "$GITHUB_ENV"
255+
241256
- name: Run GoReleaser
242257
env:
243258
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)