mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-14 11:06:13 +05:00
ci: use pypi version for archivebox rc bumps
This commit is contained in:
parent
19a2e44c5b
commit
f3c8460767
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user