File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments