Skip to content

Commit

Permalink
add script to create release notes
Browse files Browse the repository at this point in the history
  • Loading branch information
nullxception committed Jun 10, 2023
1 parent 260e6fc commit 4365137
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ lib/**/*.gr.dart
# test stuff
coverage/lcov.info
test/full_coverage_test.dart

# Releases
releasenote.md
48 changes: 48 additions & 0 deletions bin/mkreleasenote.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'dart:convert';
import 'dart:io';

import 'package:path/path.dart' as path;

typedef Changelog = MapEntry<String, List<String>>;

List<Changelog> parseChangelog(String string) {
final data = <Changelog>[];

final lines = const LineSplitter()
.convert(string)
.map((it) => it.trim())
.where((it) => it.isNotEmpty);

for (final line in lines) {
if (line.startsWith('## ')) {
final ver = line.replaceFirst('## ', '').trim();
data.add(Changelog(ver, []));
} else if (line.startsWith('* ')) {
final log = line.replaceFirst('* ', '').trim();
data.last = Changelog(data.last.key, [...data.last.value, log]);
} else if (line.isNotEmpty && data.last.value.isNotEmpty) {
final newlinelog = '${data.last.value.last}\n$line';
final lastlog = data.last.value.sublist(0, data.last.value.length - 1);
data.last = Changelog(data.last.key, [...lastlog, newlinelog]);
}
}
return data;
}

void main() async {
final text = StringBuffer();

final notes = File(path.join(Directory.current.path, 'releasenote.md'));
final changelog = File(path.join(Directory.current.path, 'CHANGELOG.md'));

final data = parseChangelog(changelog.readAsStringSync());
final Changelog(key: version, value: logs) = data.first;

text.writeln("# What's new in $version");
text.writeln();
for (final log in logs) {
text.writeln('- $log');
}

notes.writeAsStringSync(text.toString());
}
6 changes: 6 additions & 0 deletions tool/grind.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,9 @@ Future<void> release() async {
await fun(['build', 'apk', '--split-per-abi']);
await Pub.runAsync('boorusphere', script: 'renameapks', runOptions: utf8Opt);
}

@Task('Create release notes')
Future<void> releaseNote() async {
await Pub.runAsync('boorusphere',
script: 'mkreleasenote', runOptions: utf8Opt);
}

0 comments on commit 4365137

Please sign in to comment.