Skip to content

Commit aac7726

Browse files
sebastianbergmanntheseerlocalheinzsebastianheuerSchrank
committed
Initial work on script that extracts release notes from ChangeLog file sebastianbergmann#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>
1 parent d62e419 commit aac7726

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env php
2+
<?php declare(strict_types=1);
3+
if ($argc !== 2) {
4+
print $argv[0] . ' <tag>' . PHP_EOL;
5+
6+
exit(1);
7+
}
8+
9+
$version = $argv[1];
10+
$versionSeries = explode('.', $version)[0] . '.' . explode('.', $version)[1];
11+
12+
$file = __DIR__ . '/../../ChangeLog-' . $versionSeries . '.md';
13+
14+
if (!is_file($file) || !is_readable($file)) {
15+
print $file . ' cannot be read' . PHP_EOL;
16+
17+
exit(1);
18+
}
19+
20+
$buffer = '';
21+
$append = false;
22+
23+
foreach (file($file) as $line) {
24+
if (str_starts_with($line, '## [' . $version . ']')) {
25+
$append = true;
26+
27+
continue;
28+
}
29+
30+
if ($append && (str_starts_with($line, '## ') || str_starts_with($line, '['))) {
31+
break;
32+
}
33+
34+
if ($append) {
35+
$buffer .= $line;
36+
}
37+
}
38+
39+
$buffer = trim($buffer);
40+
41+
if ($buffer === '') {
42+
print 'Unable to extract release notes' . PHP_EOL;
43+
44+
exit(1);
45+
}
46+
47+
print $buffer . PHP_EOL;

0 commit comments

Comments
 (0)