mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-26 01:12:21 +00:00
* ci: cut rc/<X.Y.0> off main every Friday at 3am Pacific Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: refuse to cut rc branch from a ref other than main Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: move rc version check into .github/scripts/read_rc_version.py with tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * ci: fall back to tomli for the rc version script on Python 3.10 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test: type the read_rc_version test helper Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: yuneng <yuneng@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
44 lines
1.3 KiB
Python
44 lines
1.3 KiB
Python
#!/usr/bin/env python3
|
|
"""Print `version=X.Y.0` from [project].version in pyproject.toml for $GITHUB_OUTPUT.
|
|
|
|
Usage
|
|
-----
|
|
python3 read_rc_version.py [path/to/pyproject.toml] >> "$GITHUB_OUTPUT"
|
|
|
|
Exit code 1 with a `::error::` line on stderr when the version is not an X.Y.0 release.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pathlib
|
|
import re
|
|
import sys
|
|
from typing import Final
|
|
|
|
if sys.version_info >= (3, 11):
|
|
import tomllib
|
|
else:
|
|
import tomli as tomllib
|
|
|
|
RELEASE_VERSION: Final = re.compile(r"[0-9]+\.[0-9]+\.0")
|
|
|
|
|
|
def read_version(pyproject: pathlib.Path) -> str:
|
|
with pyproject.open("rb") as f:
|
|
return tomllib.load(f)["project"]["version"]
|
|
|
|
|
|
def main(argv: list[str]) -> int:
|
|
pyproject: Final = pathlib.Path(argv[1]) if len(argv) > 1 else pathlib.Path("pyproject.toml")
|
|
version: Final = read_version(pyproject)
|
|
if RELEASE_VERSION.fullmatch(version) is None:
|
|
print( # noqa: T201 # the ::error:: line to stderr is the workflow's failure signal
|
|
f"::error::pyproject.toml version {version} is not an X.Y.0 release version", file=sys.stderr
|
|
)
|
|
return 1
|
|
print(f"version={version}") # noqa: T201 # stdout line is appended to $GITHUB_OUTPUT
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main(sys.argv))
|