Files
nezhacursor/update_version.py
2025-02-12 09:45:55 +08:00

27 lines
731 B
Python

def increment_version(version_str):
major, minor, patch = map(int, version_str.split('.'))
patch += 1
if patch >= 10:
patch = 0
minor += 1
if minor >= 10:
minor = 0
major += 1
return f"{major}.{minor}.{patch}"
def update_version():
# 读取当前版本
with open('version.txt', 'r', encoding='utf-8') as f:
current_version = f.read().strip()
# 计算新版本
new_version = increment_version(current_version)
# 写入新版本
with open('version.txt', 'w', encoding='utf-8') as f:
f.write(new_version)
print(f"版本号已从 {current_version} 更新到 {new_version}")
if __name__ == '__main__':
update_version()