Merge branch '4.1' · sebastianbergmann/php-file-iterator@d8fc468 (original) (raw)
2 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
1 | +# https://docs.github.com/en/actions | |
2 | + | |
3 | +on: | |
4 | +push: | |
5 | +tags: | |
6 | + - "**" | |
7 | + | |
8 | +name: Release | |
9 | + | |
10 | +jobs: | |
11 | +release: | |
12 | +name: Release | |
13 | + | |
14 | +runs-on: ubuntu-latest | |
15 | + | |
16 | +steps: | |
17 | + - name: Checkout | |
18 | +uses: actions/checkout@v4 | |
19 | + | |
20 | + - name: Install PHP with extensions | |
21 | +uses: shivammathur/setup-php@v2 | |
22 | +with: | |
23 | +php-version: 8.3 | |
24 | +coverage: none | |
25 | +extensions: none | |
26 | +tools: none | |
27 | + | |
28 | + - name: Determine tag | |
29 | +run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
30 | + | |
31 | + - name: Parse ChangeLog | |
32 | +run: build/scripts/extract-release-notes.php ${{ env.RELEASE_TAG }} > release-notes.md | |
33 | + | |
34 | + - name: Create release | |
35 | +uses: ncipollo/release-action@v1 | |
36 | +with: | |
37 | +bodyFile: release-notes.md | |
38 | +tag: ${{ env.RELEASE_TAG }} | |
39 | +token: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
1 | +#!/usr/bin/env php | |
2 | +<?php declare(strict_types=1); | |
3 | +if ($argc !== 2) { | |
4 | +print $argv[0] . ' ' . PHP_EOL; | |
5 | + | |
6 | +exit(1); | |
7 | +} | |
8 | + | |
9 | +$version = $argv[1]; | |
10 | + | |
11 | +$file = __DIR__ . '/../../ChangeLog.md'; | |
12 | + | |
13 | +if (!is_file($file) | | |
14 | +print $file . ' cannot be read' . PHP_EOL; | |
15 | + | |
16 | +exit(1); | |
17 | +} | |
18 | + | |
19 | +$buffer = ''; | |
20 | +$append = false; | |
21 | + | |
22 | +foreach (file($file) as $line) { | |
23 | +if (str_starts_with($line, '## [' . $version . ']')) { | |
24 | +$append = true; | |
25 | + | |
26 | +continue; | |
27 | + } | |
28 | + | |
29 | +if ($append && (str_starts_with($line, '## ') | | |
30 | +break; | |
31 | + } | |
32 | + | |
33 | +if ($append) { | |
34 | +$buffer .= $line; | |
35 | + } | |
36 | +} | |
37 | + | |
38 | +$buffer = trim($buffer); | |
39 | + | |
40 | +if ($buffer === '') { | |
41 | +print 'Unable to extract release notes' . PHP_EOL; | |
42 | + | |
43 | +exit(1); | |
44 | +} | |
45 | + | |
46 | +print $buffer . PHP_EOL; |