Repository navigation
Generate release notes and changelogs from PR titles #776
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
00042e2
Add release notes file generation from PR titles
iangmaia d2d22b0
Link release notes generation changelog to proposal PR
iangmaia 6b08618
Handle GitHub configuration comments in generated notes
iangmaia 5279dba
Simplify release notes generation and reuse the existing helper
iangmaia 2829726
Preserve generated Markdown without parsing release note entries
iangmaia dd08403
Document label-based release note categories and testing reports
iangmaia 7d5b1ff
Support Markdown changelog output for generated release notes
iangmaia d523833
Preserve final empty release-note sections without trailing newlines
iangmaia 2205524
Ignore headings inside inline HTML comments in changelogs
iangmaia ea97120
Rephrase sentence in release notes doc
iangmaia d832a33
Share custom release-note action option definitions
iangmaia File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
84 changes: 84 additions & 0 deletions
84
lib/fastlane/plugin/wpmreleasetoolkit/actions/common/generate_release_notes_file.rb
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require 'fastlane/action' | ||
| require_relative 'get_prs_between_tags' | ||
| require_relative '../../helper/release_notes_helper' | ||
|
|
||
| module Fastlane | ||
| module Actions | ||
| class GenerateReleaseNotesFileAction < Action | ||
| def self.run(params) | ||
| UI.user_error!('An explicit previous_tag is required to generate release notes') if params[:previous_tag].to_s.empty? | ||
| version = params[:version] | ||
| UI.user_error!('Expected a numeric release version') unless version.match?(/\A\d+(?:\.\d+){0,2}\z/) | ||
|
|
||
| path = params[:release_notes_file_path] | ||
| contents = File.read(path) | ||
| format = params[:format] | ||
| options = params.values.except(*custom_options.map(&:key)) | ||
| markdown = other_action.get_prs_between_tags(**options, fail_on_error: true) | ||
| section = Helper::ReleaseNotesHelper.format_section(version: version, markdown: markdown, format: format) | ||
| updated = Helper::ReleaseNotesHelper.update_section(contents: contents, version: version, section: section, format: format) | ||
|
|
||
| if params[:dry_run] | ||
| UI.message(section) | ||
| else | ||
| File.write(path, updated) | ||
| end | ||
| section | ||
| end | ||
|
|
||
| def self.description | ||
| 'Write generated GitHub notes to a release notes or Markdown changelog version section' | ||
| end | ||
|
|
||
| def self.details | ||
| <<~DETAILS | ||
| Inserts or replaces one version section using get_prs_between_tags, preserving other versions and header comments. | ||
| Defaults to the underlined version headings used in RELEASE-NOTES.txt. | ||
| Use format: :changelog and release_notes_file_path: 'CHANGELOG.md' for numeric ## version headings. | ||
| Changelog output nests generated headings beneath the version and preserves Trunk/Unreleased sections. | ||
| The existing file must contain at least one version section in the selected format. | ||
| Keeps authors, contributors, and links. Does not promote Unreleased entries or edit other versions. | ||
| Use configuration_file_path to exclude or group PRs by GitHub labels; no title markers are needed. | ||
| For a separate report, such as release testing, call get_prs_between_tags with its own configuration_file_path. | ||
| Requires an explicit previous_tag and a published target_commitish if tag_name does not exist. | ||
| Use dry_run to preview without writing. Does not commit changes. | ||
| DETAILS | ||
| end | ||
|
|
||
| def self.available_options | ||
| GetPrsBetweenTagsAction.available_options.reject { |option| option.key == :fail_on_error } + custom_options | ||
| end | ||
|
|
||
| def self.custom_options | ||
| [ | ||
| FastlaneCore::ConfigItem.new(key: :version, description: 'Numeric version heading in the output file', type: String), | ||
| FastlaneCore::ConfigItem.new(key: :release_notes_file_path, description: 'Existing release notes file', type: String, default_value: 'RELEASE-NOTES.txt'), | ||
| FastlaneCore::ConfigItem.new(key: :format, | ||
| description: 'Version section format: :release_notes or :changelog', | ||
| type: Symbol, | ||
| default_value: :release_notes, | ||
| verify_block: proc do |value| | ||
| UI.user_error!('format must be :release_notes or :changelog') unless %i[release_notes changelog].include?(value) | ||
| end), | ||
| FastlaneCore::ConfigItem.new(key: :dry_run, description: 'Preview the section without writing the file', type: Boolean, default_value: false), | ||
| ] | ||
| end | ||
|
|
||
| private_class_method :custom_options | ||
|
|
||
| def self.return_value | ||
| 'The generated version section' | ||
| end | ||
|
|
||
| def self.authors | ||
| ['Automattic'] | ||
| end | ||
|
|
||
| def self.is_supported?(platform) | ||
| true | ||
| end | ||
| end | ||
| end | ||
| end |
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
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
Oops, something went wrong.
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.
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.
Checked in the docs at https://docs.github.com/en/rest/releases/releases?apiVersion=2026-03-10#generate-release-notes-content-for-a-release and confirm
configuration_file_pathis the right name.Not sure by what magic it was working before. Or maybe the GitHub API changed it but kept support for the old name for compatibility?
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.
Indeed, yeah, can be. I was surprised it works (or worked?) 🤔