build(release): compare final changelog against previous stable tag

This commit is contained in:
alphago9
2026-03-31 16:38:49 +08:00
parent 49f86b5d8f
commit 32ac0106e0
2 changed files with 23 additions and 1 deletions
+22
View File
@@ -41,6 +41,28 @@ jobs:
with: with:
go-version-file: src/go.mod go-version-file: src/go.mod
- name: Select Previous Stable Tag For Final Releases
run: |
current_tag="${GITHUB_REF_NAME}"
if [[ "$current_tag" == *-* ]]; then
echo "prerelease tag detected: $current_tag"
exit 0
fi
previous_stable_tag="$(
git tag --list 'v*' --sort=-version:refname |
grep -Fxv "$current_tag" |
grep -Ev -- '-' |
head -n 1
)"
if [[ -n "$previous_stable_tag" ]]; then
echo "using previous stable tag: $previous_stable_tag"
echo "GORELEASER_PREVIOUS_TAG=$previous_stable_tag" >> "$GITHUB_ENV"
else
echo "no previous stable tag found"
fi
- name: Run GoReleaser - name: Run GoReleaser
uses: goreleaser/goreleaser-action@v7 uses: goreleaser/goreleaser-action@v7
with: with:
+1 -1
View File
@@ -67,4 +67,4 @@ The resulting artifacts will be generated under `src/dist/`.
If you use tags like `v1.2.3-rc1`, GoReleaser will mark the GitHub release as a prerelease. If you use tags like `v1.2.3-rc1`, GoReleaser will mark the GitHub release as a prerelease.
If you want the final `v1.2.3` release notes to compare cleanly against the previous stable release, avoid keeping old `rc` tags around longer than needed. For a final tag like `v1.2.3`, the release workflow forces GoReleaser to compare against the previous stable tag instead of the latest `rc` tag. This keeps the final changelog focused on stable-to-stable changes.