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

Update release note generation command #12920

Merged
merged 2 commits into from
Nov 1, 2022

Conversation

SarahFrench
Copy link
Member

@SarahFrench SarahFrench commented Nov 1, 2022

Context

Closes #12751

The release process owned by HashiCorp expects there to be an artifact, containing the release notes for a given release, uploaded to the repo containing the provider. This is the section of the GHA workflow for this repo that defines how the release notes are generated and then uploaded.

The sed command used to pull out the section of CHANGELOG.md relevant to the latest release is something made by HashiCorp : see it here in the release tooling's README

The sed command uses git describe to pull in the latest tag and then uses that output to identify the previous tag. This is used to prevent lines in the changelog from previous releases being streamed into the output release-notes.txt file. So if you tag v4.50.0 and the previous tag is v4.49.0 then you should see all of your changelog file above the entry for v4.49.0 being put into release-notes.txt.

The problem

Sometimes when we make a release we get lots of extra text in the release notes- changelog entries for multiple releases instead of just the latest release.

This is because the sed command that generates the release notes needs to identify the tag for the current release we're making and also the tag for the previous release. The previous release's tag/version is used to prevent those entries and older entries from being added to release notes.

For this to work, all the tags need to be reachable from the specified commit that the release is running from (i.e. where the latest tag was added), but because we tag release branches not all tags are accessible from main or branches coming off of main. This problem can be seen by checking out a tag and running the following command to see all the tags that are accessible from the tagged commit:

git checkout v4.42.0

git tag --merged | grep v4.
# v4.17.0
# v4.27.0
# v4.40.0
# v4.42.0

Possible solution

The core issue we need to solve is how we can access the the previous release tag when we check out the most recent release tag.

This command returns all the tags in their release order (not just lexical order)

git tag --sort=-version:refname

You can pull the 2 most recent tags and then the bottom tag from that list of 2 to get the previous version:

git checkout v4.42.0

git tag --sort=-version:refname | head -n 2 | tail -n 1

# v4.41.0

What's in this PR

I've used the above approach to update the sed command. Specifically I've replaced

$(git describe --abbrev=0 --exclude="$(git describe --abbrev=0 --match='v*.*.*' --tags)" --match='v*.*.*' --tags | tr -d v)

with

$PREV_VERSION

Where this ENV contains a value that is the previous version tag, minus the v at the start. E.g. 4.42.0

This newer approach doesn't depend on tags being merged into a single branch, and works with our release branch strategy
@github-actions
Copy link

github-actions bot commented Nov 1, 2022

** WARNING **: This repository is generated by https://github.com/GoogleCloudPlatform/magic-modules. Any changes made directly to this repository will likely be overwritten. If you have further questions, please feel free to ping your reviewer or, internal employees, reach out to one of the engineers. Thank you!

Add optional pattern arg to list command, so only version tags starting with v are processed
@ScottSuarez
Copy link
Collaborator

Thanks Sarah ^-^

@SarahFrench
Copy link
Member Author

Thanks for the review! I'll merge and post about it in the team channel

@github-actions
Copy link

github-actions bot commented Dec 3, 2022

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 3, 2022
@SarahFrench SarahFrench deleted the update-release-note-generation branch August 7, 2023 13:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto truncate comment in release making process
2 participants