diff --git a/cli/release_publish.php b/cli/release_publish.php index a6bccd8..957de2c 100644 --- a/cli/release_publish.php +++ b/cli/release_publish.php @@ -34,6 +34,7 @@ class ReleasePublishCli extends CliFramework $this->addArgument('--org', 'Organization', ''); $this->addArgument('--repo', 'Repository name', ''); $this->addArgument('--repo-url', 'Repository URL for git auth', ''); + $this->addArgument('--skip-update-stream', 'Skip updates.xml generation and sync (managed externally)', false); } protected function run(): int @@ -46,7 +47,8 @@ class ReleasePublishCli extends CliFramework $giteaUrl = $this->getArgument('--gitea-url') ?: (getenv('GITEA_URL') ?: 'https://git.mokoconsulting.tech'); $org = $this->getArgument('--org') ?: (getenv('GITEA_ORG') ?: ''); $repo = $this->getArgument('--repo') ?: (getenv('GITEA_REPO') ?: ''); - $repoUrl = $this->getArgument('--repo-url'); + $repoUrl = $this->getArgument('--repo-url'); + $skipUpdateStream = $this->getArgument('--skip-update-stream'); if (empty($stability) || empty($token)) { $this->log('ERROR', "Usage: release_publish.php --stability --token TOKEN [options]"); @@ -295,66 +297,71 @@ class ReleasePublishCli extends CliFramework // -- Step 4: No lesser stream copies -- echo "\n--- Step 4: Skipped (no lesser stream copies) ---\n"; - // -- Step 5: Update ONLY this stream in updates.xml -- - echo "\n--- Step 5: Update {$stability} stream in updates.xml ---\n"; - $streamsToWrite = [$stability]; + if ($skipUpdateStream) { + echo "\n--- Step 5: Skipped (--skip-update-stream) ---\n"; + echo "\n--- Step 6: Skipped (--skip-update-stream) ---\n"; + } else { + // -- Step 5: Update ONLY this stream in updates.xml -- + echo "\n--- Step 5: Update {$stability} stream in updates.xml ---\n"; + $streamsToWrite = [$stability]; - foreach ($streamsToWrite as $stream) { - $streamVersion = $releaseVersion; - $shaFlag = !empty($sha256) ? "--sha {$sha256}" : ''; + foreach ($streamsToWrite as $stream) { + $streamVersion = $releaseVersion; + $shaFlag = !empty($sha256) ? "--sha {$sha256}" : ''; + + echo " Writing {$stream} stream: {$streamVersion}\n"; + if (!$this->dryRun) { + passthru("{$php} {$cli}/updates_xml_build.php --path " . escapeshellarg($path) + . " --version " . escapeshellarg($streamVersion) + . " --stability " . escapeshellarg($stream) + . " --gitea-url " . escapeshellarg($giteaUrl) + . " --org " . escapeshellarg($org) + . " --repo " . escapeshellarg($repo) + . " {$shaFlag} 2>&1"); + } + } + + // -- Step 6: Commit updates.xml and sync to all branches -- + echo "\n--- Step 6: Commit and sync updates.xml ---\n"; + $root = realpath($path) ?: $path; - echo " Writing {$stream} stream: {$streamVersion}\n"; if (!$this->dryRun) { - passthru("{$php} {$cli}/updates_xml_build.php --path " . escapeshellarg($path) - . " --version " . escapeshellarg($streamVersion) - . " --stability " . escapeshellarg($stream) + $cdX = PHP_OS_FAMILY === 'Windows' ? "cd /d " : "cd "; + $cdRt = $cdX . escapeshellarg($root); + $diffCheck = trim((string) @shell_exec( + $cdRt . " && git diff --quiet updates.xml" + . " 2>&1 && echo clean || echo dirty" + )); + if ($diffCheck === 'dirty') { + @shell_exec($cdRt . " && git add updates.xml"); + $chMsg = "chore: update channels for" + . " {$releaseVersion} [skip ci]"; + @shell_exec( + $cdRt . " && git commit -m " + . escapeshellarg($chMsg) + . " --author=\"gitea-actions[bot]" + . " \"" + ); + @shell_exec( + $cdRt . " && git push origin " + . escapeshellarg($branch) . " 2>&1" + ); + echo " Committed updates.xml\n"; + } + + // Sync to all branches + passthru("{$php} {$cli}/updates_xml_sync.php --path " . escapeshellarg($path) + . " --current " . escapeshellarg($branch) . " --all" + . " --version " . escapeshellarg($releaseVersion) + . " --token " . escapeshellarg($token) . " --gitea-url " . escapeshellarg($giteaUrl) . " --org " . escapeshellarg($org) - . " --repo " . escapeshellarg($repo) - . " {$shaFlag} 2>&1"); + . " --repo " . escapeshellarg($repo) . " 2>&1"); + } else { + echo "[DRY-RUN] Would commit updates.xml and sync to all branches\n"; } } - // -- Step 6: Commit updates.xml and sync to all branches -- - echo "\n--- Step 6: Commit and sync updates.xml ---\n"; - $root = realpath($path) ?: $path; - - if (!$this->dryRun) { - $cdX = PHP_OS_FAMILY === 'Windows' ? "cd /d " : "cd "; - $cdRt = $cdX . escapeshellarg($root); - $diffCheck = trim((string) @shell_exec( - $cdRt . " && git diff --quiet updates.xml" - . " 2>&1 && echo clean || echo dirty" - )); - if ($diffCheck === 'dirty') { - @shell_exec($cdRt . " && git add updates.xml"); - $chMsg = "chore: update channels for" - . " {$releaseVersion} [skip ci]"; - @shell_exec( - $cdRt . " && git commit -m " - . escapeshellarg($chMsg) - . " --author=\"gitea-actions[bot]" - . " \"" - ); - @shell_exec( - $cdRt . " && git push origin " - . escapeshellarg($branch) . " 2>&1" - ); - echo " Committed updates.xml\n"; - } - - // Sync to all branches - passthru("{$php} {$cli}/updates_xml_sync.php --path " . escapeshellarg($path) - . " --current " . escapeshellarg($branch) . " --all" - . " --version " . escapeshellarg($releaseVersion) - . " --token " . escapeshellarg($token) - . " --gitea-url " . escapeshellarg($giteaUrl) - . " --org " . escapeshellarg($org) - . " --repo " . escapeshellarg($repo) . " 2>&1"); - } else { - echo "[DRY-RUN] Would commit updates.xml and sync to all branches\n"; - } - echo "\n=== Release published: {$releaseVersion} ===\n"; // Output for CI