Public Access
d9846b1c01
Generic: Repo Health / Site Health (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Universal: Cascade Main → Dev / Cascade main → branches (push) Has been cancelled
Generic: Repo Health / Release configuration (push) Has been cancelled
Generic: Repo Health / Scripts governance (push) Has been cancelled
Generic: Repo Health / Repository health (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (push) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (push) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (push) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (push) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (push) Has been cancelled
Platform: moko-platform CI / CI Summary (push) Has been cancelled
Previously version_bump.php only read from README.md VERSION header, ignoring the actual manifest XML version. When a version was manually bumped in the manifest (e.g. 02.03.00) but README still showed an older version (02.01.45), the CLI would bump from README's version instead, producing wrong release numbers. Now both tools check README.md AND Joomla manifest XML files (pkg_*.xml, src/*.xml, packages/*/*.xml) and use whichever version is higher as the base for bumping/reading. Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
75 lines
2.5 KiB
PHP
75 lines
2.5 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/version_read.php
|
|
* BRIEF: Read version from README.md or manifest XML — outputs the higher of the two
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
$path = '.';
|
|
foreach ($argv as $i => $arg) {
|
|
if ($arg === '--path' && isset($argv[$i + 1])) {
|
|
$path = $argv[$i + 1];
|
|
}
|
|
}
|
|
|
|
$root = realpath($path) ?: $path;
|
|
|
|
// ── Read from README.md ──────────────────────────────────────────────────────
|
|
$readmeVersion = null;
|
|
$readme = "{$root}/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)) {
|
|
$readmeVersion = $m[1];
|
|
}
|
|
}
|
|
|
|
// ── Read from Joomla manifest XML ────────────────────────────────────────────
|
|
$manifestVersion = null;
|
|
$manifestFiles = array_merge(
|
|
glob("{$root}/src/pkg_*.xml") ?: [],
|
|
glob("{$root}/src/*.xml") ?: [],
|
|
glob("{$root}/src/packages/*/*.xml") ?: [],
|
|
glob("{$root}/*.xml") ?: []
|
|
);
|
|
|
|
foreach ($manifestFiles as $xmlFile) {
|
|
$xmlContent = file_get_contents($xmlFile);
|
|
if (strpos($xmlContent, '<extension') === false && strpos($xmlContent, '<version>') === false) {
|
|
continue;
|
|
}
|
|
if (preg_match('|<version>(\d{2}\.\d{2}\.\d{2})</version>|', $xmlContent, $xm)) {
|
|
$candidate = $xm[1];
|
|
if ($manifestVersion === null || version_compare($candidate, $manifestVersion, '>')) {
|
|
$manifestVersion = $candidate;
|
|
}
|
|
}
|
|
}
|
|
|
|
// ── Output the higher version ────────────────────────────────────────────────
|
|
$version = null;
|
|
if ($readmeVersion !== null && $manifestVersion !== null) {
|
|
$version = version_compare($manifestVersion, $readmeVersion, '>') ? $manifestVersion : $readmeVersion;
|
|
} elseif ($manifestVersion !== null) {
|
|
$version = $manifestVersion;
|
|
} elseif ($readmeVersion !== null) {
|
|
$version = $readmeVersion;
|
|
}
|
|
|
|
if ($version === null) {
|
|
fwrite(STDERR, "No version found in README.md or manifest XML\n");
|
|
exit(1);
|
|
}
|
|
|
|
echo $version . "\n";
|
|
exit(0);
|