Skip to content

Commit 95a2152

Browse files
committed
fix: resolve BOT_VERSION from src.__version__ so What's-new works in production
1 parent cd5032f commit 95a2152

5 files changed

Lines changed: 15 additions & 2 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ src/utils/version_store.py - read/write data/announced_version.json for startup
9393

9494
Unraid Server Monitor Bot (v0.12.0) - A Docker-based Telegram bot for monitoring Unraid servers. Monitors Docker containers (events, logs, resources) and Unraid server health (CPU, memory, disks, array, UPS). Uses multi-provider LLM support (Anthropic, OpenAI, Ollama) for AI-powered diagnostics and natural language interaction. Sends alerts via Telegram with quick-action buttons.
9595

96+
**Version string lives in TWO places**`pyproject.toml` (`version`) and `src/__init__.py` (`__version__`). Both must be bumped together on release; `tests/test_version.py` guards against drift. `BOT_VERSION` (in `src/bot/health_command.py`) resolves from installed package metadata when available, else falls back to `src.__version__` — the package is not installed in the Docker image, so the `__version__` fallback is what runs in production.
97+
9698
## Commands
9799

98100
```bash

src/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__version__ = "0.12.0"

src/bot/health_command.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from aiogram.types import Message
88

9+
from src import __version__ as _FALLBACK_VERSION
910
from src.utils.formatting import safe_reply
1011

1112
if TYPE_CHECKING:
@@ -23,7 +24,7 @@
2324
from importlib.metadata import version as _pkg_version
2425
BOT_VERSION = _pkg_version("unraid-monitor-bot")
2526
except Exception:
26-
BOT_VERSION = "unknown"
27+
BOT_VERSION = _FALLBACK_VERSION
2728

2829

2930
def _format_health_uptime(start_time: datetime) -> str:

tests/test_version.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def test_version_matches_pyproject():
2+
import pathlib
3+
import tomllib
4+
5+
from src import __version__
6+
7+
pyproject = pathlib.Path(__file__).parent.parent / "pyproject.toml"
8+
data = tomllib.loads(pyproject.read_text())
9+
assert __version__ == data["project"]["version"]

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)