Cleanup build scripts

This commit is contained in:
Isaac 2025-04-02 18:17:22 +04:00
parent 518e04cab7
commit f546a7ab20
2 changed files with 29 additions and 19 deletions

View File

@ -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)

View File

@ -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')