From 1a6ca1eac1073062b375a6d0ac348a6bf06a551f Mon Sep 17 00:00:00 2001 From: Dmitry Misharov Date: Fri, 12 Jul 2024 16:27:41 +0200 Subject: [PATCH] use branch as CLI argument --- build.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/build.py b/build.py index 2a3c2e4c5..86d74c510 100644 --- a/build.py +++ b/build.py @@ -1,4 +1,5 @@ import os +import re import shutil import subprocess import sys @@ -6,12 +7,17 @@ from pathlib import Path -def get_branch(version: str) -> str: - if version in ["1.0.2", "1.1.1"]: - return f"OpenSSL_{version.replace('.', '_')}-stable" - if version == "master": +def get_version_from_branch(branch: str) -> str: + if branch == "master": return "master" - return f"openssl-{version}" + if match := re.match(r"openssl-(3\.[0-9]+)", branch): + return match.group(1) + if branch == "OpenSSL_1_1_1-stable": + return "1.1.1" + if branch == "OpenSSL_1_0_2-stable": + return "1.0.2" + print(f"Incorrect branch {branch}") + raise SystemExit(1) def clone(branch: str, tmp_dir: str) -> None: @@ -71,11 +77,12 @@ def build_site(version: str): def main(): - version = sys.argv[1] + branch = sys.argv[1] + version = get_version_from_branch(branch) clean_docs() create_dirs() with tempfile.TemporaryDirectory() as tmp_dir: - clone(get_branch(version), tmp_dir) + clone(branch, tmp_dir) if version not in ["1.0.2", "1.1.1"]: build_manpages(tmp_dir) convert_pod_to_md(tmp_dir)