2025-02-05 11:32:35 +01:00
|
|
|
#!/usr/bin/env python
|
2025-02-05 11:39:09 +01:00
|
|
|
"""generate_release.py.
|
2025-02-05 11:32:35 +01:00
|
|
|
|
|
|
|
This script is used to generate the release.yml file as per
|
|
|
|
https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
|
|
|
|
"""
|
|
|
|
|
|
|
|
import yaml
|
|
|
|
|
|
|
|
SCOPES = [
|
|
|
|
"anta",
|
|
|
|
"anta.tests",
|
|
|
|
"anta.cli",
|
|
|
|
]
|
|
|
|
|
|
|
|
# CI and Test are excluded from Release Notes
|
|
|
|
CATEGORIES = {
|
|
|
|
"feat": "Features",
|
|
|
|
"fix": "Bug Fixes",
|
|
|
|
"cut": "Cut",
|
|
|
|
"doc": "Documentation",
|
|
|
|
"bump": "Bump",
|
|
|
|
"revert": "Revert",
|
|
|
|
"refactor": "Refactoring",
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class SafeDumper(yaml.SafeDumper):
|
2025-02-05 11:39:09 +01:00
|
|
|
"""Make yamllint happy
|
|
|
|
https://github.com/yaml/pyyaml/issues/234#issuecomment-765894586.
|
2025-02-05 11:32:35 +01:00
|
|
|
"""
|
|
|
|
|
2025-02-05 11:54:55 +01:00
|
|
|
# pylint: disable=R0901
|
2025-02-05 11:32:35 +01:00
|
|
|
|
|
|
|
def increase_indent(self, flow=False, *args, **kwargs):
|
|
|
|
return super().increase_indent(flow=flow, indentless=False)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
exclude_list = []
|
|
|
|
categories_list = []
|
|
|
|
|
|
|
|
# First add exclude labels
|
|
|
|
for scope in SCOPES:
|
|
|
|
exclude_list.append(f"rn: test({scope})")
|
|
|
|
exclude_list.append(f"rn: ci({scope})")
|
|
|
|
exclude_list.extend(["rn: test", "rn: ci"])
|
|
|
|
|
|
|
|
# Then add the categories
|
|
|
|
# First add Breaking Changes
|
|
|
|
breaking_label_categories = ["feat", "fix", "cut", "revert", "refactor", "bump"]
|
|
|
|
breaking_labels = [f"rn: {cc_type}({scope})!" for cc_type in breaking_label_categories for scope in SCOPES]
|
|
|
|
breaking_labels.extend([f"rn: {cc_type}!" for cc_type in breaking_label_categories])
|
|
|
|
|
|
|
|
categories_list.append(
|
|
|
|
{
|
|
|
|
"title": "Breaking Changes",
|
|
|
|
"labels": breaking_labels,
|
2025-02-05 11:39:09 +01:00
|
|
|
},
|
2025-02-05 11:32:35 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Add new features
|
|
|
|
feat_labels = [f"rn: feat({scope})" for scope in SCOPES]
|
|
|
|
feat_labels.append("rn: feat")
|
|
|
|
|
|
|
|
categories_list.append(
|
|
|
|
{
|
|
|
|
"title": "New features and enhancements",
|
|
|
|
"labels": feat_labels,
|
2025-02-05 11:39:09 +01:00
|
|
|
},
|
2025-02-05 11:32:35 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Add fixes
|
|
|
|
fixes_labels = [f"rn: fix({scope})" for scope in SCOPES]
|
|
|
|
fixes_labels.append("rn: fix")
|
|
|
|
|
|
|
|
categories_list.append(
|
|
|
|
{
|
|
|
|
"title": "Fixed issues",
|
|
|
|
"labels": fixes_labels,
|
2025-02-05 11:39:09 +01:00
|
|
|
},
|
2025-02-05 11:32:35 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Add Documentation
|
|
|
|
doc_labels = [f"rn: doc({scope})" for scope in SCOPES]
|
|
|
|
doc_labels.append("rn: doc")
|
|
|
|
|
|
|
|
categories_list.append(
|
|
|
|
{
|
|
|
|
"title": "Documentation",
|
|
|
|
"labels": doc_labels,
|
2025-02-05 11:39:09 +01:00
|
|
|
},
|
2025-02-05 11:32:35 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
# Add the catch all
|
|
|
|
categories_list.append(
|
|
|
|
{
|
|
|
|
"title": "Other Changes",
|
|
|
|
"labels": ["*"],
|
2025-02-05 11:39:09 +01:00
|
|
|
},
|
2025-02-05 11:32:35 +01:00
|
|
|
)
|
|
|
|
with open(r"release.yml", "w", encoding="utf-8") as release_file:
|
|
|
|
yaml.dump(
|
|
|
|
{
|
|
|
|
"changelog": {
|
|
|
|
"exclude": {"labels": exclude_list},
|
|
|
|
"categories": categories_list,
|
2025-02-05 11:39:09 +01:00
|
|
|
},
|
2025-02-05 11:32:35 +01:00
|
|
|
},
|
|
|
|
release_file,
|
|
|
|
Dumper=SafeDumper,
|
|
|
|
sort_keys=False,
|
|
|
|
)
|