feat: version_bump.php writes to .mokogitea/manifest.xml as canonical target
Generic: Repo Health / Site Health (push) Has been skipped
Universal: Cascade Main → Dev / Cascade main → branches (push) Successful in 3s
Generic: Repo Health / Access control (push) Successful in 2s
Platform: moko-platform CI / Gate 1: Code Quality (push) Successful in 53s
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
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

Authored-by: Moko Consulting
This commit is contained in:
2026-05-26 19:26:45 +00:00
parent c5e4b41100
commit d323ca52af
+35 -17
View File
@@ -9,7 +9,7 @@
* INGROUP: moko-platform
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
* PATH: /cli/version_bump.php
* BRIEF: Auto-increment patch version — checks both README.md and manifest XML, uses the higher version as base
* BRIEF: Auto-increment version — manifest.xml is canonical, also updates README.md and Joomla XML
*/
declare(strict_types=1);
@@ -24,7 +24,18 @@ foreach ($argv as $i => $arg) {
$root = realpath($path) ?: $path;
// ── Read version from README.md ──────────────────────────────────────────────
// -- 1. Read version from .mokogitea/manifest.xml (canonical) --
$mokoVersion = null;
$mokoManifest = "{$root}/.mokogitea/manifest.xml";
$mokoContent = '';
if (file_exists($mokoManifest)) {
$mokoContent = file_get_contents($mokoManifest);
if (preg_match('|<version>(\d{2}\.\d{2}\.\d{2})</version>|', $mokoContent, $m)) {
$mokoVersion = $m[1];
}
}
// -- 2. Fallback: README.md --
$readmeVersion = null;
$readme = "{$root}/README.md";
$readmeContent = '';
@@ -35,10 +46,8 @@ if (file_exists($readme)) {
}
}
// ── Read version from Joomla manifest XML ────────────────────────────────────
// -- 3. Fallback: Joomla manifest XML --
$manifestVersion = null;
// Check package manifest first (pkg_*.xml), then sub-extension manifests
$manifestFiles = array_merge(
glob("{$root}/src/pkg_*.xml") ?: [],
glob("{$root}/src/*.xml") ?: [],
@@ -60,23 +69,21 @@ foreach ($manifestFiles as $xmlFile) {
}
}
// ── Use the higher version as base ───────────────────────────────────────────
// -- Use the highest version as base --
$baseVersion = null;
if ($readmeVersion !== null && $manifestVersion !== null) {
$baseVersion = version_compare($manifestVersion, $readmeVersion, '>') ? $manifestVersion : $readmeVersion;
} elseif ($manifestVersion !== null) {
$baseVersion = $manifestVersion;
} elseif ($readmeVersion !== null) {
$baseVersion = $readmeVersion;
$candidates = array_filter([$mokoVersion, $readmeVersion, $manifestVersion]);
foreach ($candidates as $v) {
if ($baseVersion === null || version_compare($v, $baseVersion, '>')) {
$baseVersion = $v;
}
}
if ($baseVersion === null) {
fwrite(STDERR, "No version found in README.md or manifest XML\n");
fwrite(STDERR, "No version found in manifest.xml, README.md, or Joomla XML\n");
exit(1);
}
// ── Parse and bump ───────────────────────────────────────────────────────────
// -- Parse and bump --
if (!preg_match('/^(\d{2})\.(\d{2})\.(\d{2})$/', $baseVersion, $parts)) {
fwrite(STDERR, "Invalid version format: {$baseVersion}\n");
exit(1);
@@ -99,7 +106,18 @@ switch ($type) {
$new = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
// ── Update README.md ─────────────────────────────────────────────────────────
// -- Update .mokogitea/manifest.xml (canonical target) --
if (file_exists($mokoManifest) && !empty($mokoContent)) {
$updated = preg_replace(
'|<version>\d{2}\.\d{2}\.\d{2}</version>|',
"<version>{$new}</version>",
$mokoContent,
1
);
file_put_contents($mokoManifest, $updated);
}
// -- Update README.md --
if (file_exists($readme) && !empty($readmeContent)) {
$updated = preg_replace(
'/(VERSION:\s*)\d{2}\.\d{2}\.\d{2}/m',
@@ -110,5 +128,5 @@ if (file_exists($readme) && !empty($readmeContent)) {
file_put_contents($readme, $updated);
}
echo "{$old} {$new}\n";
echo "{$old} -> {$new}\n";
exit(0);