07ea171af9
Generic: Repo Health / Site Health (push) Has been skipped
Generic: Repo Health / Access control (push) Successful in 1s
Platform: moko-platform CI / Gate 1: Code Quality (push) Failing after 43s
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
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
New CLI tools: - manifest_element.php — extract element/type/prefix from any platform manifest - release_create.php — create/overwrite Gitea releases with proper naming - release_package.php — build ZIP+tar.gz, SHA-256, upload assets - release_promote.php — promote releases between channels (dev→RC→stable) - version_reset_dev.php — reset platform version on dev branch after release Updated CLI tools: - version_bump.php — now writes to manifests, Dolibarr mod, composer.json (not just README) - release_cascade.php — added --version for version-aware deletion of stale releases - release_validate.php — auto-detect platform, --github-output, source dir check Workflow changes (auto-release.yml): - Draft PR to main → auto-promote highest pre-release to RC - Merged PR to main → promote RC to stable (skip rebuild when RC exists) - Removed paths filter for Go/Node/generic repo compatibility - Fixed cascade --api-base parameter bug Workflow changes (pre-release.yml): - Auto-trigger development pre-release on feature branch merge to dev - Removed paths filter Infrastructure: - RepositorySynchronizer: fixed template repo names, .mokogitea/workflows path, universal workflow cascade (Template-Generic → other templates) - bulk_sync.php: syncs universal workflows to templates before repo sync - PHPDoc added to 4 classes missing class-level docs - Version bump 09.00.00 → 09.01.00 Closes #152 #153 #154 #155 #156 #157 #158 #159 #161 #162 Authored-by: Moko Consulting Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
203 lines
5.9 KiB
PHP
203 lines
5.9 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: moko-platform.CLI
|
|
* INGROUP: moko-platform
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
|
* PATH: /cli/version_bump.php
|
|
* BRIEF: Auto-increment version — manifest.xml is canonical, also updates README.md and Joomla XML
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
$path = '.';
|
|
$type = 'patch'; // patch | minor | major
|
|
foreach ($argv as $i => $arg) {
|
|
if ($arg === '--path' && isset($argv[$i + 1])) {
|
|
$path = $argv[$i + 1];
|
|
}
|
|
if ($arg === '--minor') {
|
|
$type = 'minor';
|
|
}
|
|
if ($arg === '--major') {
|
|
$type = 'major';
|
|
}
|
|
}
|
|
|
|
$root = realpath($path) ?: $path;
|
|
|
|
// -- 1. Read version from .mokogitea/manifest.xml (canonical) --
|
|
$mokoVersion = null;
|
|
$mokoManifest = "{$root}/.mokogitea/manifest.xml";
|
|
$mokoContent = '';
|
|
if (file_exists($mokoManifest)) {
|
|
$mokoContent = file_get_contents($mokoManifest);
|
|
if (preg_match('|<version>(\d{2}\.\d{2}\.\d{2})</version>|', $mokoContent, $m)) {
|
|
$mokoVersion = $m[1];
|
|
}
|
|
}
|
|
|
|
// -- 2. Fallback: README.md --
|
|
$readmeVersion = null;
|
|
$readme = "{$root}/README.md";
|
|
$readmeContent = '';
|
|
if (file_exists($readme)) {
|
|
$readmeContent = file_get_contents($readme);
|
|
if (preg_match('/VERSION:\s*(\d{2}\.\d{2}\.\d{2})/m', $readmeContent, $m)) {
|
|
$readmeVersion = $m[1];
|
|
}
|
|
}
|
|
|
|
// -- 3. Fallback: Joomla manifest XML --
|
|
$manifestVersion = null;
|
|
$manifestFiles = array_merge(
|
|
glob("{$root}/src/pkg_*.xml") ?: [],
|
|
glob("{$root}/src/*.xml") ?: [],
|
|
glob("{$root}/src/packages/*/mokowaas.xml") ?: [],
|
|
glob("{$root}/src/packages/*/*.xml") ?: [],
|
|
glob("{$root}/*.xml") ?: []
|
|
);
|
|
|
|
foreach ($manifestFiles as $xmlFile) {
|
|
$xmlContent = file_get_contents($xmlFile);
|
|
if (strpos($xmlContent, '<extension') === false && strpos($xmlContent, '<version>') === false) {
|
|
continue;
|
|
}
|
|
if (preg_match('|<version>(\d{2}\.\d{2}\.\d{2})(?:-[a-z]+)?</version>|', $xmlContent, $xm)) {
|
|
$candidate = $xm[1];
|
|
if ($manifestVersion === null || version_compare($candidate, $manifestVersion, '>')) {
|
|
$manifestVersion = $candidate;
|
|
}
|
|
}
|
|
}
|
|
|
|
// -- Use the highest version as base --
|
|
$baseVersion = null;
|
|
$candidates = array_filter([$mokoVersion, $readmeVersion, $manifestVersion]);
|
|
foreach ($candidates as $v) {
|
|
if ($baseVersion === null || version_compare($v, $baseVersion, '>')) {
|
|
$baseVersion = $v;
|
|
}
|
|
}
|
|
|
|
if ($baseVersion === null) {
|
|
fwrite(STDERR, "No version found in manifest.xml, README.md, or Joomla XML\n");
|
|
exit(1);
|
|
}
|
|
|
|
// -- Parse and bump --
|
|
if (!preg_match('/^(\d{2})\.(\d{2})\.(\d{2})$/', $baseVersion, $parts)) {
|
|
fwrite(STDERR, "Invalid version format: {$baseVersion}\n");
|
|
exit(1);
|
|
}
|
|
|
|
$major = (int)$parts[1];
|
|
$minor = (int)$parts[2];
|
|
$patch = (int)$parts[3];
|
|
$old = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
|
|
|
switch ($type) {
|
|
case 'major':
|
|
$major++;
|
|
$minor = 0;
|
|
$patch = 0;
|
|
break;
|
|
case 'minor':
|
|
$minor++;
|
|
$patch = 0;
|
|
break;
|
|
default:
|
|
$patch++;
|
|
if ($patch > 99) {
|
|
$minor++;
|
|
$patch = 0;
|
|
}
|
|
if ($minor > 99) {
|
|
$major++;
|
|
$minor = 0;
|
|
}
|
|
break;
|
|
}
|
|
|
|
$new = sprintf('%02d.%02d.%02d', $major, $minor, $patch);
|
|
|
|
// -- Update .mokogitea/manifest.xml (canonical target) --
|
|
if (file_exists($mokoManifest) && !empty($mokoContent)) {
|
|
$updated = preg_replace(
|
|
'|<version>\d{2}\.\d{2}\.\d{2}</version>|',
|
|
"<version>{$new}</version>",
|
|
$mokoContent,
|
|
1
|
|
);
|
|
file_put_contents($mokoManifest, $updated);
|
|
}
|
|
|
|
// -- Update README.md --
|
|
if (file_exists($readme) && !empty($readmeContent)) {
|
|
$updated = preg_replace(
|
|
'/(VERSION:\s*)\d{2}\.\d{2}\.\d{2}/m',
|
|
'${1}' . $new,
|
|
$readmeContent,
|
|
1
|
|
);
|
|
file_put_contents($readme, $updated);
|
|
}
|
|
|
|
// ── Update manifest XML files ────────────────────────────────────────────────
|
|
foreach ($manifestFiles as $xmlFile) {
|
|
$xmlContent = file_get_contents($xmlFile);
|
|
if (strpos($xmlContent, '<extension') === false && strpos($xmlContent, '<version>') === false) {
|
|
continue;
|
|
}
|
|
$updatedXml = preg_replace(
|
|
'|<version>\d{2}\.\d{2}\.\d{2}(?:-[a-z]+)?</version>|',
|
|
"<version>{$new}</version>",
|
|
$xmlContent
|
|
);
|
|
if ($updatedXml !== $xmlContent) {
|
|
file_put_contents($xmlFile, $updatedXml);
|
|
}
|
|
}
|
|
|
|
// ── Update Dolibarr mod*.class.php ───────────────────────────────────────────
|
|
$modFiles = array_merge(
|
|
glob("{$root}/src/core/modules/mod*.class.php") ?: [],
|
|
glob("{$root}/htdocs/core/modules/mod*.class.php") ?: []
|
|
);
|
|
foreach ($modFiles as $modFile) {
|
|
$modContent = file_get_contents($modFile);
|
|
if (strpos($modContent, 'extends DolibarrModules') === false) {
|
|
continue;
|
|
}
|
|
$updatedMod = preg_replace(
|
|
'/(\$this->version\s*=\s*)[\'"][^\'"]*[\'"]/',
|
|
"\${1}'{$new}'",
|
|
$modContent
|
|
);
|
|
if ($updatedMod !== $modContent) {
|
|
file_put_contents($modFile, $updatedMod);
|
|
}
|
|
}
|
|
|
|
// ── Update composer.json ─────────────────────────────────────────────────────
|
|
$composerFile = "{$root}/composer.json";
|
|
if (file_exists($composerFile)) {
|
|
$composerContent = file_get_contents($composerFile);
|
|
$updatedComposer = preg_replace(
|
|
'/("version"\s*:\s*")\d{2}\.\d{2}\.\d{2}(")/m',
|
|
'${1}' . $new . '${2}',
|
|
$composerContent
|
|
);
|
|
if ($updatedComposer !== $composerContent) {
|
|
file_put_contents($composerFile, $updatedComposer);
|
|
}
|
|
}
|
|
|
|
echo "{$old} → {$new}\n";
|
|
exit(0);
|