Skip to content

Commit 7ae4f9c

Browse files
samdarkStyleCIBot
andauthored
Generate release news text (#318)
Co-authored-by: StyleCI Bot <bot@styleci.io>
1 parent 5132851 commit 7ae4f9c

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

src/App/Command/Release/MakeCommand.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,13 @@ protected function processPackage(Package $package): void
193193
$io->info('The following steps are left to do manually:');
194194
$io->info("- Close the $versionToRelease <href=https://github.com/{$package->getName()}/milestones/>milestone on GitHub</> and open new one for $nextVersion.");
195195
$io->info('- Release news and announcement.');
196+
197+
$this->displayReleaseSummary(
198+
package: $package,
199+
composerConfig: $composerConfig,
200+
changelog: $changelog,
201+
versionToRelease: $versionToRelease
202+
);
196203
}
197204
}
198205

@@ -275,4 +282,37 @@ private function getToken(): string
275282

276283
return trim(file_get_contents($tokenFile));
277284
}
285+
286+
private function displayReleaseSummary(Package $package, ComposerConfig $composerConfig, Changelog $changelog, Version $versionToRelease): void
287+
{
288+
$packageName = $package->getName();
289+
290+
$description = $composerConfig->getSection(ComposerConfig::SECTION_DESCRIPTION);
291+
292+
$io = $this->getIO();
293+
$io->info("\n---\n");
294+
$io->info('<fg=green>' . $description . ' ' . $versionToRelease . "</>\n");
295+
296+
$changes = [];
297+
298+
foreach ($changelog->getReleaseNotes($versionToRelease) as $note) {
299+
$note = trim($note);
300+
if ($note === '') {
301+
continue;
302+
}
303+
304+
$changes[] = '- ' . preg_replace('~^-.*?:\s+(.*)\s+\(?.*?\)$~', '$1', $note);
305+
}
306+
307+
$changes = implode("\n", $changes);
308+
309+
$text = <<<TEXT
310+
[$description](https://github.com/yiisoft/$packageName) version $versionToRelease was released.
311+
In this version:
312+
313+
$changes
314+
TEXT;
315+
316+
$io->info($text . "\n");
317+
}
278318
}

src/Infrastructure/Composer/Config/ComposerConfig.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ class ComposerConfig
1717
public const SECTION_REQUIRE = 'require';
1818
public const SECTION_REQUIRE_DEV = 'require-dev';
1919

20+
public const SECTION_DESCRIPTION = 'description';
21+
2022
private function __construct(private array $data)
2123
{
2224
}

0 commit comments

Comments
 (0)