Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/scripts/merge-change-log-after-release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash -e

# this script merges release notes for $VERSION into CHANGELOG.md
# the release date for $VERSION should be available in $RELEASE_DATE
# and the release notes for $VERSION should be available in /tmp/changelog-section.md

if [[ $VERSION =~ ^[0-9]+\.[0-9]+\.0 ]]; then
# this was not a patch release, so the version exists already in the CHANGELOG.md

# update the release date
sed -Ei "s/## Version $VERSION .*/## Version $VERSION ($RELEASE_DATE)/" CHANGELOG.md

# the entries are copied over from the release branch to support workflows
# where change log entries may be updated after preparing the release branch

{
# copy the portion above the release, up to and including the heading
sed -n "0,/^## Version $VERSION /p" CHANGELOG.md
# copy the release notes for $VERSION
cat /tmp/changelog-section.md
# copy the portion below the release
sed -n "0,/^## Version $VERSION /d;0,/^## Version /{/^## Version/!d};p" CHANGELOG.md
} > /tmp/CHANGELOG.md

# update the real CHANGELOG.md
cp /tmp/CHANGELOG.md CHANGELOG.md

else
# this was a patch release, so the version does not exist already in the CHANGELOG.md

{
# copy the portion above the top-most release, not including the heading
sed -n "0,/^## Version /{ /^## Version /!p }" CHANGELOG.md
# add the heading
echo "## Version $VERSION ($RELEASE_DATE)"
# copy the release notes for $VERSION
cat /tmp/changelog-section.md
# copy the portion starting from the top-most release
sed -n "/^## Version /,\$p" CHANGELOG.md
} > /tmp/CHANGELOG.md

# update the real CHANGELOG.md
cp /tmp/CHANGELOG.md CHANGELOG.md
Comment on lines +42 to +43
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this could be factored out of the if/else and just exist after.

Copy link
Member Author

@trask trask Jun 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point I'd prefer to keep these files in sync since they're in multiple repos

fi
Loading