Skip to content

Commit

Permalink
Auto-link to change log section on release [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
brunchboy committed Feb 26, 2024
1 parent 32f307e commit 4bdde0a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/resources/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@

## What’s in the Release

✨Summary to be added once James has a moment! Please see the [Change Log](https://github.com/Deep-Symmetry/beat-link-trigger/blob/main/CHANGELOG.md#730---2023-11-24) for all the details.
✨Summary to be added once James has a moment! Please see the [Change Log](https://github.com/Deep-Symmetry/beat-link-trigger/blob/main/CHANGELOG.md#LINK-GOES-HERE) for all the details.
30 changes: 28 additions & 2 deletions .github/scripts/finish_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,37 @@ set -e # Exit if any command fails.
# See if we are creating a preview release
if [ "$release_snapshot" = true ] ; then

# Update the release information on GitHub and reflect that it is ready.
gh release edit latest-preview --title "$release_tag preview" --notes-file .github/resources/preview_notes.md

else

gh release edit "$release_tag" --prerelease=false --latest --title "$release_tag" \
--notes-file .github/resources/release_notes.md
# Look for the heading in the change log corresponding to this version
pattern="^## \\[${git_version//\./\\.}\\]"
if grep "$pattern" CHANGELOG.md >_header.md ; then

# Extract the release date from that heading so we can build a link to the release notes.
rel_date=`sed 's/.* - //' <_header.md`
link="#${git_version//\./}---$rel_date"

# Update the release note template to use the correct link
sed "s/#LINK-GOES-HERE/$link/" .github/resources/release_notes.md > _release_notes.md

else

# Log a workflow warning reporting that this release could not be found in the change log.
echo "::warning file=CHANGELOG.md,title=Unable to link from release notes.::No heading for release $git_version found"

# Update the release note template to link to the top of the file
sed "s/#LINK-GOES-HERE//" .github/resources/release_notes.md > _release_notes.md

fi

# Update the release information on GitHub and reflect that it is ready.
gh release edit "$release_tag" --prerelease=false --latest --title "$release_tag" --notes-file _release_notes.md

# Clean up our temporary files
rm -f _header.md
rm -f _release_notes.md

fi

0 comments on commit 4bdde0a

Please sign in to comment.