From f3c8460767ced4c454b85fd6d882a5d7bbb2e259 Mon Sep 17 00:00:00 2001 From: Nick Sweeting Date: Sun, 14 Jun 2026 11:43:34 -0700 Subject: [PATCH] ci: use pypi version for archivebox rc bumps --- bin/release.sh | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/bin/release.sh b/bin/release.sh index 049a0880..62f74df8 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -221,6 +221,26 @@ else: PY } +latest_pypi_version() { + local package_name="$1" + local releases_json + releases_json="$(curl -fsSL "https://pypi.org/pypi/${package_name}/json" | jq -r '.releases | keys[]' || true)" + RELEASE_TAGS="${releases_json}" python3 - <<'PY' +import os +import re + +def parse(version: str) -> tuple[int, int, int, int, int]: + match = re.fullmatch(r'(\d+)\.(\d+)\.(\d+)(?:-?rc(\d*))?$', version) + if not match: + return (-1, -1, -1, -1, -1) + major, minor, patch, rc = match.groups() + return (int(major), int(minor), int(patch), 0 if 'rc' in version else 1, int(rc or '0')) + +versions = [line.strip() for line in os.environ.get('RELEASE_TAGS', '').splitlines() if line.strip()] +print(max(versions, key=parse) if versions else '') +PY +} + github_release_enabled() { local version="$1" if [[ "${version}" == *rc* && "${CREATE_GITHUB_RC_RELEASES:-0}" != "1" ]]; then @@ -412,7 +432,7 @@ publish_artifacts() { } main() { - local slug branch version latest relation + local slug branch version latest pypi_latest relation source_optional_env slug="$(repo_slug)" @@ -425,6 +445,10 @@ main() { version="$(current_version)" latest="$(latest_release_version "${slug}")" + pypi_latest="$(latest_pypi_version "${PYPI_PACKAGE}")" + if [[ -n "${pypi_latest}" && ( -z "${latest}" || "$(compare_versions "${pypi_latest}" "${latest}")" == "gt" ) ]]; then + latest="${pypi_latest}" + fi if [[ -z "${latest}" ]]; then relation="gt" else