11from __future__ import annotations
22
3+ import argparse
34import json
45import os
56import re
89from pathlib import Path
910
1011
11- def update_container_file (server_name : str , version : str ) -> bool :
12+ def update_container_file (server_name : str , version : str , force : bool = False ) -> bool :
1213 container_file = Path (f"container/{ server_name } /ContainerFile" )
1314 if not container_file .exists ():
1415 print (f"ContainerFile for { server_name } not found at { container_file } " )
@@ -17,15 +18,19 @@ def update_container_file(server_name: str, version: str) -> bool:
1718 content = container_file .read_text ()
1819 new_content = re .sub (r"ARG VERSION=.*" , f"ARG VERSION={ version } " , content , count = 1 )
1920
20- if content != new_content :
21+ updated = content != new_content
22+ if updated :
2123 container_file .write_text (new_content )
2224 print (f"Updated { server_name } to { version } " )
23- return True
2425
25- return False
26+ return updated or force
2627
2728
2829def main ():
30+ parser = argparse .ArgumentParser ()
31+ parser .add_argument ("--force" , action = "store_true" , help = "Force update all servers" )
32+ args = parser .parse_args ()
33+
2934 # Capture the output of server_versions.py
3035 result = subprocess .run (
3136 [sys .executable , "scripts/server_versions.py" ],
@@ -37,7 +42,7 @@ def main():
3742
3843 updated_servers = []
3944 for server , version in versions .items ():
40- if update_container_file (server , version ):
45+ if update_container_file (server , version , args . force ):
4146 updated_servers .append (server )
4247
4348 if updated_servers :
0 commit comments