diff --git a/cli/updates_xml_build.php b/cli/updates_xml_build.php index 60e7616..681f639 100644 --- a/cli/updates_xml_build.php +++ b/cli/updates_xml_build.php @@ -299,6 +299,7 @@ $stabilitySuffixMap = [ 'beta' => '-beta', 'alpha' => '-alpha', 'development' => '-dev', + 'dev' => '-dev', ]; // Joomla values — maps to Joomla's stabilityTagToInteger() @@ -308,6 +309,7 @@ $stabilityTagMap = [ 'beta' => 'beta', 'alpha' => 'alpha', 'development' => 'dev', + 'dev' => 'dev', ]; // Gitea release tag names (used in download/info URLs) @@ -317,6 +319,7 @@ $releaseTagMap = [ 'beta' => 'beta', 'alpha' => 'alpha', 'development' => 'development', + 'dev' => 'development', ]; // -- Build update entries ----------------------------------------------------- diff --git a/cli/version_auto_bump.php b/cli/version_auto_bump.php index f7de29e..350ba9a 100644 --- a/cli/version_auto_bump.php +++ b/cli/version_auto_bump.php @@ -26,11 +26,14 @@ $token = ''; $repoUrl = ''; $dryRun = false; +$watchPath = ''; + foreach ($argv as $i => $arg) { - if ($arg === '--path' && isset($argv[$i + 1])) $path = $argv[$i + 1]; - if ($arg === '--branch' && isset($argv[$i + 1])) $branch = $argv[$i + 1]; - if ($arg === '--token' && isset($argv[$i + 1])) $token = $argv[$i + 1]; - if ($arg === '--repo-url' && isset($argv[$i + 1])) $repoUrl = $argv[$i + 1]; + if ($arg === '--path' && isset($argv[$i + 1])) $path = $argv[$i + 1]; + if ($arg === '--branch' && isset($argv[$i + 1])) $branch = $argv[$i + 1]; + if ($arg === '--token' && isset($argv[$i + 1])) $token = $argv[$i + 1]; + if ($arg === '--repo-url' && isset($argv[$i + 1])) $repoUrl = $argv[$i + 1]; + if ($arg === '--watch-path' && isset($argv[$i + 1])) $watchPath = $argv[$i + 1]; if ($arg === '--dry-run') $dryRun = true; } @@ -62,17 +65,42 @@ if (array_key_exists($branch, $stabilityMap)) { $cli = __DIR__; $php = PHP_BINARY; -// Step 1: Patch bump — all branches get patch bumps -$shouldBump = true; - -if ($shouldBump) { - $bumpOutput = []; - exec("{$php} {$cli}/version_bump.php --path " . escapeshellarg($path) . " 2>&1", $bumpOutput, $bumpRc); - foreach ($bumpOutput as $line) { - echo "{$line}\n"; +// Auto-detect watch path from manifest.xml if not provided +if (empty($watchPath)) { + $manifestFile = realpath($path) . '/.mokogitea/manifest.xml'; + if (file_exists($manifestFile)) { + $xml = @simplexml_load_file($manifestFile); + if ($xml && isset($xml->build->{'entry-point'})) { + $watchPath = (string) $xml->build->{'entry-point'}; + } } -} else { - echo "Skipping patch bump on {$branch} branch (suffix change only)\n"; +} + +// Check if code files actually changed (skip bump for docs/config-only changes) +$shouldBump = true; +if (!empty($watchPath)) { + $root = realpath($path) ?: $path; + $diffOutput = trim((string) @shell_exec( + "cd " . escapeshellarg($root) . " && git diff --name-only HEAD~1 HEAD -- " . escapeshellarg($watchPath) . " 2>/dev/null" + )); + if (empty($diffOutput)) { + echo "No changes in {$watchPath} — skipping version bump\n"; + $shouldBump = false; + } else { + echo "Changes detected in {$watchPath}:\n{$diffOutput}\n"; + } +} + +if (!$shouldBump) { + echo "No code changes — nothing to do\n"; + exit(0); +} + +// Step 1: Patch bump +$bumpOutput = []; +exec("{$php} {$cli}/version_bump.php --path " . escapeshellarg($path) . " 2>&1", $bumpOutput, $bumpRc); +foreach ($bumpOutput as $line) { + echo "{$line}\n"; } // Step 2: Read version