This commit is contained in:
2025-10-14 12:23:58 +02:00
parent cf4f3ce564
commit f8dc03caf9
21 changed files with 384 additions and 43 deletions

View File

@@ -207,27 +207,25 @@ def _format_version_tuple(version_tuple: tuple) -> str:
def _edition_version_tuple(version: str, version_type: str) -> tuple:
"""Return edition-specific version tuple."""
"""Return edition-specific version tuple without altering the provided version."""
try:
major_str, minor_str, patch_str = version.split(".", 2)
major, minor, patch = int(major_str), int(minor_str), int(patch_str)
except ValueError:
# Fallback if version string unexpected
return (1, 0, 0) if version_type == "free" else (1, 0, 1)
return (1, 0, 0)
if version_type == "full":
return (major, minor, patch + 1)
return (major, minor, patch)
def _apply_edition_overrides(rel_path: Path, source_code: str, version_type: str, version: str) -> str:
"""Inject edition-specific metadata into copied source files."""
if rel_path.as_posix() == "__init__.py":
edition_name = "Text Texture Generator (Pro)" if version_type == "full" else "Text Texture Generator (Free)"
edition_name = "Text Texture Generator Pro" if version_type == "full" else "Text Texture Generator (Free)"
target_version_tuple = _edition_version_tuple(version, version_type)
source_code = re.sub(
r'"name":\s*"Text Texture Generator\s*\([^"]*\)"',
r'"name":\s*"Text Texture Generator[^"]*"',
f'"name": "{edition_name}"',
source_code,
count=1
@@ -438,14 +436,16 @@ def build_all_versions(version: Optional[str] = None, minify: bool = True):
print("\n" + "="*50)
print("BUILDING FULL VERSION")
print("="*50)
full_package = build_addon("full", version, minify=minify)
resolved_version = version or get_version_from_git() or "1.0.0"
full_package = build_addon("full", resolved_version, minify=minify)
built_packages.append(("full", full_package))
# Build free version
print("\n" + "="*50)
print("BUILDING FREE VERSION")
print("="*50)
free_package = build_addon("free", version, minify=minify)
free_package = build_addon("free", resolved_version, minify=minify)
built_packages.append(("free", free_package))
print("\n" + "="*50)
@@ -455,6 +455,19 @@ def build_all_versions(version: Optional[str] = None, minify: bool = True):
file_size = package_path.stat().st_size / 1024 # KB
print(f"{version_type.upper():>4}: {package_path.name} ({file_size:.1f} KB)")
# Restore development files to the full-version state so local testing keeps premium features visible
project_root = get_project_root()
restore_sync = subprocess.run(
[
'python3', 'build/sync_version.py',
'--version', resolved_version,
'--type', 'full'
],
cwd=project_root
)
if restore_sync.returncode != 0:
raise RuntimeError("Failed to resync version metadata after build")
return built_packages
def main():