forked from aristanetworks/avd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate_release.py
executable file
·211 lines (184 loc) · 5.78 KB
/
generate_release.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/env python
# Copyright (c) 2023-2024 Arista Networks, Inc.
# Use of this source code is governed by the Apache License 2.0
# that can be found in the LICENSE file.
"""
generate_release.py.
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
"""
from pathlib import Path
from typing import Any
import yaml
SCOPES = [
"build_output_folders",
"cvp_configlet_upload",
"dhcp_provisioner",
"cv_deploy",
"eos_cli_config_gen",
"eos_config_deploy_cvp",
"eos_config_deploy_eapi",
"eos_designs",
"eos_snapshot",
"eos_validate_state",
"plugins",
"requirements",
"containers",
# Handle multiple scopes ',' are not supported in Github labels and so replaced with '|' by our action
"eos_designs|eos_cli_config_gen",
"eos_cli_config_gen|eos_designs",
"pyavd",
]
# CI and Test are excluded from Release Notes
CATEGORIES = {
"Feat": "Features",
"Fix": "Bug Fixes",
"Cut": "Cut",
"Doc": "Documentation",
# Excluding "CI": "CI",
"Bump": "Bump",
# Excluding "Test": "Test",
"Revert": "Revert",
"Refactor": "Refactoring",
}
class SafeDumper(yaml.SafeDumper):
"""
Make yamllint happy.
https://github.com/yaml/pyyaml/issues/234#issuecomment-765894586
"""
# pylint: disable=R0901,W0613,W1113
def increase_indent(self, flow: bool = False, *_args: Any, **_kwargs: Any) -> None:
return super().increase_indent(flow=flow, indentless=False)
if __name__ == "__main__":
exclude_list = []
categories_list = []
other_scopes = [
scope
for scope in SCOPES
if scope
not in [
"eos_cli_config_gen",
"eos_designs",
"eos_cli_config_gen|eos_designs",
"eos_designs|eos_cli_config_gen",
"pyavd",
]
]
# 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 EXCEPT `pyavd` ones
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 if scope != "pyavd"]
breaking_labels.extend([f"rn: {cc_type}!" for cc_type in breaking_label_categories])
categories_list.append(
{
"title": "Breaking Changes",
"labels": breaking_labels,
},
)
# Add fixes in eos_cli_config_gen
categories_list.append(
{
"title": "Fixed issues in eos_cli_config_gen",
"labels": ["rn: Fix(eos_cli_config_gen)"],
},
)
# Add fixes in eos_designs
categories_list.append(
{
"title": "Fixed issues in eos_designs",
"labels": ["rn: Fix(eos_designs)"],
},
)
# Add fixes in eos_cli_config_gen|eos_designs or eos_designs|eos_cli_config_gen
categories_list.append(
{
"title": "Fixed issues in both eos_designs and eos_cli_config_gen",
"labels": [
"rn: Fix(eos_cli_config_gen|eos_designs)",
"rn: Fix(eos_designs|eos_cli_config_gen)",
],
},
)
# Add other fixes
other_fixes_labels = [f"rn: Fix({scope})" for scope in other_scopes]
other_fixes_labels.append("rn: Fix")
categories_list.append(
{
"title": "Other Fixed issues",
"labels": other_fixes_labels,
},
)
# Add Documentation - except for PyAVD
doc_labels = [f"rn: Doc({scope})" for scope in SCOPES if scope != "pyavd"]
doc_labels.append("rn: Doc")
categories_list.append(
{
"title": "Documentation",
"labels": doc_labels,
},
)
# Add new features in eos_cli_config_gen
categories_list.append(
{
"title": "New features and enhancements in eos_cli_config_gen",
"labels": ["rn: Feat(eos_cli_config_gen)"],
},
)
# Add new features in eos_designs
categories_list.append(
{
"title": "New features and enhancements in eos_designs",
"labels": ["rn: Feat(eos_designs)"],
},
)
# Add new features in both eos_cli_config_gen|eos_designs or eos_designs|eos_cli_config_gen
categories_list.append(
{
"title": "New features and enhancement in both eos_designs and eos_cli_config_gen",
"labels": [
"rn: Feat(eos_cli_config_gen|eos_designs)",
"rn: Feat(eos_designs|eos_cli_config_gen)",
],
},
)
# Add other new features
other_feat_labels = [f"rn: Feat({scope})" for scope in other_scopes]
other_feat_labels.append("rn: Feat")
categories_list.append(
{
"title": "Other new features and enhancements",
"labels": other_feat_labels,
},
)
# Add all PyAVD changes
pyavd_labels = [f"rn: {category}(pyavd)" for category in CATEGORIES]
categories_list.append(
{
"title": "PyAVD Changes",
"labels": pyavd_labels,
},
)
# Add the catch all
categories_list.append(
{
"title": "Other Changes",
"labels": ["*"],
},
)
with Path("release.yml").open("w", encoding="utf-8") as release_file:
yaml.dump(
{
"changelog": {
"exclude": {"labels": exclude_list},
"categories": categories_list,
},
},
release_file,
Dumper=SafeDumper,
sort_keys=False,
)