Add --extract-release-notes to changelog add #2483
Open
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.
Impetus
Fixes https://github.com/elastic/docs-eng-team/issues/370
In Kibana pull requests, contributors often put a "Release Notes" section in the PR description and it's heeded by their current https://github.com/elastic/kibana-release-notes generator.
I think we ought to have the same option in the
docs-builder changelog addcommand (though not by default since this is the only team currently requiring that functionality).Overview
Added support for extracting release notes from GitHub PR descriptions in the
docs-builder changelog addcommand. This feature automatically extracts release notes from PR descriptions and uses them appropriately in changelog entries based on their length and format.Implementation Summary
Core Changes
1. GitHub PR Service Updates
src/services/Elastic.Documentation.Services/Changelog/GitHubPrService.csBodyproperty toGitHubPrInfoclass to store PR descriptionGitHubPrResponseto includeBodyfield from GitHub APIFetchPrInfoAsyncto populate theBodyproperty2. Release Notes Extractor Utility
src/services/Elastic.Documentation.Services/Changelog/ReleaseNotesExtractor.cs(new)Release Notes: ...Release-Notes: ...release notes: ...Release Note: ...Release Notes - ...## Release Note(markdown header)GeneratedRegexAttributefor compile-time regex generation3. Changelog Command Updates
src/tooling/docs-builder/Commands/ChangelogCommand.cs--extract-release-notesboolean optionChangelogInput4. Changelog Input Model
src/services/Elastic.Documentation.Services/Changelog/ChangelogInput.csExtractReleaseNotesboolean property5. Changelog Service Logic
src/services/Elastic.Documentation.Services/ChangelogService.csCreateSingleChangelogmethodExtractReleaseNotesis enabledCreateChangelogsForMultiplePrsto passExtractReleaseNotesflag to individual PR processingDocumentation Updates
docs/cli/release/changelog-add.mdanddocs/contribute/changelog.mdTesting
Test Coverage
1. Release Notes Extractor Tests
tests/Elastic.Documentation.Services.Tests/ReleaseNotesExtractorTests.cs(new)2. Changelog Service Integration Tests
tests/Elastic.Documentation.Services.Tests/ChangelogServiceTests.csCreateChangelog_WithExtractReleaseNotes_ShortReleaseNote_UsesAsTitle- Verifies short release notes are used as titleCreateChangelog_WithExtractReleaseNotes_LongReleaseNote_UsesAsDescription- Verifies long release notes are used as descriptionCreateChangelog_WithExtractReleaseNotes_MultiLineReleaseNote_UsesAsDescription- Verifies multi-line release notes are used as descriptionCreateChangelog_WithExtractReleaseNotes_NoReleaseNote_UsesPrTitle- Verifies fallback to PR title when no release note foundCreateChangelog_WithExtractReleaseNotes_ExplicitTitle_TakesPrecedence- Verifies explicit title takes precedence over extracted release noteCreateChangelog_WithExtractReleaseNotes_ExplicitDescription_TakesPrecedence- Verifies explicit description takes precedence over extracted release noteTotal Test Coverage: 23 tests, all passing ✅
Usage Examples
Basic Usage
Example PR Description Formats
Short Release Note (Used as Title)
## Summary This PR adds a new feature. Release Notes: Adds support for new aggregation typesLong Release Note (Used as Description)
## Summary This PR adds a new feature. Release Notes: Adds support for new aggregation types including date histogram, range aggregations, and nested aggregations with improved performanceMulti-line Release Note (Used as Description)
## Summary This PR adds a new feature. Release Notes: Adds support for new aggregation types This includes date histogram and range aggregations with improved performanceBehavior Details
Release Note Extraction Logic
Usage Rules
Short release notes (≤120 characters, single line):
--titleis not explicitly providedLong release notes (>120 characters or multi-line):
--descriptionis not explicitly providedNo release note found:
Explicit values take precedence:
--titleis provided, extracted release note title is ignored--descriptionis provided, extracted release note description is ignoredTechnical Implementation Notes
Regex Pattern
The extraction uses a compiled regex pattern (via
GeneratedRegexAttribute) that matches:Performance
GeneratedRegexAttributefor compile-time regex generationCompatibility
--prsoption--strip-title-prefixoptionFiles Changed
New Files
src/services/Elastic.Documentation.Services/Changelog/ReleaseNotesExtractor.cstests/Elastic.Documentation.Services.Tests/ReleaseNotesExtractorTests.csModified Files
src/services/Elastic.Documentation.Services/Changelog/GitHubPrService.cssrc/services/Elastic.Documentation.Services/Changelog/ChangelogInput.cssrc/services/Elastic.Documentation.Services/ChangelogService.cssrc/tooling/docs-builder/Commands/ChangelogCommand.csdocs/cli/release/changelog-add.mddocs/contribute/changelog.mdtests/Elastic.Documentation.Services.Tests/ChangelogServiceTests.csTesting Results
All tests pass successfully:
Related Issues
This implementation is based on the functionality described in:
The extraction logic matches the patterns used in the kibana-release-notes project for consistency across Elastic's documentation tooling.
Examples
Short sentence
./docs-builder changelog add --prs 248804 \ --repo kibana --owner elastic \ --products "kibana 9.3.0" \ --output /path/to/kibana/docs/changelog/ \ --config /path/to/kibana/docs/changelog.yml \ --extract-release-notesThe resulting changelog contains this string in the
title:Paragraph
The release note blurbs in these cases are added to the changelog descriptions. For example:
Generative AI disclosure
Tool(s) and model(s) used: composer-1