-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy path4_make_release_drafts.py
131 lines (101 loc) · 4.17 KB
/
4_make_release_drafts.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
import argparse
import json
from pathlib import Path
import requests
from utils import (
INITIALS_TO_USERNAMES,
list_folders_in_path,
validate_date,
validate_time,
validate_version,
)
CURRENT_DIR: Path = Path(__file__).resolve().parent
INITIALS: list[str] = list(INITIALS_TO_USERNAMES.keys())
_TEMPLATE: str = """Click on the link for a list of all the PRs released since `{version_tag}`
https://github.com/ITISFoundation/osparc-simcore/compare/{version_tag}...master
Please check your name if finished:
{names_to_check}
**Draft release notes go below the line**
---
# Release Notes
### Highlights
<details>
<summary>Show detailed release notes</summary>
{collapsable_content}
</details>
"""
_MATTERMOST_TEMPLATE: str = """
@all please contribute in compiling the `Release Drafts`.
There are 3 release drafts to fill out: `s4l` (which also includes s4l-lite), `osparc`, `tip`.
Instructions:
- Please go through all your last changes in master since the last release for each product: [osparc](https://github.com/ITISFoundation/osparc-issues/blob/master/release-notes/osparc/{version_tag}.md), [s4l](https://github.com/ITISFoundation/osparc-issues/blob/master/release-notes/s4l/{version_tag}.md) and [tip](https://github.com/ITISFoundation/osparc-issues/blob/master/release-notes/tip/{version_tag}.md) (each product contains a link to these changes)
- For each product please chose those features which it makes sense to highlight.
- When highlighting a feature please provide a meaningful `USER` readable description and the link to the PR
- deadline `{deadline_day} by {deadline_time}`
- please :white_check_mark: your name when done in all products so I can keep track of who is missing.
:pray: Thanks everybody for your kind cooperation and help.
"""
def _get_previous_version(vtag: str) -> int:
version_parts = vtag.strip("v").split(".")
version_parts[1] = f"{int(version_parts[1])-1}"
return "v" + ".".join(version_parts)
def _get_names_to_check() -> str:
return "\n".join([f"- [ ] {name}" for name in INITIALS])
def _get_collpasable_notes(vtag: str) -> str:
response = requests.get(
f"https://api.github.com/repos/ITISFoundation/osparc-simcore/releases/tags/{vtag}",
timeout=10,
)
if response.status_code >= 400:
print(
f"ERROR: The GET request to the github API to https://api.github.com/repos/ITISFoundation/osparc-simcore/releases/tags/{vtag} failed. Does the github release {vtag} exist yet?"
)
exit(1)
json_response = json.loads(response.text)
return json_response["body"]
def main():
parser = argparse.ArgumentParser(
description="Process a version number in the format X.X.X"
)
parser.add_argument(
"version", type=validate_version, help="The version number in the format X.X.X"
)
parser.add_argument(
"deadline_day",
type=validate_date,
help="The date is in the format dd.mm",
)
parser.add_argument(
"deadline_time",
type=validate_time,
help="The time is in the format HH:MM",
)
args = parser.parse_args()
tag = f"{args.version}"
vtag = f"v{tag}"
print("\nTotal [STEPS] 2\n")
print(f"Will generate drafts for tag: {vtag}")
new_draft_content = _TEMPLATE.format(
version_tag=_get_previous_version(vtag),
names_to_check=_get_names_to_check(),
collapsable_content=_get_collpasable_notes(vtag),
)
for product_folder in list_folders_in_path(CURRENT_DIR / ".." / "release-notes"):
draft_file = product_folder / f"{vtag}.md"
if draft_file.exists():
msg = f"{draft_file} already exists, make sure you are creating the draft for the correct release"
# raise ValueError(msg)
draft_file.write_text(new_draft_content)
print(
"\n[STEP] 1/2 post this message on mattermost, please edit the DEADLINE accordingly\n"
)
print(
_MATTERMOST_TEMPLATE.format(
version_tag=vtag,
deadline_day=args.deadline_day,
deadline_time=args.deadline_time,
)
)
print("\n[STEP] 2/2 commit and push changes generated in this repo!!!!\n")
if __name__ == "__main__":
main()