Skip to content
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

Small fixes to the release script #2363

Merged
merged 2 commits into from
Jan 29, 2024
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
24 changes: 8 additions & 16 deletions tool/release.dart
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,6 @@ Future<int> runReset({
// Reset the dependency overrides for the package:
_updateOverrides(package, includeOverrides: true);

// If updating webdev, also reset the dwds override for test_common to prevent
// conflicts:
if (package == 'webdev') {
_updateOverrides('test_common', includeOverrides: true);
}

// Update the version strings in CHANGELOG and pubspec.yaml.
_updateVersionStrings(
package,
Expand Down Expand Up @@ -129,25 +123,19 @@ Future<int> runRelease({

// Update the pinned version of DWDS for webdev releases.
if (package == 'webdev') {
_logInfo('Updating pinned version of DWDS.');
await _updateDwdsPin('test_common');
final newVersion = await _updateDwdsPin('webdev');
_logInfo('Add pinned DWDS info to CHANGELOG.');
final changelog = File('../webdev/CHANGELOG.md');
_addNewLine(changelog,
newLine: '- Update `dwds` constraint to `${newVersion ?? 'TODO'}`.');
newLine: '- Update `dwds` constraint to `${newVersion ?? 'TODO'}`.',
insertAt: 2,
);
}

// Remove any dependency overrides for the package:
_logInfo('Removing dependency overrides for $package.');
_updateOverrides(package, includeOverrides: false);

// If updating webdev, also remove the dwds override for test_common to
// prevent conflicts:
if (package == 'webdev') {
_updateOverrides('test_common', includeOverrides: false);
}

// Run dart pub upgrade.
for (final packagePath in [
'../dwds',
Expand Down Expand Up @@ -245,8 +233,12 @@ void _updateVersionStrings(
void _addNewLine(
File file, {
required String newLine,
int insertAt = 0,
}) {
final newLines = [newLine, '', ...file.readAsLinesSync()];
final currentLines = file.readAsLinesSync();
final linesBefore = currentLines.sublist(0, insertAt);
final linesAfter = currentLines.sublist(insertAt);
final newLines = [...linesBefore, newLine, '', ...linesAfter];
final content = newLines.joinWithNewLine();
return file.writeAsStringSync(content);
}
Expand Down
Loading