c6da98289b
Update DEFGROUP and INGROUP fields across all CLI scripts to reflect the repo rename from MokoStandards to moko-platform. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
67 lines
1.7 KiB
PHP
67 lines
1.7 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
*
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* FILE INFORMATION
|
|
* DEFGROUP: moko-platform.CLI
|
|
* INGROUP: moko-platform
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
|
* PATH: /cli/release_notes.php
|
|
* BRIEF: Extract release notes from CHANGELOG.md for a given version
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
$path = '.';
|
|
$version = null;
|
|
foreach ($argv as $i => $arg) {
|
|
if ($arg === '--path' && isset($argv[$i + 1])) $path = $argv[$i + 1];
|
|
if ($arg === '--version' && isset($argv[$i + 1])) $version = $argv[$i + 1];
|
|
}
|
|
|
|
if ($version === null) {
|
|
// Read from README.md
|
|
$readme = realpath($path) . '/README.md';
|
|
if (file_exists($readme)) {
|
|
$content = file_get_contents($readme);
|
|
if (preg_match('/^\s*VERSION:\s*(\d{2}\.\d{2}\.\d{2})/m', $content, $m)) {
|
|
$version = $m[1];
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($version === null) {
|
|
fwrite(STDERR, "Usage: release_notes.php --path . --version XX.YY.ZZ\n");
|
|
exit(1);
|
|
}
|
|
|
|
$changelog = realpath($path) . '/CHANGELOG.md';
|
|
if (!file_exists($changelog)) {
|
|
echo "Release {$version}\n";
|
|
exit(0);
|
|
}
|
|
|
|
$lines = file($changelog, FILE_IGNORE_NEW_LINES);
|
|
$notes = [];
|
|
$capturing = false;
|
|
|
|
foreach ($lines as $line) {
|
|
if (preg_match('/^##\s.*' . preg_quote($version, '/') . '/', $line)) {
|
|
$capturing = true;
|
|
continue;
|
|
}
|
|
if ($capturing && preg_match('/^## /', $line)) {
|
|
break; // Next version heading — stop
|
|
}
|
|
if ($capturing) {
|
|
$notes[] = $line;
|
|
}
|
|
}
|
|
|
|
$result = trim(implode("\n", $notes));
|
|
echo $result ?: "Release {$version}";
|
|
echo "\n";
|
|
exit(0);
|