Skip to content

Commit 8654b76

Browse files
authored
Release 0.23.0 (#243)
* update CHANGELOG for release * Version 0.23.0 * Version 0.23.1-dev * reference new version in CHANGELOG * add next version to changelog after release tag has been created
1 parent 706e852 commit 8654b76

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

3-
## Version 0.23.0-dev
3+
## Version 0.23.1-dev
4+
5+
## Version 0.23.0
46
- technical: use package_config to interact with package configs
57
- fix: problem resolving external packages
68

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: dart_apitool
22
description: A tool to analyze the public API of a package, create a model of it and diff it against another version to check semver.
33
repository: https://github.com/bmw-tech/dart_apitool
44

5-
version: 0.23.0-dev
5+
version: 0.23.1-dev
66

77
environment:
88
sdk: ">=3.0.0 <4.0.0"

scripts/release_util/lib/src/release_command.dart

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ class ReleaseCommand extends Command {
3232
_runTests();
3333
_checkSemver();
3434
if (!isPrerelease) {
35-
_removePrereleaseFlagFromPubspec();
35+
final oldVersion = _removePrereleaseFlagFromPubspec();
36+
_updateChangelog(oldVersion);
3637
_commit('Version ${_getCurrentVersion()}');
3738
}
3839
await _publishDryRunAsync();
3940
_createTag('v${_getCurrentVersion()}');
4041
_setNextPrereleaseVersion();
42+
_addNextVersionToChangelog();
4143
_commit('Version ${_getCurrentVersion()}');
4244
}
4345

@@ -182,19 +184,19 @@ class ReleaseCommand extends Command {
182184
}
183185
}
184186

185-
void _removePrereleaseFlagFromPubspec() {
187+
String _removePrereleaseFlagFromPubspec() {
186188
final String pubspecPath = path.join(_getApiToolRootPath(), 'pubspec.yaml');
187189
final pubspecContent = File(pubspecPath).readAsStringSync();
188190

189191
final pubspec = Pubspec.parse(pubspecContent);
190192
final currentVersion = pubspec.version!;
191193

194+
final currentVersionString = currentVersion.canonicalizedVersion;
195+
192196
if (currentVersion.preRelease.isEmpty) {
193-
return;
197+
return currentVersionString;
194198
}
195199

196-
final currentVersionString = currentVersion.canonicalizedVersion;
197-
198200
final newVersion = Version(
199201
currentVersion.major, currentVersion.minor, currentVersion.patch);
200202
final newVersionString = newVersion.canonicalizedVersion;
@@ -205,6 +207,7 @@ class ReleaseCommand extends Command {
205207
);
206208

207209
File(pubspecPath).writeAsStringSync(newPubspecContent);
210+
return currentVersionString;
208211
}
209212

210213
void _commit(String message) {
@@ -280,4 +283,31 @@ class ReleaseCommand extends Command {
280283
);
281284
File(pubspecPath).writeAsStringSync(newPubspecContent);
282285
}
286+
287+
void _addNextVersionToChangelog() {
288+
print('adding next version to changelog');
289+
final changelogPath = path.join(_getApiToolRootPath(), 'CHANGELOG.md');
290+
final changelogContent = File(changelogPath).readAsStringSync();
291+
final newVersion = _getCurrentVersion();
292+
final newChangelogContent = changelogContent.replaceFirst(
293+
'# Changelog\n',
294+
'# Changelog\n\n## Version $newVersion\n',
295+
);
296+
File(changelogPath).writeAsStringSync(newChangelogContent);
297+
}
298+
299+
void _updateChangelog(String oldVersion) {
300+
print('updating changelog');
301+
final changelogPath = path.join(_getApiToolRootPath(), 'CHANGELOG.md');
302+
final changelogContent = File(changelogPath).readAsStringSync();
303+
final newVersion = _getCurrentVersion();
304+
final newChangelogContent = changelogContent.replaceFirst(
305+
'## Version $oldVersion',
306+
'## Version $newVersion',
307+
);
308+
if (newChangelogContent == changelogContent) {
309+
throw Exception('Could not find version $oldVersion in CHANGELOG.md');
310+
}
311+
File(changelogPath).writeAsStringSync(newChangelogContent);
312+
}
283313
}

0 commit comments

Comments
 (0)