- Rename GITEA_TOKEN to DEPLOY_TOKEN in release workflow - Extract shared version detection into build-common.sh - Use importlib.metadata for runtime version instead of hardcoded string - Use PEP 440 parsing (packaging lib) for update version comparison - Add packaging>=23.0 to dependencies - Fix update banner close button alignment (CSS) - Update CLAUDE.md with versioning docs and frontend rebuild notes
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
"""Media Server - REST API for controlling system media playback."""
|
||||
|
||||
__version__ = "1.0.1"
|
||||
from importlib.metadata import PackageNotFoundError, version
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def _detect_version() -> str:
|
||||
# 1. Package metadata (works when pip-installed in dev)
|
||||
try:
|
||||
return version("media-server")
|
||||
except PackageNotFoundError:
|
||||
pass
|
||||
|
||||
# 2. VERSION file written by build scripts (production builds)
|
||||
# Located at install root, two levels up from this package
|
||||
version_file = Path(__file__).resolve().parent.parent.parent / "VERSION"
|
||||
if version_file.is_file():
|
||||
return version_file.read_text().strip()
|
||||
|
||||
return "0.0.0-dev"
|
||||
|
||||
|
||||
__version__ = _detect_version()
|
||||
|
||||
@@ -2,30 +2,36 @@
|
||||
|
||||
import asyncio
|
||||
import logging
|
||||
import re
|
||||
from typing import Any, Optional
|
||||
|
||||
from packaging.version import Version
|
||||
|
||||
from .release_provider import ReleaseProvider
|
||||
from .websocket_manager import ws_manager
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_PRE_PATTERN = re.compile(
|
||||
r"^(\d+\.\d+\.\d+)[-.]?(alpha|beta|rc)[.-]?(\d+)$", re.IGNORECASE
|
||||
)
|
||||
_PRE_MAP = {"alpha": "a", "beta": "b", "rc": "rc"}
|
||||
|
||||
def _parse_version(version: str) -> tuple[int, ...]:
|
||||
"""Parse a version string into a comparable tuple.
|
||||
|
||||
Handles versions like "1.0.0", "1.2.3", ignoring non-numeric suffixes.
|
||||
def _parse_version(raw: str) -> Version:
|
||||
"""Normalize a version tag to PEP 440 for correct comparison.
|
||||
|
||||
Examples:
|
||||
v0.3.0-alpha.1 → 0.3.0a1 (pre-release, sorts below 0.3.0)
|
||||
v0.3.0-rc.3 → 0.3.0rc3
|
||||
v1.0.0 → 1.0.0
|
||||
"""
|
||||
parts: list[int] = []
|
||||
for part in version.split("."):
|
||||
digits = ""
|
||||
for ch in part:
|
||||
if ch.isdigit():
|
||||
digits += ch
|
||||
else:
|
||||
break
|
||||
if digits:
|
||||
parts.append(int(digits))
|
||||
return tuple(parts)
|
||||
cleaned = raw.lstrip("v").strip()
|
||||
m = _PRE_PATTERN.match(cleaned)
|
||||
if m:
|
||||
base, pre_label, pre_num = m.group(1), m.group(2).lower(), m.group(3)
|
||||
cleaned = f"{base}{_PRE_MAP[pre_label]}{pre_num}"
|
||||
return Version(cleaned)
|
||||
|
||||
|
||||
class UpdateChecker:
|
||||
|
||||
@@ -3537,6 +3537,8 @@ footer .separator {
|
||||
opacity: 0.7;
|
||||
cursor: pointer;
|
||||
line-height: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.update-banner-close:hover {
|
||||
|
||||
Reference in New Issue
Block a user