77 workflow_dispatch :
88 inputs :
99 versions :
10- description : ' Comma-separated list of tags (e.g., v0.21.4,v0.22.2). Leave empty to auto-detect missing stable tags >= v0.13.0.'
11- required : false
12- default : " "
13- include_rcs :
14- description : ' Include release candidate tags (rc) in auto-detection.'
15- required : false
16- type : boolean
17- default : false
10+ description : ' JSON array of tags (e.g. ["v0.21.4","v0.22.2"])'
11+ required : true
12+ type : string
1813
1914jobs :
20- compute_matrix :
21- runs-on : ubuntu-latest
22- outputs :
23- versions : ${{ steps.compute.outputs.matrix }}
24- steps :
25- - name : Checkout repository
26- uses : actions/checkout@v4
27- with :
28- fetch-depth : 0
29-
30- - id : compute
31- env :
32- INPUT_VERSIONS : ${{ github.event.inputs.versions }}
33- INCLUDE_RCS : ${{ github.event.inputs.include_rcs }}
34- run : |
35- set -e
36- apt-get update
37- apt-get install -y python3 python3-pip
38- python3 -m pip install --quiet packaging pyyaml huggingface_hub
39- python3 - <<'PY'
40- import json
41- import os
42- import re
43- import subprocess
44- from packaging import version
45- import yaml
46-
47- try:
48- from huggingface_hub import hf_hub_download
49- except ImportError:
50- print("::error::huggingface_hub failed to import")
51- raise
52-
53- def is_candidate(tag: str, include_rcs: bool) -> bool:
54- m = re.match(r"v(\d+\.\d+\.\d+)(.*)$", tag)
55- if not m:
56- return False
57- suffix = m.group(2)
58- if suffix and not include_rcs:
59- # filter out rc/beta/etc
60- return False
61- return version.parse(m.group(1)) >= version.parse("0.13.0")
62-
63- raw_tags = subprocess.check_output(["git", "tag", "--list", "v*"]).decode().split()
64- include_rcs = (os.getenv("INCLUDE_RCS", "false").lower() == "true")
65- candidates = sorted({t for t in raw_tags if is_candidate(t, include_rcs)}, key=lambda t: version.parse(re.sub(r"^v", "", re.sub(r"rc.*", "", t))))
66-
67- pattern = re.compile(r"^v\d+\.\d+\.\d+(?:[a-zA-Z0-9.-]+)?$")
68-
69- input_versions = os.getenv("INPUT_VERSIONS", "").strip()
70- if input_versions:
71- build_list = []
72- for v in (v.strip() for v in input_versions.split(",")):
73- if not v:
74- continue
75- if not pattern.match(v):
76- raise SystemExit(f"Invalid version format: {v}")
77- build_list.append(v)
78- else:
79- try:
80- path = hf_hub_download(repo_id="hf-doc-build/doc-build", filename="tokenizers/_versions.yml", repo_type="dataset")
81- with open(path, "r", encoding="utf-8") as f:
82- existing = [entry["version"] for entry in yaml.safe_load(f)]
83- except Exception as e:
84- print(f"::warning::Could not load remote _versions.yml ({e}); assuming none built")
85- existing = []
86- build_list = [v for v in candidates if v not in existing]
87-
88- if not build_list:
89- print("::notice::No versions to build")
90-
91- matrix = json.dumps(build_list)
92- print(f"matrix={matrix}")
93- with open(os.environ["GITHUB_OUTPUT"], "a", encoding="utf-8") as fh:
94- fh.write(f"matrix={matrix}\n")
95- PY
96-
9715 build :
98- needs : compute_matrix
99- if : needs.compute_matrix.outputs.versions != '[]' && needs.compute_matrix.outputs.versions != ''
16+ runs-on : ubuntu-latest
10017 strategy :
10118 fail-fast : false
10219 matrix :
103- version : ${{ fromJson(needs.compute_matrix.outputs .versions) }}
20+ version : ${{ fromJson(github.event.inputs .versions) }}
10421 uses : huggingface/doc-builder/.github/workflows/build_main_documentation.yml@main
10522 with :
10623 commit_sha : ${{ matrix.version }}
11027 version_tag_suffix : bindings/python/py_src/
11128 install_rust : true
11229 secrets :
113- hf_token : ${{ secrets.HF_DOC_BUILD_PUSH }}
30+ hf_token : ${{ secrets.HF_DOC_BUILD_PUSH }}
0 commit comments