forked from bartvdbraak/blender
Blender LTS: Download + Release notes CMS scripts
This patch contains 2 scripts that will help with LTS releases create_download_urls.py This python script is used to generate the download urls which we can copy-paste directly into the CMS of www.blender.org. Usage: create_download_urls.py --version 2.83.7 Arguments: --version VERSION Version string in the form of {major}.{minor}.{build} (eg 2.83.7) The resulting html will be printed to the console. create_release_notes.py ======================= This python script is used to generate the release notes which we can copy-paste directly into the CMS of www.blender.org and stores. Usage: ./create_release_notes.py --task=T77348 --version=2.83.7 Arguments: --version VERSION Version string in the form of {major}.{minor}.{build} (e.g. 2.83.7) --task TASK Phabricator ticket that is contains the release notes information (e.g. T77348) --format FORMAT Format the result in `text`, `steam`, `wiki` or `html` Requirements ============ * Python 3.8 or later * Python phabricator client version 0.7.0 https://pypi.org/project/phabricator/ For convenience the python modules can be installed using pip. pip3 install -r ./requirements.txt Differential Revision: https://developer.blender.org/D9055
This commit is contained in:
parent
abddd7d5f9
commit
3a23f18e02
41
release/lts/README.md
Normal file
41
release/lts/README.md
Normal file
@ -0,0 +1,41 @@
|
||||
This folder contains several scripts to smoothen the Blender LTS releases.
|
||||
|
||||
create_download_urls.py
|
||||
=======================
|
||||
|
||||
This python script is used to generate the download urls which we can
|
||||
copy-paste directly into the CMS of www.blender.org.
|
||||
|
||||
Usage: create_download_urls.py --version 2.83.7
|
||||
|
||||
Arguments:
|
||||
--version VERSION Version string in the form of {major}.{minor}.{build}
|
||||
(eg 2.83.7)
|
||||
|
||||
The resulting html will be printed to the console.
|
||||
|
||||
create_release_notes.py
|
||||
=======================
|
||||
|
||||
This python script is used to generate the release notes which we can
|
||||
copy-paste directly into the CMS of www.blender.org and stores.
|
||||
|
||||
Usage: ./create_release_notes.py --task=T77348 --version=2.83.7
|
||||
|
||||
Arguments:
|
||||
--version VERSION Version string in the form of {major}.{minor}.{build}
|
||||
(e.g. 2.83.7)
|
||||
--task TASK Phabricator ticket that is contains the release notes
|
||||
information (e.g. T77348)
|
||||
--format FORMAT Format the result in `text`, `steam`, `wiki` or `html`
|
||||
|
||||
Requirements
|
||||
============
|
||||
|
||||
* Python 3.8 or later
|
||||
* Python phabricator client version 0.7.0
|
||||
https://pypi.org/project/phabricator/
|
||||
|
||||
For convenience the python modules can be installed using pip
|
||||
|
||||
pip3 install -r ./requirements.txt
|
78
release/lts/create_download_urls.py
Executable file
78
release/lts/create_download_urls.py
Executable file
@ -0,0 +1,78 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import datetime
|
||||
|
||||
|
||||
DESCRIPTION = ("This python script is used to generate the download urls "
|
||||
"which we can copy-paste directly into the CMS of "
|
||||
"www.blender.org")
|
||||
USAGE = "create_download_urls --version=2.83.7"
|
||||
# Used date format: "September 30, 2020"
|
||||
DATE_FORMAT = "%B %d, %Y"
|
||||
|
||||
|
||||
class Version:
|
||||
"""
|
||||
Version class that extracts the major, minor and build from
|
||||
a version string
|
||||
"""
|
||||
def __init__(self, version: str):
|
||||
self.version = version
|
||||
v = version.split(".")
|
||||
self.major = v[0]
|
||||
self.minor = v[1]
|
||||
self.build = v[2]
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.version
|
||||
|
||||
|
||||
def get_download_file_names(version: Version):
|
||||
yield f"blender-{version}-linux64.tar.xz"
|
||||
yield f"blender-{version}-macOS.dmg"
|
||||
yield f"blender-{version}-windows64.msi"
|
||||
yield f"blender-{version}-windows64.zip"
|
||||
|
||||
|
||||
def get_download_url(version: Version, file_name: str) -> str:
|
||||
"""
|
||||
Get the download url for the given version and file_name
|
||||
"""
|
||||
return (f"https://www.blender.org/download/Blender{version.major}"
|
||||
f".{version.minor}/{file_name}")
|
||||
|
||||
|
||||
def generate_html(version: Version) -> str:
|
||||
"""
|
||||
Generate download urls and format them into an HTML string
|
||||
"""
|
||||
today = datetime.date.today()
|
||||
lines = []
|
||||
lines.append(f"Released on {today.strftime(DATE_FORMAT)}.")
|
||||
lines.append("")
|
||||
lines.append("<ul>")
|
||||
for file_name in get_download_file_names(version):
|
||||
download_url = get_download_url(version, file_name)
|
||||
lines.append(f" <li><a href=\"{download_url}\">{file_name}</a></li>")
|
||||
lines.append("</ul>")
|
||||
|
||||
return "\n".join(lines)
|
||||
|
||||
|
||||
def print_download_urls(version: Version):
|
||||
"""
|
||||
Generate the download urls and print them to the console.
|
||||
"""
|
||||
print(generate_html(version))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=DESCRIPTION, usage=USAGE)
|
||||
parser.add_argument("--version",
|
||||
required=True,
|
||||
help=("Version string in the form of {major}.{minor}."
|
||||
"{build} (eg 2.83.7)"))
|
||||
args = parser.parse_args()
|
||||
|
||||
print_download_urls(version=Version(args.version))
|
166
release/lts/create_release_notes.py
Executable file
166
release/lts/create_release_notes.py
Executable file
@ -0,0 +1,166 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import phabricator
|
||||
|
||||
|
||||
DESCRIPTION = ("This python script is used to generate the release notes "
|
||||
"which we can copy-paste directly into the CMS of "
|
||||
"www.blender.org and stores.")
|
||||
USAGE = "./create_release_notes.py --task=T77348 --version=2.83.7"
|
||||
|
||||
|
||||
class ReleaseLogLine:
|
||||
"""
|
||||
Class containing the information of a single line of the release log
|
||||
|
||||
Instance attributes:
|
||||
|
||||
* line: (str) the original line used to create this log line
|
||||
* task_id: (int or None) the extracted task id associated with this log
|
||||
line. Can be None if the log line isn't associated with a task.
|
||||
* commit_id: (str or None) the extracted commit id associated with this log
|
||||
line. Only filled when no `task_id` could be found.
|
||||
* ref: (str) `task_id` or `commit_id` of this line, including `T` for tasks
|
||||
or `D` for diffs.
|
||||
* title: (str) title of this log line. When constructed this attribute is
|
||||
an empty string. The called needs to retrieve the title from the
|
||||
backend.
|
||||
* url: (str) url of the ticket task or commit.
|
||||
"""
|
||||
def __init__(self, line: str):
|
||||
self.line=line
|
||||
items = line.split("|")
|
||||
self.task_id = None
|
||||
self.commit_id = None
|
||||
try:
|
||||
task_id = int(items[1].strip()[1:])
|
||||
self.task_id = task_id
|
||||
self.ref = f"T{self.task_id}"
|
||||
except ValueError:
|
||||
# no task
|
||||
commit_string = items[3].strip()
|
||||
commits = commit_string.split(",")
|
||||
commit_id = commits[0]
|
||||
commit_id = commit_id.replace("{", "").replace("}", "")
|
||||
if not commit_id.startswith("rB"):
|
||||
commit_id = f"rB{commit_id}"
|
||||
self.commit_id = commit_id
|
||||
|
||||
self.ref = f"{self.commit_id}"
|
||||
|
||||
self.title = ""
|
||||
self.url = f"https://developer.blender.org/{self.ref}"
|
||||
|
||||
def __format_as_html(self)-> str:
|
||||
return f" <li>{self.title} [<a href=\"{self.url}\">{self.ref}</a>]</li>"
|
||||
|
||||
def __format_as_text(self) ->str:
|
||||
return f"* {self.title} [{self.ref}]"
|
||||
|
||||
def __format_as_steam(self) -> str:
|
||||
return f"* {self.title} ([url={self.url}]{self.ref}[/url])"
|
||||
|
||||
def __format_as_wiki(self) -> str:
|
||||
if self.task_id:
|
||||
return f"* {self.title} [{{{{BugReport|{self.task_id}}}}}]"
|
||||
else:
|
||||
return f"* {self.title} [{{{{GitCommit|{self.commit_id[2:]}}}}}]"
|
||||
|
||||
def format(self, format: str) -> str:
|
||||
"""
|
||||
Format this line
|
||||
|
||||
:attr format: the desired format. Possible values are 'text', 'steam' or 'html'
|
||||
:type string:
|
||||
"""
|
||||
if format == 'html':
|
||||
return self.__format_as_html()
|
||||
elif format == 'steam':
|
||||
return self.__format_as_steam()
|
||||
elif format == 'wiki':
|
||||
return self.__format_as_wiki()
|
||||
else:
|
||||
return self.__format_as_text()
|
||||
|
||||
|
||||
def format_title(title: str) -> str:
|
||||
title = title.strip()
|
||||
if not title.endswith("."):
|
||||
title = title + "."
|
||||
return title
|
||||
|
||||
|
||||
def extract_release_notes(version: str, task_id: int):
|
||||
"""
|
||||
Extract all release notes logs
|
||||
|
||||
# Process
|
||||
|
||||
1. Retrieval of description of the gived `task_id`.
|
||||
2. Find rows for the given `version` and convert to `ReleaseLogLine`.
|
||||
3. based on the associated task or commit retrieves the title of the log
|
||||
line.
|
||||
"""
|
||||
phab = phabricator.Phabricator()
|
||||
phab.update_interfaces()
|
||||
task = phab.maniphest.info(task_id=task_id)
|
||||
description = task["description"]
|
||||
lines = description.split("\n")
|
||||
start_index = lines.index(f"## Blender {version} ##")
|
||||
lines = lines[start_index+1:]
|
||||
for line in lines:
|
||||
if not line.strip():
|
||||
continue
|
||||
if line.startswith("| **Report**"):
|
||||
continue
|
||||
if line.startswith("## Blender"):
|
||||
break
|
||||
|
||||
log_line = ReleaseLogLine(line)
|
||||
if log_line.task_id:
|
||||
issue_task = phab.maniphest.info(task_id=log_line.task_id)
|
||||
log_line.title = format_title(issue_task.title)
|
||||
yield log_line
|
||||
elif log_line.commit_id:
|
||||
commits = phab.diffusion.commit.search(constraints={"identifiers":[log_line.commit_id]})
|
||||
commit = commits.data[0]
|
||||
commit_message = commit['fields']['message']
|
||||
commit_title = commit_message.split("\n")[0]
|
||||
log_line.title = format_title(commit_title)
|
||||
yield log_line
|
||||
|
||||
|
||||
def print_release_notes(version: str, format: str, task_id: int):
|
||||
"""
|
||||
Generate and print the release notes to the console.
|
||||
"""
|
||||
if format == 'html':
|
||||
print("<ul>")
|
||||
if format == 'steam':
|
||||
print("[ul]")
|
||||
for log_item in extract_release_notes(version=version, task_id=task_id):
|
||||
print(log_item.format(format=format))
|
||||
if format == 'html':
|
||||
print("</ul>")
|
||||
if format == 'steam':
|
||||
print("[/ul]")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description=DESCRIPTION, usage=USAGE)
|
||||
parser.add_argument(
|
||||
"--version",
|
||||
required=True,
|
||||
help="Version string in the form of {major}.{minor}.{build} (e.g. 2.83.7)")
|
||||
parser.add_argument(
|
||||
"--task",
|
||||
required=True,
|
||||
help="Phabricator ticket that is contains the release notes information (e.g. T77348)")
|
||||
parser.add_argument(
|
||||
"--format",
|
||||
help="Format the result in `text`, `steam`, `wiki` or `html`",
|
||||
default="text")
|
||||
args = parser.parse_args()
|
||||
|
||||
print_release_notes(version=args.version, format=args.format, task_id=int(args.task[1:]))
|
1
release/lts/requirements.txt
Normal file
1
release/lts/requirements.txt
Normal file
@ -0,0 +1 @@
|
||||
phabricator==0.7.0
|
Loading…
Reference in New Issue
Block a user