1 Star 0 Fork 1

LeChaPatteImpitoyable / sd-webui-controlnet

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
patch_version.py 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
Chenlei Hu 提交于 2023-11-12 22:01 . :hammer:Add patch version script (#2256)
import re
import subprocess
def get_current_version(filename):
version_pattern = r"version_flag\s*=\s*'v(\d+\.\d+\.\d+)'"
with open(filename, "r") as file:
content = file.read()
match = re.search(version_pattern, content)
if match:
return match.group(1)
else:
raise ValueError("Version number not found in the file")
def increment_version(version):
major, minor, patch = map(int, version.split("."))
patch += 1 # Increment the patch number
return f"{major}.{minor}.{patch}"
def update_version_file(filename, new_version):
with open(filename, "r") as file:
content = file.read()
new_content = re.sub(
r"version_flag = 'v\d+\.\d+\.\d+'", f"version_flag = 'v{new_version}'", content
)
with open(filename, "w") as file:
file.write(new_content)
def git_commit_and_tag(filename, new_version):
commit_message = f":memo: Update to version v{new_version}"
tag_name = f"v{new_version}"
# Commit the changes
subprocess.run(["git", "add", filename], check=True)
subprocess.run(["git", "commit", "-m", commit_message], check=True)
# Create a new tag
subprocess.run(["git", "tag", tag_name], check=True)
if __name__ == "__main__":
filename = "scripts/controlnet_version.py"
current_version = get_current_version(filename)
new_version = increment_version(current_version)
update_version_file(filename, new_version)
git_commit_and_tag(filename, new_version)
1
https://gitee.com/LeChaPatteImpitoyable/sd-webui-controlnet.git
git@gitee.com:LeChaPatteImpitoyable/sd-webui-controlnet.git
LeChaPatteImpitoyable
sd-webui-controlnet
sd-webui-controlnet
main

搜索帮助