diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-10-28 12:14:09 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-12-09 11:14:53 +0300 |
commit | 3a23f18e02ebe09414a04c399a7294c8e719a72a (patch) | |
tree | 45f0e6b51edcce50c3720897fe447b7008716c1f /release/lts/create_download_urls.py | |
parent | abddd7d5f91a6b00617d4eac8616d54490d45e8d (diff) |
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
Diffstat (limited to 'release/lts/create_download_urls.py')
-rwxr-xr-x | release/lts/create_download_urls.py | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/release/lts/create_download_urls.py b/release/lts/create_download_urls.py new file mode 100755 index 00000000000..0d0b2554d2a --- /dev/null +++ b/release/lts/create_download_urls.py @@ -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)) |