From f546a7ab20fe58681f14b5fd2fc0f4338135a566 Mon Sep 17 00:00:00 2001 From: Isaac <> Date: Wed, 2 Apr 2025 18:17:22 +0400 Subject: [PATCH] Cleanup build scripts --- build-system/Make/BuildEnvironment.py | 15 ++++++------ build-system/Make/DeployToFirebase.py | 33 +++++++++++++++++---------- 2 files changed, 29 insertions(+), 19 deletions(-) diff --git a/build-system/Make/BuildEnvironment.py b/build-system/Make/BuildEnvironment.py index 3f7311aa73..db8d6a4da8 100644 --- a/build-system/Make/BuildEnvironment.py +++ b/build-system/Make/BuildEnvironment.py @@ -11,25 +11,26 @@ def is_apple_silicon(): return False -def get_clean_env(): +def get_clean_env(use_clean_env): clean_env = os.environ.copy() - clean_env['PATH'] = '/usr/bin:/bin:/usr/sbin:/sbin' + if use_clean_env: + clean_env['PATH'] = '/usr/bin:/bin:/usr/sbin:/sbin' return clean_env -def resolve_executable(program): +def resolve_executable(program, use_clean_env=True): def is_executable(fpath): return os.path.isfile(fpath) and os.access(fpath, os.X_OK) - for path in get_clean_env()["PATH"].split(os.pathsep): + for path in get_clean_env(use_clean_env=use_clean_env)["PATH"].split(os.pathsep): executable_file = os.path.join(path, program) if is_executable(executable_file): return executable_file return None -def run_executable_with_output(path, arguments, decode=True, input=None, stderr_to_stdout=True, print_command=False, check_result=False): - executable_path = resolve_executable(path) +def run_executable_with_output(path, arguments, use_clean_env=True, decode=True, input=None, stderr_to_stdout=True, print_command=False, check_result=False): + executable_path = resolve_executable(path, use_clean_env=use_clean_env) if executable_path is None: raise Exception('Could not resolve {} to a valid executable file'.format(path)) @@ -45,7 +46,7 @@ def run_executable_with_output(path, arguments, decode=True, input=None, stderr_ stdout=subprocess.PIPE, stderr=stderr_assignment, stdin=subprocess.PIPE, - env=get_clean_env() + env=get_clean_env(use_clean_env=use_clean_env) ) if input is not None: output_data, _ = process.communicate(input=input) diff --git a/build-system/Make/DeployToFirebase.py b/build-system/Make/DeployToFirebase.py index 32c12bf018..e0dcc994a8 100644 --- a/build-system/Make/DeployToFirebase.py +++ b/build-system/Make/DeployToFirebase.py @@ -2,8 +2,9 @@ import os import sys import argparse import json +import re -from BuildEnvironment import check_run_system +from BuildEnvironment import run_executable_with_output def deploy_to_firebase(args): if not os.path.exists(args.configuration): @@ -26,18 +27,26 @@ def deploy_to_firebase(args): if key not in configuration_dict: print('Configuration at {} does not contain {}'.format(args.configuration, key)) sys.exit(1) - - debug_flag = "--debug" if args.debug else "" - command = 'firebase appdistribution:distribute --app {app_id} --groups "{group}" {debug_flag}'.format( - app_id=configuration_dict['app_id'], - group=configuration_dict['group'], - debug_flag=debug_flag - ) - - command += ' "{ipa_path}"'.format(ipa_path=args.ipa) - check_run_system(command) - + firebase_arguments = [ + 'appdistribution:distribute', + '--app', configuration_dict['app_id'], + '--groups', configuration_dict['group'], + args.ipa + ] + + output = run_executable_with_output( + 'firebase', + firebase_arguments, + use_clean_env=False, + check_result=True + ) + + sharing_link_match = re.search(r'Share this release with testers who have access: (https://\S+)', output) + if sharing_link_match: + print(f"Sharing link: {sharing_link_match.group(1)}") + else: + print("No sharing link found in the output.") if __name__ == '__main__': parser = argparse.ArgumentParser(prog='deploy-firebase')