Skip to content
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

Merged
merged 1 commit into from
Mar 8, 2024

Conversation

camscale
Copy link
Contributor

@camscale camscale commented Mar 6, 2024

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.


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.

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.
@camscale camscale added the no-changelog Indicates that a PR does not require a changelog entry label Mar 6, 2024
@camscale camscale requested review from fheinecke, r0mant and tcsc March 6, 2024 21:41
@github-actions github-actions bot requested review from bl-nero and jakule March 6, 2024 21:41
DATE=$(git show -s --date=format:'%Y-%m-%dT%H:%M:%S%z' --format=%cd $COMMIT)
gh pr list \
--search "${gh_query}" \
--limit 200 \
Copy link
Contributor

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}"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

@camscale camscale Mar 12, 2024

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")
Copy link
Contributor

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. :)

Copy link
Contributor Author

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='
Copy link
Contributor

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.

@r0mant r0mant added this pull request to the merge queue Mar 8, 2024
Merged via the queue into master with commit e7d829e Mar 8, 2024
38 checks passed
@r0mant r0mant deleted the camh/spiffy-changelog-generation branch March 8, 2024 17:49
@public-teleport-github-review-bot

@camscale See the table below for backport results.

Branch Result
branch/v13 Create PR
branch/v14 Failed
branch/v15 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants