Skip to content

Commit

Permalink
Merge branch '5.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Mar 10, 2024
2 parents f291e5a + 423f1a4 commit 139d085
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/release.yaml
@@ -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 }}
7 changes: 7 additions & 0 deletions ChangeLog.md
Expand Up @@ -14,6 +14,12 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

* This component is no longer supported on PHP 8.1

## [5.1.2] - 2024-03-02

### Changed

* Do not use implicitly nullable parameters

## [5.1.1] - 2023-09-24

### Changed
Expand Down Expand Up @@ -108,6 +114,7 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

[6.0.1]: https://github.com/sebastianbergmann/exporter/compare/6.0.0...6.0.1
[6.0.0]: https://github.com/sebastianbergmann/exporter/compare/5.1...6.0.0
[5.1.2]: https://github.com/sebastianbergmann/exporter/compare/5.1.1...5.1.2
[5.1.1]: https://github.com/sebastianbergmann/exporter/compare/5.1.0...5.1.1
[5.1.0]: https://github.com/sebastianbergmann/exporter/compare/5.0.1...5.1.0
[5.0.1]: https://github.com/sebastianbergmann/exporter/compare/5.0.0...5.0.1
Expand Down
46 changes: 46 additions & 0 deletions build/scripts/extract-release-notes.php
@@ -0,0 +1,46 @@
#!/usr/bin/env php
<?php declare(strict_types=1);
if ($argc !== 2) {
print $argv[0] . ' <tag>' . PHP_EOL;

exit(1);
}

$version = $argv[1];

$file = __DIR__ . '/../../ChangeLog.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);
}

print $buffer . PHP_EOL;

0 comments on commit 139d085

Please sign in to comment.