Public Access
7728b6b4ac
Universal: Pre-Release / Build Pre-Release (${{ inputs.stability || github.ref_name }}) (push) Successful in 12s
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Universal: PR Check / Validate PR (pull_request) Failing after 7s
Universal: PR Check / Secret Scan (pull_request) Successful in 10s
Platform: mokocli CI / Gate 1: Code Quality (pull_request) Failing after 1m3s
Platform: mokocli CI / Gate 2: Unit Tests (8.1) (pull_request) Has been cancelled
Platform: mokocli CI / Gate 2: Unit Tests (8.2) (pull_request) Has been cancelled
Platform: mokocli CI / Gate 2: Unit Tests (8.3) (pull_request) Has been cancelled
Platform: mokocli CI / Gate 3: Self-Health Check (pull_request) Has been cancelled
Platform: mokocli CI / Gate 4: Governance (pull_request) Has been cancelled
Platform: mokocli CI / Gate 5: Template Integrity (pull_request) Has been cancelled
Platform: mokocli CI / CI Summary (pull_request) Has been cancelled
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
MokoGitea instance rebrand to MokoGit. Content sweep over 265 files (ordered to avoid
moko-prefix doubling) plus path renames:
- .mokogitea/ -> .mokogit/ (repo + all mcp/servers/*)
- templates/mokogitea/ -> templates/mokogit/
- lib/Enterprise/MokoGiteaAdapter.php -> MokoGitAdapter.php (class MokoGitAdapter)
- mcp/servers/mokogitea_{skill,api} -> mokogit_{skill,api}; skills/mokogitea -> skills/mokogit
- automation/migrate_to_gitea.php -> migrate_to_mokogit.php
- env/secret names GITEA_* -> MOKOGIT_*
Note: ~/.claude/.mcp.json server flipped to @mokoconsulting/mcp-mokogit (publish pending).
167 lines
6.4 KiB
PHP
167 lines
6.4 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
*
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
*
|
|
* FILE INFORMATION
|
|
* DEFGROUP: mokocli.CLI
|
|
* INGROUP: mokocli
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/mokocli
|
|
* PATH: /cli/version_set_platform.php
|
|
* BRIEF: Set version in platform-specific files (Dolibarr $this->version, Joomla <version>)
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/../lib/Enterprise/CliFramework.php';
|
|
|
|
use MokoCli\{CliFramework, SourceResolver, PlatformDetector};
|
|
|
|
class VersionSetPlatformCli extends CliFramework
|
|
{
|
|
protected function configure(): void
|
|
{
|
|
$this->setDescription('Set version in platform-specific files (Dolibarr $this->version, Joomla <version>)');
|
|
$this->addArgument('--path', 'Repository root path', '.');
|
|
$this->addArgument('--version', 'Version string XX.YY.ZZ', '');
|
|
$this->addArgument('--branch', 'Git branch name', '');
|
|
$this->addArgument('--stability', 'Stability level (stable, dev, alpha, beta, rc)', 'stable');
|
|
}
|
|
|
|
protected function run(): int
|
|
{
|
|
$path = $this->getArgument('--path');
|
|
$version = $this->getArgument('--version');
|
|
$branch = $this->getArgument('--branch');
|
|
$stability = $this->getArgument('--stability');
|
|
|
|
// Auto-detect branch from git or GitHub env
|
|
if ($branch === '') {
|
|
$branch = trim((string) @shell_exec('git rev-parse --abbrev-ref HEAD 2>/dev/null'));
|
|
if (empty($branch) || $branch === 'HEAD') {
|
|
$branch = getenv('GITHUB_REF_NAME') ?: 'main';
|
|
}
|
|
}
|
|
|
|
if ($version === '') {
|
|
$this->log('ERROR', 'Usage: version_set_platform.php --path . --version 04.01.00 [--stability dev]');
|
|
return 1;
|
|
}
|
|
|
|
// Strip any existing suffix(es) before applying the correct one
|
|
$version = preg_replace('/(-(dev|alpha|beta|rc))+$/', '', $version);
|
|
|
|
// Validate version format — must be XX.YY.ZZ to prevent XML corruption
|
|
if (!preg_match('/^\d{2}\.\d{2}\.\d{2}$/', $version)) {
|
|
$this->log('ERROR', "Invalid version format: '{$version}' — expected XX.YY.ZZ");
|
|
return 1;
|
|
}
|
|
|
|
// Append stability suffix for non-stable releases
|
|
$stabilitySuffixMap = [
|
|
'stable' => '',
|
|
'development' => '-dev',
|
|
'dev' => '-dev',
|
|
'alpha' => '-alpha',
|
|
'beta' => '-beta',
|
|
'rc' => '-rc',
|
|
'release-candidate' => '-rc',
|
|
];
|
|
$suffix = $stabilitySuffixMap[$stability] ?? '';
|
|
if ($suffix !== '' && !str_ends_with($version, $suffix)) {
|
|
$version .= $suffix;
|
|
echo "Version with stability suffix: {$version}\n";
|
|
}
|
|
|
|
$root = realpath($path) ?: $path;
|
|
|
|
// Detect platform from repo files (.mokogit/manifest.xml retired) and translate to
|
|
// the stamp vocabulary this tool branches on below (crm-module / waas-component).
|
|
$platform = PlatformDetector::toStampPlatform(PlatformDetector::detect($root));
|
|
|
|
$changed = 0;
|
|
|
|
// Dolibarr: $this->version + $this->url_last_version in mod*.class.php
|
|
if ($platform === 'crm-module') {
|
|
$srcName = SourceResolver::resolve($root);
|
|
$pattern = "{$root}/{$srcName}/core/modules/mod*.class.php";
|
|
foreach (glob($pattern) ?: [] as $file) {
|
|
$content = file_get_contents($file);
|
|
|
|
// Set $this->version
|
|
$updated = preg_replace(
|
|
'/(\$this->version\s*=\s*)[\'"][^\'"]*[\'"]/',
|
|
"\${1}'{$version}'",
|
|
$content
|
|
);
|
|
|
|
// Rewrite $this->url_last_version to point to current branch
|
|
if (preg_match('/\$this->url_last_version\s*=\s*[\'"]([^\'"]+)[\'"]/', $updated, $urlMatch)) {
|
|
$oldUrl = $urlMatch[1];
|
|
// Replace the branch segment: .../BRANCH/update.txt
|
|
$newUrl = preg_replace(
|
|
'#(raw\.githubusercontent\.com/[^/]+/[^/]+/)[^/]+(/update\.json)#',
|
|
"\${1}{$branch}\${2}",
|
|
$oldUrl
|
|
);
|
|
if ($newUrl !== $oldUrl) {
|
|
$updated = str_replace($oldUrl, $newUrl, $updated);
|
|
echo "Dolibarr: url_last_version → {$branch}/update.txt\n";
|
|
}
|
|
}
|
|
|
|
if ($updated !== $content) {
|
|
file_put_contents($file, $updated);
|
|
echo "Dolibarr: " . basename($file) . " → version={$version}, branch={$branch}\n";
|
|
$changed++;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Joomla: <version> in XML manifests (top-level + sub-packages)
|
|
if (in_array($platform, ['waas-component', 'joomla'], true)) {
|
|
$srcName = SourceResolver::resolve($root);
|
|
$xmlFiles = array_merge(
|
|
glob("{$root}/{$srcName}/*.xml") ?: [],
|
|
glob("{$root}/{$srcName}/packages/*/*.xml") ?: [],
|
|
glob("{$root}/*.xml") ?: []
|
|
);
|
|
if (empty($xmlFiles)) {
|
|
$xmlFiles = glob("{$root}/*.xml") ?: [];
|
|
}
|
|
foreach ($xmlFiles as $file) {
|
|
$content = file_get_contents($file);
|
|
if (!str_contains($content, '<extension')) {
|
|
continue;
|
|
}
|
|
$updated = preg_replace(
|
|
'|<version>[^<]*</version>|',
|
|
"<version>{$version}</version>",
|
|
$content
|
|
);
|
|
if ($updated !== null && $updated !== $content) {
|
|
file_put_contents($file, $updated);
|
|
$relPath = str_replace($root . '/', '', $file);
|
|
echo "Joomla: {$relPath} → {$version}\n";
|
|
$changed++;
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($changed === 0) {
|
|
if (empty($platform)) {
|
|
echo "No manifest.xml file — skipping platform version set\n";
|
|
} else {
|
|
echo "No platform-specific version files found for {$platform}\n";
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
$app = new VersionSetPlatformCli();
|
|
exit($app->execute());
|