fix: ensure release notes diff with temp tags (#742)

## ℹ️ Description
*Provide a concise summary of the changes introduced in this pull
request.*

- Link to the related issue(s): N/A
- Describe the motivation and context for this change.
- Fix empty release notes when using moving `latest`/`preview` tags by
diffing two short‑lived tags.
- Remove the generated “Full Changelog” link because temporary tags are
deleted after notes generation.

## 📋 Changes Summary

- Generate release notes using a temp prev tag and a temp head tag to
ensure old → new comparisons.
- Clean up temp tags after notes generation to keep tags tidy.
- Strip the “Full Changelog” line to avoid broken compare links.

### ⚙️ Type of Change
Select the type(s) of change(s) included in this pull request:
- [x] 🐞 Bug fix (non-breaking change which fixes an issue)
- [ ]  New feature (adds new functionality without breaking existing
usage)
- [ ] 💥 Breaking change (changes that might break existing user setups,
scripts, or configurations)


##  Checklist
Before requesting a review, confirm the following:
- [x] I have reviewed my changes to ensure they meet the project's
standards.
- [ ] I have tested my changes and ensured that all tests pass (`pdm run
test`).
- [ ] I have formatted the code (`pdm run format`).
- [ ] I have verified that linting passes (`pdm run lint`).
- [x] I have updated documentation where necessary.

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
This commit is contained in:
Jens
2025-12-20 21:12:15 +01:00
committed by GitHub
parent 767871dca4
commit c0a144fadc

View File

@@ -469,9 +469,13 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
# We reuse the "latest"/"preview" tag, therefore GitHub's generate-notes must be anchored # We reuse the moving "latest"/"preview" tags for releases. GitHub's generate-notes compares
# to a different tag name pointing at the previous channel release commit. Use a temporary # tag_name -> previous_tag_name, so using the moving tag as tag_name would compare old -> old
# tag and delete it afterwards to avoid accumulating tags. # (because the tag hasn't moved yet) and returns empty notes.
# To keep tags clean and avoid new permanent tags, we create two short-lived tags:
# - one on the previous release commit
# - one on the new release commit
# Then we diff temp-new -> temp-prev and delete both tags.
if ! PREVIOUS_RELEASE_SHA=$(gh release view "$RELEASE_NAME" --json targetCommitish --jq '.targetCommitish' 2>/dev/null); then if ! PREVIOUS_RELEASE_SHA=$(gh release view "$RELEASE_NAME" --json targetCommitish --jq '.targetCommitish' 2>/dev/null); then
echo "ERROR: Failed to query existing '$RELEASE_NAME' release; cannot generate release notes." >&2 echo "ERROR: Failed to query existing '$RELEASE_NAME' release; cannot generate release notes." >&2
exit 1 exit 1
@@ -482,9 +486,11 @@ jobs:
fi fi
TEMP_PREV_TAG="${RELEASE_NAME}-prev-${GITHUB_RUN_ID}" TEMP_PREV_TAG="${RELEASE_NAME}-prev-${GITHUB_RUN_ID}"
TEMP_HEAD_TAG="${RELEASE_NAME}-head-${GITHUB_RUN_ID}"
cleanup() { cleanup() {
git push --delete origin "$TEMP_PREV_TAG" >/dev/null 2>&1 || true # Best-effort cleanup; don't fail the job if cleanup fails.
git tag -d "$TEMP_PREV_TAG" >/dev/null 2>&1 || true git push --delete origin "$TEMP_PREV_TAG" "$TEMP_HEAD_TAG" >/dev/null 2>&1 || true
git tag -d "$TEMP_PREV_TAG" "$TEMP_HEAD_TAG" >/dev/null 2>&1 || true
} }
trap cleanup EXIT trap cleanup EXIT
@@ -494,20 +500,30 @@ jobs:
git fetch --no-tags origin "${PREVIOUS_RELEASE_SHA}" git fetch --no-tags origin "${PREVIOUS_RELEASE_SHA}"
fi fi
# Ensure the temporary tag exists for generate-notes diffing # Ensure both temporary tags exist for generate-notes diffing.
git tag -f "$TEMP_PREV_TAG" "$PREVIOUS_RELEASE_SHA" git tag -f "$TEMP_PREV_TAG" "$PREVIOUS_RELEASE_SHA"
git tag -f "$TEMP_HEAD_TAG" "$GITHUB_SHA"
git push --force origin "refs/tags/${TEMP_PREV_TAG}" git push --force origin "refs/tags/${TEMP_PREV_TAG}"
git push --force origin "refs/tags/${TEMP_HEAD_TAG}"
echo "Using temp tags: prev=${TEMP_PREV_TAG} (${PREVIOUS_RELEASE_SHA}), head=${TEMP_HEAD_TAG} (${GITHUB_SHA})"
# 1) Prefer GitHub's generate-notes API so we get PR links and @mentions # 1) Prefer GitHub's generate-notes API so we get PR links and @mentions
ARGS=(-X POST "repos/${GITHUB_REPOSITORY}/releases/generate-notes" -f tag_name="$RELEASE_NAME" -f target_commitish="$GITHUB_SHA") gh api -X POST "repos/${GITHUB_REPOSITORY}/releases/generate-notes" \
ARGS+=(-f previous_tag_name="$TEMP_PREV_TAG") -f tag_name="$TEMP_HEAD_TAG" \
gh api "${ARGS[@]}" --jq '.body' > release-notes.md -f target_commitish="$GITHUB_SHA" \
-f previous_tag_name="$TEMP_PREV_TAG" \
--jq '.body' > release-notes.md
if ! grep -q '[^[:space:]]' release-notes.md; then if ! grep -q '[^[:space:]]' release-notes.md; then
echo "ERROR: GitHub generate-notes returned an empty body." >&2 echo "ERROR: GitHub generate-notes returned an empty body." >&2
exit 1 exit 1
fi fi
# Remove the "Full Changelog" line to avoid broken links from temp tags.
sed -E -i.bak '/^\*\*Full Changelog\*\*:/d' release-notes.md
rm -f release-notes.md.bak
printf "\n%s\n" "$LEGAL_NOTICE" >> release-notes.md printf "\n%s\n" "$LEGAL_NOTICE" >> release-notes.md