55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
import os, shutil
|
|
from datetime import datetime
|
|
|
|
# 更新日志
|
|
CHANGELOG = {
|
|
"assembly-dll": """无""",
|
|
"shaderassets0-assets": """无""",
|
|
"code-csharp": """无""",
|
|
"images-l10n": """无""",
|
|
"rules": """无""",
|
|
}
|
|
|
|
|
|
# 自动撰写更新日志
|
|
def update_changelog():
|
|
current_time = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
|
|
with open("buildnumber.txt", "r+") as f:
|
|
version = int(f.read())
|
|
f.seek(0)
|
|
f.write(str(version + 1))
|
|
|
|
# 将时间和版本号写入changelog.md
|
|
with open("changelog.md", "r+") as f:
|
|
f.seek(0, 2) # 移动到文件末尾
|
|
f.write(f"## 版本号: V{version}\n\n > 构建时间:{current_time}\n\n")
|
|
for key, value in CHANGELOG.items():
|
|
f.write(f"### {key} 更新内容:\n\n{value}\n\n")
|
|
|
|
|
|
# 更新历史记录的7z文件并打包
|
|
def update_history7z(process):
|
|
# 使用7z命令行工具解压history.7z到临时文件夹
|
|
update_changelog()
|
|
with open("buildnumber.txt", "r+") as f:
|
|
version = int(f.read())
|
|
for key in process:
|
|
if not os.path.exists(f"{key}/history.7z"):
|
|
os.system(f"cd {key} && 7z a history.7z original.{key.split('-')[1]}")
|
|
os.system(f"7z x {key}/history.7z -otmp/{key}")
|
|
os.remove(f"{key}/history.7z")
|
|
# 将latest.dll/assets重命名为{VERSION}.dll/assets
|
|
shutil.copy(
|
|
f"{key}/latest.{key.split('-')[1]}",
|
|
f"tmp/{key}/V{version}.{key.split('-')[1]}",
|
|
)
|
|
# 重新压缩
|
|
os.system(f"cd tmp/{key} && 7z a ../../{key}/history.7z *")
|
|
# 删除临时文件夹
|
|
shutil.rmtree(f"tmp/{key}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
# update_changelog()
|
|
update_history7z(["assembly-dll", "shaderassets0-assets"])
|