from pathlib import Path import sys, shutil, json, hashlib, zipfile ROOT=Path(__file__).resolve().parent.parent SRC=ROOT/'Demon_v0.12'; WIN=ROOT/'Demon_v0.12_Windows' def sha(p):return hashlib.sha256(p.read_bytes()).hexdigest() if sys.argv[1]=='prepare': assert not SRC.exists() and not WIN.exists(),'Do not overwrite an existing release' shutil.copytree(ROOT/'Demon_v0.11',SRC,ignore=shutil.ignore_patterns('.godot','*.log','qa','export_templates','feature_profiles','script_templates','text_editor_themes')) WIN.mkdir() for name in ['main.gd','tests.gd','addons/build_stamp/plugin.gd','export_presets.cfg']: p=SRC/name;s=p.read_text(encoding='utf-8-sig') s=s.replace('"0.11-','"0.12-').replace('"version":"0.11"','"version":"0.12"').replace('Demon_v0.11_Windows','Demon_v0.12_Windows').replace('DEMON 0.11','DEMON 0.12') p.write_text(s,encoding='utf-8') p=SRC/'README_RU.md';s=p.read_text(encoding='utf-8-sig') s=s.replace('# Demon 0.11 — бесконечный цех','# Demon 0.12 — души и левитация') s=s.replace('Текущая папка — рабочие исходники после релиза 0.11 (27 октября 2026), Godot 4.3, Forward+ / Vulkan. Новые изменения ещё не экспортированы в EXE. Старые архивы 0.11 содержат предыдущую версию.','Релиз 0.12, 27 октября 2026. Распакуйте Windows-архив и запустите Demon.exe. Godot 4.3, Forward+ / Vulkan. Включены все изменения персонажей, механик, голосов и интерфейса после 0.11.') s=s.replace('Текущие кадры captures сняты из исходного проекта, без сборки EXE','Кадры captures сняты из готового EXE') s=s.replace('godot --path Demon_v0.11','godot --path Demon_v0.12').replace('tools/build_v11.ps1','tools/build_v12.ps1') p.write_text(s,encoding='utf-8') build=(ROOT/'tools/build_v11.ps1').read_text().replace('Demon_v0.11','Demon_v0.12') (ROOT/'tools/build_v12.ps1').write_text(build,encoding='utf-8') print('PREPARED',SRC,WIN) elif sys.argv[1]=='package': logs={p.name:p.read_text(encoding='utf-8') for p in WIN.glob('*.log')} for name,marker in [('release-tests.log','ALL TESTS PASSED'),('release-ui.log','QUIT: main-menu exit action'),('release-audio.log','22 nonverbal voice variants'),('release-capture.log','CAPTURE_BUILD:')]: assert marker in logs[name],name assert not any(word in logs[name] for word in ['ERROR:','Assertion failed']),name probe=json.loads(next(s.split('BUILD_PROBE: ',1)[1] for s in logs['probe.log'].splitlines() if s.startswith('BUILD_PROBE: '))) assert probe['id'].startswith('0.12-') and probe['id']!='0.12-editor' assert 'CAPTURE_BUILD: '+probe['id'] in logs['release-capture.log'] for name in ['README_RU.md','AUDIO_CREDITS.md','GODOT_LICENSE.txt','MODEL_CREDITS.md','MODEL_LICENSE_CC0.txt']: shutil.copy2(SRC/name,WIN/name) for name in ['KellySlab-OFL.txt','RuslanDisplay-OFL.txt']:shutil.copy2(SRC/'art/fonts'/name,WIN/name) qa=WIN/'QA';qa.mkdir(exist_ok=True) for name in ['release-tests.log','release-ui.log','release-audio.log','release-capture.log','probe.log']:shutil.copy2(WIN/name,qa/name) for p in (WIN/'captures').glob('*'):shutil.copy2(p,SRC/'captures'/p.name) manifest={'version':'0.12','date':'2026-10-27','build_id':probe['id'],'engine':'Godot 4.3 stable official','binary_sha256':sha(WIN/'Demon.exe'),'validation':{'exported_gameplay':'passed','exported_mouse_ui':'passed','exported_audio':'passed','exported_capture':'passed'},'soul_models':10,'dialogue_variants':22,'new_game_resets_progress':True,'models':{p.name:sha(p) for p in (SRC/'art').rglob('*.glb')}} (WIN/'BUILD_MANIFEST.json').write_text(json.dumps(manifest,ensure_ascii=False,indent=2),encoding='utf-8') for folder,suffix in [(WIN,'Windows'),(SRC,'Source')]: dest=ROOT/f'Demon_v0.12_{suffix}.zip' with zipfile.ZipFile(dest,'w',zipfile.ZIP_DEFLATED,compresslevel=6) as z: for p in sorted(folder.rglob('*')): if not p.is_file() or '.godot' in p.parts:continue if p.parent==folder and p.suffix=='.log':continue if suffix=='Source' and p.suffix=='.import' and not p.name.endswith('.glb.import'):continue z.write(p,Path(folder.name)/p.relative_to(folder)) if suffix=='Source': for name in ['build_v12.ps1','fetch_windows_template.py','release_v12.py']:z.write(ROOT/'tools'/name,Path('tools')/name) with zipfile.ZipFile(dest) as z:assert z.testzip() is None print('VERIFIED',dest.name,dest.stat().st_size,'SHA256',sha(dest)) print('BUILD_ID',probe['id'])