Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
2025-10-10 15:34:36 +08:00
5 changed files with 200 additions and 11 deletions

View File

@@ -301,32 +301,58 @@ class DatabaseVersionManager:
def update_config_version(self, new_version: str):
"""更新config.py中的APP_VERSION"""
logger.info(f"正在更新config.py到版本: {new_version}")
logger.info(f"配置文件路径: {self.config_file}")
logger.info(f"配置文件绝对路径: {self.config_file.absolute()}")
logger.info(f"配置文件是否存在: {self.config_file.exists()}")
if not self.config_file.exists():
logger.warning(f"配置文件不存在: {self.config_file}")
logger.error(f"配置文件不存在: {self.config_file}")
return False
try:
# 读取文件
with open(self.config_file, 'r', encoding='utf-8') as f:
content = f.read()
logger.info(f"已读取config.py文件大小: {len(content)} 字节")
# 查找当前版本
import re
pattern = r'APP_VERSION\s*=\s*["\'][\d.]+["\']'
replacement = f'APP_VERSION = "{new_version}"'
match = re.search(pattern, content)
if re.search(pattern, content):
if match:
old_version_line = match.group(0)
logger.info(f"找到当前版本行: {old_version_line}")
replacement = f'APP_VERSION = "{new_version}"'
new_content = re.sub(pattern, replacement, content)
logger.info(f"准备写入新版本: {replacement}")
# 写入文件
with open(self.config_file, 'w', encoding='utf-8') as f:
f.write(new_content)
# 验证写入
with open(self.config_file, 'r', encoding='utf-8') as f:
verify_content = f.read()
verify_match = re.search(pattern, verify_content)
if verify_match:
logger.info(f"✅ 写入验证成功: {verify_match.group(0)}")
logger.info(f"✅ 已更新 config.py: APP_VERSION = \"{new_version}\"")
return True
else:
logger.warning("未找到APP_VERSION配置项")
logger.error(f"未找到APP_VERSION配置项pattern: {pattern}")
logger.info(f"文件内容预览前200字符: {content[:200]}")
return False
except Exception as e:
logger.error(f"更新config.py失败: {e}")
logger.error(f"更新config.py失败: {e}")
import traceback
logger.error(traceback.format_exc())
return False
def create_version_record(self) -> dict:

View File

@@ -5,7 +5,6 @@
用于查看和管理GUI客户端的版本历史记录
"""
import sys
import json
import argparse
from pathlib import Path

View File

@@ -141,23 +141,43 @@ jobs:
git config user.name "Gitea Actions Bot"
git config user.email "bot@gitea.local"
# 检查文件状态
Write-Host "=== Git Status Before Add ==="
git status
Write-Host "`n=== Checking file changes ==="
Write-Host "config.py changes:"
git diff config.py | Select-Object -First 10
Write-Host "version_history.json changes:"
git diff version_history.json | Select-Object -First 10
# 添加修改的文件
Write-Host "`n=== Adding files ==="
git add config.py
Write-Host "Added config.py"
git add version_history.json
Write-Host "Added version_history.json"
# 检查暂存区
Write-Host "`n=== Git Status After Add ==="
git status
Write-Host "`n=== Staged changes ==="
git diff --staged --stat
# 检查是否有变更
$hasChanges = git diff --staged --quiet
if ($LASTEXITCODE -ne 0) {
# 动态获取当前分支名(兼容 master 和 develop
$BRANCH = "${{ github.ref_name }}"
Write-Host "Committing to branch: $BRANCH"
Write-Host "`nCommitting to branch: $BRANCH"
git commit -m "[skip ci] 🤖 自动更新版本到 v$VERSION"
git commit -m "[skip ci] Update version to v$VERSION"
git push origin $BRANCH
Write-Host "Version changes committed and pushed to $BRANCH"
Write-Host "Version changes committed and pushed to $BRANCH"
} else {
Write-Host " No changes to commit"
Write-Host "No changes to commit"
}
# Step 6: Display summary