Generate changelog with semantic-release#963
Merged
shawnbot merged 7 commits intorelease-14.0.0from Nov 5, 2019
Merged
Conversation
|
This pull request is being automatically deployed with ZEIT Now (learn more). 🔍 Inspect: https://zeit.co/primer/primer-css/g9xfr863j |
simurai
reviewed
Oct 28, 2019
Contributor
simurai
left a comment
There was a problem hiding this comment.
The output looks pretty good. ✨ Like hand made.
Contributor
Author
|
Let's test this out on the 14.0 release! |
This was referenced Dec 13, 2022
This was referenced Jan 2, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a script that uses semantic-release under the hood to generate the next release's changelog entry. I couldn't figure out how to work with any of the existing semantic-release plugins, so (natch) I wrote my own that implements two "steps":
analyzeCommits()gets a list of commits (fromsemantic-release🎉), finds the merge commits that reference PR numbers, grabs the corresponding PR data from the GitHub API, and looks at the labels for each to determine which, if any:This function then returns the release type (major, minor, or patch — I haven't tested the noop case yet) for semantic-release to manage.
generateNotes()gets the same list of commits, figures out which ones were marked as relevant merge commits in the previous step (and which grouping they belong to), then generates a hunk of raw Markdown text to drop into the changelog.Caveats
I thought that I could get away with stashing the metadata on the commit objects in the first step, but it wasn't available in the second one. I tried using a WeakMap for the metadata (
map.set(commit, metadata)), but none of the commit objects in the second step were found in the map. This suggests that the objects are being recreated (or deep copied?) in between steps, but I'd need to look closer at the source to know for sure.Anyway, sharing state with in a Map by commit SHA feels icky, but it works and the keys are guaranteed unique, so 🤷♂
It would probably be better to generate the changelog Markdown using an AST builder like remark.
Without further ado, here's the output, copied from this actions run:
13.2.0
🚀 Enhancements
🐛 Bug fixes
📝 Documentation
🏠 Internal
Committers