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

feat(build-cli): New command transform:releaseNotes #22466

Merged
merged 27 commits into from
Sep 14, 2024

Conversation

tylerbutler
Copy link
Member

@tylerbutler tylerbutler commented Sep 11, 2024

The problem

Our goal is to automate the release process as much as possible. To that end, now that we have a release notes generator, we'd like to automatically upload those notes to the GitHub release as part of the automated release.

Unfortunately, when we generate changelogs as part of release, we consume and delete all the changesets for the release. However, we generate a markdown file with the release notes as part of the release, and that gets committed to the repo. Alas, we need the markdown to be slightly different when posted to GitHub releases, and we don't have the input changesets anymore, so we can't easily regenerate them in automation (we'd need to find the commit in which the changesets were consumed, go to the commit before, regenerate - it's not trivial).

The proposed change

Since we have the release notes files in the repo, I have created a new command, transform:releaseNotes, which takes the in-repo release notes file as input, and outputs a modified markdown file for use in the release pipeline. For example:

flub transform releaseNotes --inFile RELEASE_NOTES/2.2.0.md --outFile out.md

@github-actions github-actions bot added area: build Build related issues base: main PRs targeted against main branch labels Sep 11, 2024
Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

I saw that the pipeline changes will be reverted before merging but left a couple of comments there too.

Overall makes sense to me, but I can't "run the remark plugins in my head" to know exactly what to expect.

@@ -72,7 +72,7 @@ jobs:
with:
name: release-metadata
path: release-metadata.json
retention-days: 3
retention-days: 30
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the motivation here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had some trouble debugging since all the artifacts were gone. Now that we're releasing ~monthly, this felt like a reasonable time period to ensure there would usually be an artifact around to use for investigation/debugging. The file is also super small. Regardless, though, debugging was my main reason. Probably worth a comment.

.github/workflows/push-tag-create-release.yml Outdated Show resolved Hide resolved
.github/workflows/push-tag-create-release.yml Outdated Show resolved Hide resolved
build-tools/packages/build-cli/docs/transform.md Outdated Show resolved Hide resolved

static readonly flags = {
inFile: Flags.file({
description: `A release notes file that was generated using 'flub generate releaseNotes'. The file must not already contain heading links. That is, the input file must not have been generated with the --headingLinks flag.`,
Copy link
Contributor

Choose a reason for hiding this comment

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

What happens if it was generated with --headingLinks? Can we detect if it was and react appropriately (throw?)?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll test it - probably possible to detect but not sure how much it's worth - maybe just stripping anchor tags and regenning them in the remark pipeline will be easier.

Copy link
Member Author

Choose a reason for hiding this comment

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

It turns out that this is the reason to check if the first child node of a heading is text - if I add that check back, then it works even when links have been generated, because it skips them. So I added that check back.

build-tools/packages/build-cli/src/library/markdown.ts Outdated Show resolved Hide resolved
public async run(): Promise<string> {
const { inFile, outFile } = this.flags;
const input = await readFile(inFile, { encoding: "utf8" });
const processor = remark()
Copy link
Contributor

Choose a reason for hiding this comment

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

Any chance of refactoring common bits between this and generate:releaseNotes so the two commands stay in sync?

Copy link
Member Author

Choose a reason for hiding this comment

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

I haven't found a great way to do that yet, but I am looking. The problem is that the order of the pipeline matters, and the typing is complex enough that I haven't successfully modularized a "chunk" of the pipeline - only the individual plugins/functions. I am positive this is possible and I just haven't found a workable pattern yet.

tylerbutler and others added 3 commits September 11, 2024 16:11
Co-authored-by: jzaffiro <[email protected]>
Co-authored-by: jzaffiro <[email protected]>
Co-authored-by: jzaffiro <[email protected]>
@tylerbutler
Copy link
Member Author

Thanks for the review, @jzaffiro!

Copy link
Contributor

@alexvy86 alexvy86 left a comment

Choose a reason for hiding this comment

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

Besides any checks you're still doing, lgtm. One small thing below, not critical.

build-tools/packages/build-cli/src/library/markdown.ts Outdated Show resolved Hide resolved
@tylerbutler tylerbutler merged commit d2995da into microsoft:main Sep 14, 2024
29 checks passed
@tylerbutler tylerbutler deleted the bt-relnotes-publish branch September 14, 2024 00:01
tylerbutler added a commit that referenced this pull request Oct 10, 2024
The transform:releaseNotes command was added in #22466 to enable
automated release note creation for minor releases. This change updates
the CI pipeline to take advantage of the new capabilities.


[AB#19242](https://dev.azure.com/fluidframework/235294da-091d-4c29-84fc-cdfc3d90890b/_workitems/edit/19242)

---------

Co-authored-by: Alex Villarreal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: build Build related issues base: main PRs targeted against main branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants