forked from pydantic/pydantic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcheck_relnotes.py
33 lines (26 loc) · 943 Bytes
/
check_relnotes.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
"""Short helper script to check that a PR has exactly one relnotes label."""
import json
import os
import sys
if __name__ == '__main__':
event_path = os.environ.get('GITHUB_EVENT_PATH')
if event_path is None:
raise RuntimeError('Can only check changelog on github actions')
with open(event_path) as event_file:
event = json.load(event_file)
labels = [
label['name']
for label in event['pull_request']['labels']
if label['name'].startswith('relnotes-') or label['name'] == 'documentation'
]
if not labels:
print(
'No suitable label found, please add either one of the `relnotes-` or `documentation` labels.',
file=sys.stderr,
)
exit(1)
if len(labels) > 1:
print(f'Multiple relnotes labels found: `{"`, `".join(labels)}`', file=sys.stderr)
exit(1)
print('Found suitable label:', labels[0])
exit(0)