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."""
36 def is_point_release(version
: str) -> bool:
37 return not version
.endswith('.0')
40 def update_index(is_point
: bool, version
: str) -> None:
41 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'index.html'
42 with p
.open('rt') as f
:
45 news
= tree
.xpath('.//h1')[0]
47 date
= datetime
.date
.today()
48 month
= calendar
.month_name
[date
.month
]
49 header
= etree
.Element('h2')
50 header
.text
= f
"{month} {date.day}, {date.year}"
52 body
= etree
.Element('p')
54 body
, 'a', attrib
={'href': f
'relnotes/{version}.html'})
55 a
.text
= f
"Mesa {version}"
57 a
.tail
= " is released. This is a bug fix release."
59 a
.tail
= (" is released. This is a new development release. "
60 "See the release notes for more information about this release.")
62 root
= news
.getparent()
63 index
= root
.index(news
) + 1
64 root
.insert(index
, body
)
65 root
.insert(index
, header
)
67 tree
.write(p
.as_posix(), method
='html', pretty_print
=True)
68 subprocess
.run(['git', 'add', p
])
71 def update_release_notes(version
: str) -> None:
72 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'relnotes.html'
73 with p
.open('rt') as f
:
76 li
= etree
.Element('li')
77 a
= etree
.SubElement(li
, 'a', href
=f
'relnotes/{version}.html')
78 a
.text
= f
'{version} release notes'
80 ul
= tree
.xpath('.//ul')[0]
83 tree
.write(p
.as_posix(), method
='html', pretty_print
=True)
84 subprocess
.run(['git', 'add', p
])
87 def update_calendar(version
: str) -> None:
88 p
= pathlib
.Path(__file__
).parent
.parent
/ 'docs' / 'release-calendar.html'
89 with p
.open('rt') as f
:
92 base_version
= version
[:-2]
97 for tr
in tree
.xpath('.//tr'):
102 for td
in tr
.xpath('./td'):
103 if td
.text
== base_version
:
107 assert old
is not None
108 assert new
is not None
109 old
.getparent().remove(old
)
111 # rowspan is 1 based in html, but 0 based in lxml
112 rowspan
= int(td
.get("rowspan")) - 1
114 td
.set("rowspan", str(rowspan
))
117 tree
.write(p
.as_posix(), method
='html', pretty_print
=True)
118 subprocess
.run(['git', 'add', p
])
122 parser
= argparse
.ArgumentParser()
123 parser
.add_argument('version', help="The released version.")
124 args
= parser
.parse_args()
126 is_point
= is_point_release(args
.version
)
128 update_index(is_point
, args
.version
)
129 update_release_notes(args
.version
)
130 update_calendar(args
.version
)
131 subprocess
.run(['git', 'commit', '-m',
132 'docs: update calendar, add news item, and link releases '
133 f
'notes for {args.version}'])
136 if __name__
== "__main__":