|
4 | 4 | # |
5 | 5 | # Stamps the "## Unreleased" section in a release-notes file with a version |
6 | 6 | # and date, and extracts the section content for use in GitHub releases / email. |
| 7 | +# Also includes all commits since the last release for complete transparency. |
7 | 8 | # |
8 | 9 | # Usage: finalize-release-notes.sh <version> <file-path> |
9 | 10 | # |
@@ -86,11 +87,44 @@ NEW_HEADER="## Version ${VERSION} - ${DATE_STAMP}" |
86 | 87 |
|
87 | 88 | mv "${FILE}.tmp" "$FILE" |
88 | 89 |
|
| 90 | +# Get commits since the last release |
| 91 | +LAST_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "") |
| 92 | +COMMIT_LIST="" |
| 93 | + |
| 94 | +if [[ -n "$LAST_TAG" ]]; then |
| 95 | + echo "Fetching commits since ${LAST_TAG}..." |
| 96 | + # Get commits between last tag and HEAD, excluding merge commits and skip ci commits |
| 97 | + COMMIT_LIST=$(git log "${LAST_TAG}..HEAD" \ |
| 98 | + --no-merges \ |
| 99 | + --pretty=format:"- %s ([%h](https://github.com/${GITHUB_REPOSITORY}/commit/%H))" \ |
| 100 | + --grep="\[skip ci\]" --invert-grep \ |
| 101 | + || echo "") |
| 102 | +else |
| 103 | + echo "No previous tag found, fetching all commits..." |
| 104 | + COMMIT_LIST=$(git log \ |
| 105 | + --no-merges \ |
| 106 | + --pretty=format:"- %s ([%h](https://github.com/${GITHUB_REPOSITORY}/commit/%H))" \ |
| 107 | + --grep="\[skip ci\]" --invert-grep \ |
| 108 | + || echo "") |
| 109 | +fi |
| 110 | + |
89 | 111 | # Write the extracted section content (for GitHub release body / future email) |
90 | 112 | { |
91 | 113 | echo "$NEW_HEADER" |
92 | 114 | echo "" |
93 | | - echo "$TRIMMED" |
| 115 | + if [[ -n "$TRIMMED" ]]; then |
| 116 | + echo "$TRIMMED" |
| 117 | + echo "" |
| 118 | + fi |
| 119 | + |
| 120 | + # Add commit history if available |
| 121 | + if [[ -n "$COMMIT_LIST" ]]; then |
| 122 | + echo "---" |
| 123 | + echo "" |
| 124 | + echo "### 📝 All Changes" |
| 125 | + echo "" |
| 126 | + echo "$COMMIT_LIST" |
| 127 | + fi |
94 | 128 | } > "${FILE}.section" |
95 | 129 |
|
96 | 130 | echo "Finalized release notes for v${VERSION}" |
|
0 commit comments