Skip to content

Commit dc1a568

Browse files
authored
fix: populate the release notes when the release is created (#8799)
Use the contents of the commit message from the commit associated with the tag (that contains the version bump) as the release notes by writing them to a file and then specifying the file as the `body_path` of `softprops/action-gh-release@v2`.
1 parent 54ded1a commit dc1a568

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

.github/workflows/rust-release.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,26 @@ jobs:
323323
- name: Checkout repository
324324
uses: actions/checkout@v6
325325

326+
- name: Generate release notes from tag commit message
327+
id: release_notes
328+
shell: bash
329+
run: |
330+
set -euo pipefail
331+
332+
# On tag pushes, GITHUB_SHA may be a tag object for annotated tags;
333+
# peel it to the underlying commit.
334+
commit="$(git rev-parse "${GITHUB_SHA}^{commit}")"
335+
notes_path="${RUNNER_TEMP}/release-notes.md"
336+
337+
# Use the commit message for the commit the tag points at (not the
338+
# annotated tag message).
339+
git log -1 --format=%B "${commit}" > "${notes_path}"
340+
# Ensure trailing newline so GitHub's markdown renderer doesn't
341+
# occasionally run the last line into subsequent content.
342+
echo >> "${notes_path}"
343+
344+
echo "path=${notes_path}" >> "${GITHUB_OUTPUT}"
345+
326346
- uses: actions/download-artifact@v7
327347
with:
328348
path: dist
@@ -395,6 +415,7 @@ jobs:
395415
with:
396416
name: ${{ steps.release_name.outputs.name }}
397417
tag_name: ${{ github.ref_name }}
418+
body_path: ${{ steps.release_notes.outputs.path }}
398419
files: dist/**
399420
# Mark as prerelease only when the version has a suffix after x.y.z
400421
# (e.g. -alpha, -beta). Otherwise publish a normal release.

0 commit comments

Comments
 (0)