diff --git a/cli/version_bump.php b/cli/version_bump.php
index 40438f9..1f91ea9 100644
--- a/cli/version_bump.php
+++ b/cli/version_bump.php
@@ -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('|(\d{2}\.\d{2}\.\d{2})|', $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(
+ '|\d{2}\.\d{2}\.\d{2}|',
+ "{$new}",
+ $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);