#!/usr/bin/env -S godot --headless -s extends MainLoop func _initialize(): print("--- Starting Automated Patch Build ---") var output_file = "patch.pck" var changed_files_txt = "changed_files.txt" if not FileAccess.file_exists(changed_files_txt): print("ERROR: missing changed_files.txt. Cannot build patch.") return var pck_packer = PCKPacker.new() var err = pck_packer.pck_start(output_file) if err != OK: print("ERROR: Could not start PCK file: ", output_file) return var file = FileAccess.open(changed_files_txt, FileAccess.READ) var count = 0 while not file.eof_reached(): var line = file.get_line().strip_edges() if line.is_empty(): continue var res_path = "res://" + line # Include automatically compiled scripts for GDScript if line.ends_with(".gd"): var remap_path = res_path.replace(".gd", ".gdc") if FileAccess.file_exists(remap_path): pck_packer.add_file(res_path, remap_path) else: pck_packer.add_file(res_path, res_path) count += 1 print("Adding (Script): ", res_path) elif FileAccess.file_exists(res_path): print("Adding to patch: ", res_path) pck_packer.add_file(res_path, res_path) count += 1 else: print("Warning: Changed file not found or Is Directory, skipping: ", res_path) # Always package our version/changelog list so clients see the new changelog var version_manifest = "res://assets/data/version.json" pck_packer.add_file(version_manifest, version_manifest) print("Adding Version Manifest: ", version_manifest) pck_packer.flush(true) print("--- Patch Build Complete! Packed %d files into %s ---" % [count + 1, output_file]) func _process(_delta: float) -> bool: return true # True tells Godot to gracefully shut down the engine now!