Skip to content

Update breaking changes release notes section automatically #4060

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 2 commits into from
Apr 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion .ci/ReleaseChangelog.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ public static void main(String[] args) throws IOException {
Path releaseNotesDir = Paths.get(args[1]);
Path releaseNotesFile = releaseNotesDir.resolve("index.md");
Path deprecationsFile = releaseNotesDir.resolve("deprecations.md");
Path breakingChangesFile = releaseNotesDir.resolve("breaking-changes.md");
VersionNumber version = VersionNumber.parse(args[2].trim());

Lines nextChangelogLines = new Lines(Files.readAllLines(nextChangelogFile, StandardCharsets.UTF_8));
Lines fixes = nextChangelogLines.cutLinesBetween("<!--FIXES-START-->", "<!--FIXES-END-->");
Lines enhancements = nextChangelogLines.cutLinesBetween("<!--ENHANCEMENTS-START-->", "<!--ENHANCEMENTS-END-->");
Lines deprecations = nextChangelogLines.cutLinesBetween("<!--DEPRECATIONS-START-->", "<!--DEPRECATIONS-END-->");
Lines breakingChanges = nextChangelogLines.cutLinesBetween("<!--BREAKING-CHANGES-START-->", "<!--BREAKING-CHANGES-END-->");


var formatter = DateTimeFormatter.ofPattern("LLLL d, yyyy", Locale.ENGLISH);
Expand All @@ -65,6 +67,12 @@ public static void main(String[] args) throws IOException {
allDeprecations.insert(generateDeprecations(version, releaseDateLine, deprecations), insertDepsBeforeLine);
Files.writeString(deprecationsFile, allDeprecations + "\n", StandardCharsets.UTF_8);
}
if (!breakingChanges.isEmpty()) {
Lines allBreakingChanges = new Lines(Files.readAllLines(breakingChangesFile, StandardCharsets.UTF_8));
int insertBcBeforeLine = findHeadingOfPreviousVersion(allBreakingChanges, version);
allBreakingChanges.insert(generateBreakingChanges(version, releaseDateLine, breakingChanges), insertBcBeforeLine);
Files.writeString(breakingChangesFile, allBreakingChanges + "\n", StandardCharsets.UTF_8);
}
Files.writeString(releaseNotesFile, allReleaseNotes + "\n", StandardCharsets.UTF_8);
Files.writeString(nextChangelogFile, nextChangelogLines + "\n", StandardCharsets.UTF_8);
}
Expand All @@ -89,7 +97,6 @@ private static Lines generateReleaseNotes(VersionNumber version, String releaseD
return result;
}


private static Lines generateDeprecations(VersionNumber version, String releaseDateLine, Lines deprecations) {
return new Lines()
.append("## " + version.dotStr() + " [elastic-apm-java-agent-" + version.dashStr() + "-deprecations]")
Expand All @@ -99,6 +106,16 @@ private static Lines generateDeprecations(VersionNumber version, String releaseD
.append("");
}

private static Lines generateBreakingChanges(VersionNumber version, String releaseDateLine, Lines breakingChanges) {
return new Lines()
.append("## " + version.dotStr() + " [" + version.dotStr() + "]")
.append("")
.append(releaseDateLine)
.append("")
.append(breakingChanges)
.append("");
}

static int findHeadingOfPreviousVersion(Lines lines, VersionNumber version) {
Pattern headingPattern = Pattern.compile("## (\\d+\\.\\d+\\.\\d+) .*");
Comparator<VersionNumber> comp = VersionNumber.comparator();
Expand Down
Loading