v1.0.10
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/**
|
||||
* 版本号递增脚本(每次修改代码后运行一次)
|
||||
* 用法:php tools/bump_version.php
|
||||
*
|
||||
* 规则:v1.0.01 -> v1.0.02 -> ... -> v1.0.99 -> v1.1.00 -> v1.1.01 -> ... -> v1.99.99 -> v2.0.00
|
||||
* 即:末两位递增,到 99 后向前进位(末位归 00,中间位 +1);中间位到 99 后主版本 +1。
|
||||
* 版本号保存在 static/js/config.js 的 APP_VERSION 中(logo 旁展示)。
|
||||
*/
|
||||
|
||||
$file = __DIR__ . '/../static/js/config.js';
|
||||
if (!is_file($file)) {
|
||||
fwrite(STDERR, "[错误] 找不到 " . $file . "\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$content = file_get_contents($file);
|
||||
if (!preg_match("/APP_VERSION\s*=\s*'([^']+)'/", $content, $m)) {
|
||||
fwrite(STDERR, "[错误] 无法在 config.js 中解析 APP_VERSION\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$old = $m[1];
|
||||
if (!preg_match('/^v(\d+)\.(\d+)\.(\d+)$/', $old, $p)) {
|
||||
fwrite(STDERR, "[错误] 版本号格式不正确:$old(应为 v1.0.01 格式)\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$major = (int)$p[1];
|
||||
$minor = (int)$p[2];
|
||||
$patch = (int)$p[3];
|
||||
|
||||
// 递增:末两位 +1,到 99 进位
|
||||
$patch++;
|
||||
if ($patch > 99) {
|
||||
$patch = 0;
|
||||
$minor++;
|
||||
}
|
||||
if ($minor > 99) {
|
||||
$minor = 0;
|
||||
$major++;
|
||||
}
|
||||
|
||||
$new = sprintf('v%d.%d.%02d', $major, $minor, $patch);
|
||||
$content = str_replace($m[0], "APP_VERSION = '$new'", $content);
|
||||
file_put_contents($file, $content);
|
||||
|
||||
echo "版本已更新:$old -> $new\n";
|
||||
Reference in New Issue
Block a user