Skip to content

Commit

Permalink
Initial work on script that extracts release notes from ChangeLog file
Browse files Browse the repository at this point in the history
…#5550

Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
Co-authored-by: Arne Blankerts <Arne@Blankerts.de>
Co-authored-by: Andreas Möller <am@localheinz.com>
Co-authored-by: Sebastian Heuer <sebastian@phpeople.de>
Co-authored-by: Fabian Blechschmidt <blechschmidt@fabian-blechschmidt.de>
Co-authored-by: Frank Sons <frank.sons@code-quality.de>
  • Loading branch information
6 people committed Mar 9, 2024
1 parent d62e419 commit aac7726
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions build/scripts/extract-release-notes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env php
<?php declare(strict_types=1);
if ($argc !== 2) {
print $argv[0] . ' <tag>' . PHP_EOL;

exit(1);
}

$version = $argv[1];
$versionSeries = explode('.', $version)[0] . '.' . explode('.', $version)[1];

$file = __DIR__ . '/../../ChangeLog-' . $versionSeries . '.md';

if (!is_file($file) || !is_readable($file)) {
print $file . ' cannot be read' . PHP_EOL;

exit(1);
}

$buffer = '';
$append = false;

foreach (file($file) as $line) {
if (str_starts_with($line, '## [' . $version . ']')) {
$append = true;

continue;
}

if ($append && (str_starts_with($line, '## ') || str_starts_with($line, '['))) {
break;
}

if ($append) {
$buffer .= $line;
}
}

$buffer = trim($buffer);

if ($buffer === '') {
print 'Unable to extract release notes' . PHP_EOL;

exit(1);
}

print $buffer . PHP_EOL;

0 comments on commit aac7726

Please sign in to comment.