HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ubuntu-8gb-hel1-1 6.8.0-55-generic #57-Ubuntu SMP PREEMPT_DYNAMIC Wed Feb 12 23:42:21 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.32
Disabled: NONE
Upload Files
File: /var/www/agighana.org_backup/extract-release-notes.php
#!/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);
}

print $buffer . PHP_EOL;