2 # Copyright © 2019-2020 Intel Corporation
4 # Permission is hereby granted, free of charge, to any person obtaining a copy
5 # of this software and associated documentation files (the "Software"), to deal
6 # in the Software without restriction, including without limitation the rights
7 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 # copies of the Software, and to permit persons to whom the Software is
9 # furnished to do so, subject to the following conditions:
11 # The above copyright notice and this permission notice shall be included in
12 # all copies or substantial portions of the Software.
14 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 """Update the main page, release notes, and calendar."""
29 def update_homepage(version
: str) -> None:
30 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'conf.py'
32 # Don't post release candidates to the homepage
36 with
open(p
, 'r') as f
:
41 if line
.startswith("version = '") and line
.endswith("'\n"):
42 old_version
= line
.split("'")[1]
43 # Avoid overwriting 20.1.0 when releasing 20.0.8
44 # TODO: we might need more than that to handle 20.0.10
45 if old_version
< version
:
46 line
= f
"version = '{version}'\n"
49 with
open(p
, 'w') as f
:
53 subprocess
.run(['git', 'add', p
])
56 def update_release_notes(version
: str) -> None:
57 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes.rst'
59 with
open(p
, 'r') as f
:
60 relnotes
= f
.readlines()
65 if first_list
and line
.startswith('-'):
67 new_relnotes
.append(f
'- `{version} release notes <relnotes/{version}.rst>`__\n')
68 new_relnotes
.append(line
)
70 with
open(p
, 'w') as f
:
71 for line
in new_relnotes
:
74 subprocess
.run(['git', 'add', p
])
77 def update_calendar(version
: str) -> None:
78 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'release-calendar.rst'
80 with
open(p
, 'r') as f
:
81 calendar
= f
.readlines()
88 branch
= line
.split('|')[1].strip()
93 # Put the branch number back on the next line
94 new_calendar
.append(line
[:2] + branch
+ line
[len(branch
) + 2:])
97 new_calendar
.append(line
)
99 with
open(p
, 'w') as f
:
100 for line
in new_calendar
:
103 subprocess
.run(['git', 'add', p
])
107 parser
= argparse
.ArgumentParser()
108 parser
.add_argument('version', help="The released version.")
109 args
= parser
.parse_args()
111 update_homepage(args
.version
)
112 update_release_notes(args
.version
)
113 update_calendar(args
.version
)
114 done
= 'update calendar'
116 if not is_release_candidate(args
.version
):
117 update_index(args
.version
)
118 update_release_notes(args
.version
)
119 done
+= ', add news item, and link releases notes'
121 subprocess
.run(['git', 'commit', '-m',
122 f
'docs: {done} for {args.version}'])
125 if __name__
== "__main__":