Skip to content

Commit 6bd07d1

Browse files
Create release when tag is pushed
1 parent d51c3ae commit 6bd07d1

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

.github/workflows/release.yaml

+39
Original file line numberDiff line numberDiff 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 }}
+47
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)