Skip to content

Commit 1a6ca1e

Browse files
committed
use branch as CLI argument
1 parent b266a0d commit 1a6ca1e

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

build.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import os
2+
import re
23
import shutil
34
import subprocess
45
import sys
56
import tempfile
67
from pathlib import Path
78

89

9-
def get_branch(version: str) -> str:
10-
if version in ["1.0.2", "1.1.1"]:
11-
return f"OpenSSL_{version.replace('.', '_')}-stable"
12-
if version == "master":
10+
def get_version_from_branch(branch: str) -> str:
11+
if branch == "master":
1312
return "master"
14-
return f"openssl-{version}"
13+
if match := re.match(r"openssl-(3\.[0-9]+)", branch):
14+
return match.group(1)
15+
if branch == "OpenSSL_1_1_1-stable":
16+
return "1.1.1"
17+
if branch == "OpenSSL_1_0_2-stable":
18+
return "1.0.2"
19+
print(f"Incorrect branch {branch}")
20+
raise SystemExit(1)
1521

1622

1723
def clone(branch: str, tmp_dir: str) -> None:
@@ -71,11 +77,12 @@ def build_site(version: str):
7177

7278

7379
def main():
74-
version = sys.argv[1]
80+
branch = sys.argv[1]
81+
version = get_version_from_branch(branch)
7582
clean_docs()
7683
create_dirs()
7784
with tempfile.TemporaryDirectory() as tmp_dir:
78-
clone(get_branch(version), tmp_dir)
85+
clone(branch, tmp_dir)
7986
if version not in ["1.0.2", "1.1.1"]:
8087
build_manpages(tmp_dir)
8188
convert_pod_to_md(tmp_dir)

0 commit comments

Comments
 (0)