from __future__ import annotations

import subprocess
import sys
from pathlib import Path


def main() -> int:
    script_dir = Path(__file__).resolve().parent
    scripts = ["build_image.py", "push_image.py"]

    for script in scripts:
        script_path = script_dir / script
        print(f"Executing {script}...")
        try:
            subprocess.run([sys.executable, str(script_path)], check=True)
            print(f"{script} executed successfully.\n")
        except subprocess.CalledProcessError as error:
            print(f"Error: {script} failed with exit code {error.returncode}.")
            return error.returncode

    return 0


if __name__ == "__main__":
    raise SystemExit(main())
