#!/usr/bin/env python3 """Keep executable release identity derived from the Cargo package version.""" from pathlib import Path import sys sys.path.insert(0, str(Path(__file__).resolve().parents[2])) from scripts.version import project_version root = Path(__file__).resolve().parents[2] version = project_version(root) for name in ('src/main/bootstrap.rs','src/main/tasks.rs','src/web_server/fastcgi/protocol.rs','src/web_server/response/file.rs','dev.sh','scripts/deploy/upgrade.py','make_zip.py'): text = (root/name).read_text(encoding='utf-8') assert f'RustProxy {version}' not in text and f'RustProxy/{version}' not in text, f'hardcoded runtime version: {name}' assert 'env!("CARGO_PKG_VERSION")' in (root/'src/web_server/fastcgi/protocol.rs').read_text() assert 'env!("CARGO_PKG_VERSION")' in (root/'src/web_server/response/file.rs').read_text() assert '__RUSTPROXY_VERSION__' in (root/'src/admin/web/index.html').read_text() assert 'OnceLock' in (root/'src/admin/public.rs').read_text() assert 'PanelContent::new' in (root/'src/admin/public.rs').read_text() assert 'preferred_encoding' in (root/'src/admin/panel_content.rs').read_text() assert 'include_str!("web/index.html")' in (root/'src/admin/public.rs').read_text() assert 'env!("CARGO_PKG_VERSION")' in (root/'src/admin/public.rs').read_text() assert 'admin_index.html' not in (root/'build.rs').read_text() assert 'project_version' in (root/'make_zip.py').read_text() print(f'PASS: executable version comes from Cargo.toml ({version})')