-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
release: Add new changelog generation script #39046
Conversation
Add a new `changelog.sh` script that has a couple of nice features over the old one: * Can run from the base release branch without args and it generates a changelog since the last release. The base branch and tag are still overrideable though if you need to * Handles multiple changelog entries on one PR which can occasionally happen. * Cleans up the changelog entries a little (trailing period, cleans whitespace). * Marks entries that did not have a changelog where the PR title was used. These need to be checked and likely re-written. * Extracts enterprise changelogs. The primary use case is to be able to run and re-run it easily as you tweak the changelog entries on the PRs so you get a final generation run that needs no changes to the changelog itself. It is also easy to update the changelog if new PRs have been merged into the base branch before the release PR was able to be merged.
DATE=$(git show -s --date=format:'%Y-%m-%dT%H:%M:%S%z' --format=%cd $COMMIT) | ||
gh pr list \ | ||
--search "${gh_query}" \ | ||
--limit 200 \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make this limitation documented? It's not explicitly spelled out in the Makefile or anywhere else.
--search "${gh_query}" \ | ||
--limit 200 \ | ||
--json number,url,title,body | | ||
"${JQ}" -r "${jq_expr}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that gh
has a built-in --jq
argument. I assume it's probably easier to trust an external implementation to deal with that complex script above, though, so up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I should use that and remove all that prerequisites cruft. I'll rev it. Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, regarding the inbuilt jq
evaluator in gh
, I'll bet that it is just using gojq
under the covers and that is a faithful reimplementation of jq (except map ordering which has Go's random ordering), so I expect --jq
should work fine.
map(promote_title) | | ||
map(flatten_changes) | | ||
map(as_entry) | | ||
join("\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, we are balancing on a thin line between sanity and using esoteric programming languages here. It's still probably better than using Perl, though. ;)
I guess it's inevitable, I myself don't see a better way to do it, but just wanted to let you know that now I understand why you wanted to rewrite this entire thing in Go. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was my personal changelog script that I was requested to add to the repo, so you all get it in its obtuse glory.
I want to make this do more - such as traversing backport PRs back to the original to get the changelog entry from there, and at that point I'm certainly not doing it in shell/jq. The current version at least has the simplicity of an immutable single pipeline - a github query gives a stream of PR details as json which is processed one at a time to transform into a set of changelog entries. Once we start querying other PRs in the middle of this, it's time for some proper code.
|
||
COMMIT=$(git rev-list -n 1 v$BASE_TAG) | ||
# shellcheck disable=SC2016 # We're not trying to expand in single quotes | ||
jq_expr=' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please explain what this thing is doing? Maybe even add an example input and output? I cannot imagine trying to fix or update this expression without any context.
Add a new
changelog.sh
script that has a couple of nice features overthe old one:
changelog since the last release. The base branch and tag are still
overrideable though if you need to
happen.
whitespace).
used. These need to be checked and likely re-written.
The primary use case is to be able to run and re-run it easily as you
tweak the changelog entries on the PRs so you get a final generation run
that needs no changes to the changelog itself. It is also easy to update
the changelog if new PRs have been merged into the base branch before
the release PR was able to be merged.
This is a cleanup of my personal changelog script I've been using. I've
manually tested it with multiple scenarios, and fixed the bug that
allowed an Enterprise changelog entry through that was not actually in
the release.
I don't really intend to rev this any more. The next version will be
written in Go and it will likely automatically insert the changelog into
CHANGELOG.md, replacing the existing one if it is being revved as
another step towards entirely automating the release process.