automatically adding versions

This commit is contained in:
2024-09-26 01:09:02 +02:00
parent 5773196018
commit 13d2d400bd
2 changed files with 33 additions and 7 deletions

View File

@@ -10,6 +10,30 @@ def extract_version(filename):
return (0, 0, 0)
def update_bug_template(versions):
template_file = ".github/ISSUE_TEMPLATE/BUG.yml"
with open(template_file, "r") as file:
lines = file.readlines()
updated_lines = []
in_options_section = False
for line in lines:
if "options:" in line:
in_options_section = True
updated_lines.append(line)
for version in versions:
updated_lines.append(f" - {version}\n")
elif in_options_section and line.strip().startswith("-"):
continue
else:
updated_lines.append(line)
with open(template_file, "w") as file:
file.writelines(updated_lines)
directory = "mrpack"
changelog_directory = "changelogs"
files = [f for f in os.listdir(directory) if f.endswith(".mrpack")]
@@ -33,5 +57,10 @@ if len(files_sorted) > 1:
)
print(f"Changelog generated: {changelog_directory}/{changelog_filename}")
versions = [".".join(map(str, extract_version(f))) for f in files_sorted]
update_bug_template(versions)
print(f"Updated .github/ISSUE_TEMPLATE/BUG.yml with versions: {versions}")
else:
print("Not enough .mrpack files found in the directory to generate a changelog.")