feat(cli): skip version bump when only non-code files change
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
Generic: Repo Health / Site Health (pull_request) Has been cancelled
Generic: Repo Health / Access control (pull_request) Has been cancelled
Universal: Secret Scanning / Gitleaks Secret Scan (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
Universal: Auto Version Bump / Version Bump (push) Has been cancelled
Generic: Repo Health / Access control (push) Has been cancelled
Generic: Repo Health / Site Health (push) Has been cancelled
Universal: Build & Release / Promote to RC (pull_request) Has been cancelled
Universal: Build & Release / Build & Release Pipeline (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (push) Has been cancelled
Platform: moko-platform CI / Gate 1: Code Quality (pull_request) 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
Platform: moko-platform CI / Gate 2: Unit Tests (8.1) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.2) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 2: Unit Tests (8.3) (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 3: Self-Health Check (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 4: Governance (pull_request) Has been cancelled
Platform: moko-platform CI / Gate 5: Template Integrity (pull_request) Has been cancelled
Platform: moko-platform CI / CI Summary (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Generic: Repo Health / Release configuration (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) 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

version_auto_bump now checks if files in the code directory (src/)
changed in the last commit. If only docs/workflows/config changed,
the bump is skipped entirely.

Watch path auto-detected from manifest.xml <entry-point> tag,
or can be passed explicitly via --watch-path.

Authored-by: Moko Consulting
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jonathan Miller
2026-05-30 09:12:34 -05:00
parent 334bb15184
commit 2b5e394eec
+42 -14
View File
@@ -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