diff --git a/cli/version_bump.php b/cli/version_bump.php
index 4c15810..5efb6c5 100644
--- a/cli/version_bump.php
+++ b/cli/version_bump.php
@@ -30,7 +30,7 @@ $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)) {
+ if (preg_match('|(\d{2}\.\d{2}\.\d{2})(?:-([a-z]+))?|', $mokoContent, $m)) {
$mokoVersion = $m[1];
}
}
@@ -56,15 +56,17 @@ $manifestFiles = array_merge(
glob("{$root}/*.xml") ?: []
);
+$manifestSuffix = '';
foreach ($manifestFiles as $xmlFile) {
$xmlContent = file_get_contents($xmlFile);
if (strpos($xmlContent, '') === false) {
continue;
}
- if (preg_match('|(\d{2}\.\d{2}\.\d{2})(?:-[a-z]+)?|', $xmlContent, $xm)) {
+ if (preg_match('|(\d{2}\.\d{2}\.\d{2})(?:-([a-z]+))?|', $xmlContent, $xm)) {
$candidate = $xm[1];
if ($manifestVersion === null || version_compare($candidate, $manifestVersion, '>')) {
$manifestVersion = $candidate;
+ $manifestSuffix = isset($xm[2]) ? $xm[2] : '';
}
}
}
@@ -106,10 +108,14 @@ switch ($type) {
$new = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
-// -- Update .mokogitea/manifest.xml (canonical target) --
+// -- Determine suffix to preserve (from whichever source had the version) --
+$suffix = !empty($manifestSuffix) ? $manifestSuffix : '';
+$newFull = $suffix !== '' ? "{$new}-{$suffix}" : $new;
+
+// -- Update .mokogitea/manifest.xml (canonical target, no suffix) --
if (file_exists($mokoManifest) && !empty($mokoContent)) {
$updated = preg_replace(
- '|\d{2}\.\d{2}\.\d{2}|',
+ '|\d{2}\.\d{2}\.\d{2}(?:-[a-z]+)?|',
"{$new}",
$mokoContent,
1
@@ -146,7 +152,7 @@ foreach ($xmlPatterns as $pattern) {
}
$newContent = preg_replace(
'|\d{2}\.\d{2}\.\d{2}(?:-[a-z]+)?|',
- "{$new}",
+ "{$newFull}",
$content
);
if ($newContent !== $content) {
@@ -190,5 +196,5 @@ if (file_exists($pyprojectFile)) {
}
}
-echo "{$old} -> {$new}\n";
+echo "{$old} -> {$newFull}\n";
exit(0);
diff --git a/cli/version_read.php b/cli/version_read.php
index cb45c93..f4c5457 100644
--- a/cli/version_read.php
+++ b/cli/version_read.php
@@ -54,6 +54,7 @@ if (file_exists($readme)) {
// -- 3. Fallback: Joomla manifest XML --
$manifestVersion = null;
+$manifestVersionSuffix = '';
$manifestFiles = array_merge(
glob("{$root}/src/pkg_*.xml") ?: [],
glob("{$root}/src/*.xml") ?: [],
@@ -66,10 +67,12 @@ foreach ($manifestFiles as $xmlFile) {
if (strpos($xmlContent, '') === false) {
continue;
}
- if (preg_match('|(\d{2}\.\d{2}\.\d{2})(?:-[a-z]+)?|', $xmlContent, $xm)) {
+ if (preg_match('|(\d{2}\.\d{2}\.\d{2})(-[a-z]+)?|', $xmlContent, $xm)) {
$candidate = $xm[1];
+ $candidateSuffix = isset($xm[2]) ? $xm[2] : '';
if ($manifestVersion === null || version_compare($candidate, $manifestVersion, '>')) {
$manifestVersion = $candidate;
+ $manifestVersionSuffix = $candidateSuffix;
}
}
}
@@ -103,9 +106,11 @@ $candidates = array_filter([
]);
$version = null;
+$versionSource = '';
foreach ($candidates as $candidate) {
if ($version === null || version_compare($candidate, $version, '>')) {
$version = $candidate;
+ $versionSource = ($candidate === $manifestVersion) ? 'manifest' : 'other';
}
}
@@ -114,6 +119,11 @@ if ($version === null) {
exit(1);
}
+// Append suffix if the version came from a Joomla manifest with a suffix
+if ($versionSource === 'manifest' && !empty($manifestVersionSuffix)) {
+ $version .= $manifestVersionSuffix;
+}
+
// -- Backfill: if manifest.xml exists but lacks , insert it --
if (file_exists($mokoManifest)) {
$content = file_get_contents($mokoManifest);