Skip to content

Commit

Permalink
Merge branch '9.6' into 10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 9, 2024
2 parents 5a7ea4e + 5384dd1 commit 5f3854e
Show file tree
Hide file tree
Showing 2 changed files with 93 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# https://docs.github.com/en/actions

on:
push:
tags:
- "**"

name: Release

jobs:
release:
name: Release

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install PHP with extensions
uses: shivammathur/setup-php@v2
with:
php-version: 8.3
coverage: none
extensions: none
tools: none

- name: Determine tag
run: echo "RELEASE_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- name: Parse changelog
run: build/scripts/extract-release-notes.php ${{ env.RELEASE_TAG }} > release-notes.md

- name: Create release
uses: ncipollo/release-action@v1
with:
bodyFile: release-notes.md
tag: ${{ env.RELEASE_TAG }}
token: ${{ secrets.GITHUB_TOKEN }}
54 changes: 54 additions & 0 deletions build/scripts/extract-release-notes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/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);
}

printf(
'%s%s---%s[How to install or update PHPUnit](https://docs.phpunit.de/en/%s/installation.html)%s',
$buffer,
PHP_EOL,
PHP_EOL,
$versionSeries,
PHP_EOL,
);

0 comments on commit 5f3854e

Please sign in to comment.