Skip to content

Commit

Permalink
Add changelogs when we bump versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Oct 24, 2024
1 parent 88772aa commit d4aa035
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tool/grind/bump_version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ void _bumpVersion(bool patch, bool dev) {
pre: dev ? "dev" : null);
}

/// Adds a "No user-visible changes" entry for [version] to the changelog in
/// [dir].
void addChangelogEntry(String dir, Version version) {
var path = p.join(dir, "CHANGELOG.md");
var text = File(path).readAsStringSync();
if (!dev && text.startsWith("## ${version}-dev\n")) {
File(path).writeAsStringSync(
text.replaceFirst("## ${version}-dev\n", "## ${version}\n"));
} else if (text.startsWith("## ${version}\n")) {
return;
} else {
File(path).writeAsStringSync(
"## ${version}\n\n* No user-visible changes.\n\n$text");
}
}

// Bumps the current version of [pubspec] to the next [patch] version, with
// `-dev` if [dev] is true.
void bumpDartVersion(String path) {
Expand All @@ -63,6 +79,7 @@ void _bumpVersion(bool patch, bool dev) {
pubspec.nodes["version"]!.span);
File(path).writeAsStringSync(
text.replaceFirst(_pubspecVersionRegExp, 'version: $version'));
addChangelogEntry(p.dirname(path), version);
}

bumpDartVersion('pubspec.yaml');
Expand All @@ -78,4 +95,5 @@ void _bumpVersion(bool patch, bool dev) {
File(packageJsonPath).writeAsStringSync(JsonEncoder.withIndent(" ")
.convert({...packageJson, "version": version.toString()}) +
"\n");
addChangelogEntry("pkg/sass-parser", version);
}

0 comments on commit d4aa035

Please sign in to comment.