diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index d4e7a17444..ac4017d263 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -56,6 +56,7 @@ experimental_i: - tags script: - PYTHONPATH="$PYTHONPATH:/darwin-containers" python3 -u build-system/Make/Make.py remote-build --darwinContainersHost="http://host.docker.internal:8650" --cacheHost="$TELEGRAM_BAZEL_CACHE_HOST" --configurationPath=build-system/appstore-configuration.json --gitCodesigningRepository="$TELEGRAM_GIT_CODESIGNING_REPOSITORY" --gitCodesigningType=appstore --configuration=release_arm64 + - python3 -u build-system/Make/DeployYoAppCenter.py --configuration="$TELEGRAM_PRIVATE_DATA_PATH/appcenter-configurations/appcenter-experimental.json" --ipa="build/artifacts/Telegram.ipa" --dsyms="build/artifacts/Telegram.DSYMs.zip" environment: name: experimental artifacts: diff --git a/build-system/Make/BuildConfiguration.py b/build-system/Make/BuildConfiguration.py index e36ef0451d..c27e191205 100644 --- a/build-system/Make/BuildConfiguration.py +++ b/build-system/Make/BuildConfiguration.py @@ -5,12 +5,7 @@ import shutil import tempfile import plistlib -from BuildEnvironment import run_executable_with_output - -def check_run_system(command): - if os.system(command) != 0: - print('Command failed: {}'.format(command)) - sys.exit(1) +from BuildEnvironment import run_executable_with_output, check_run_system class BuildConfiguration: def __init__(self, diff --git a/build-system/Make/BuildEnvironment.py b/build-system/Make/BuildEnvironment.py index db75c30f5e..6fa5fe4ee9 100644 --- a/build-system/Make/BuildEnvironment.py +++ b/build-system/Make/BuildEnvironment.py @@ -83,6 +83,12 @@ def call_executable(arguments, use_clean_environment=True, check_result=True): subprocess.call(resolved_arguments, env=resolved_env) +def check_run_system(command): + if os.system(command) != 0: + print('Command failed: {}'.format(command)) + sys.exit(1) + + def get_bazel_version(bazel_path): command_result = run_executable_with_output(bazel_path, ['--version']).strip('\n') if not command_result.startswith('bazel '): diff --git a/build-system/Make/DeployToAppCenter.py b/build-system/Make/DeployToAppCenter.py new file mode 100644 index 0000000000..9fb82cbc42 --- /dev/null +++ b/build-system/Make/DeployToAppCenter.py @@ -0,0 +1,70 @@ +import os +import sys +import argparse +import json + +from BuildEnvironment import check_run_system + +def deploy_to_appcenter(args): + if not os.path.exists(args.configuration): + print('{} does not exist'.format(args.configuration)) + sys.exit(1) + if not os.path.exists(args.ipa): + print('{} does not exist'.format(args.ipa)) + sys.exit(1) + if args.dsyms is not None and not os.path.exists(args.dsyms): + print('{} does not exist'.format(args.dsyms)) + sys.exit(1) + + with open(args.configuration) as file: + configuration_dict = json.load(file) + required_keys = [ + 'username', + 'app_name', + 'api_token', + ] + for key in required_keys: + if key not in configuration_dict: + print('Configuration at {} does not contain {}'.format(args.configuration, key)) + + check_run_system('appcenter login --token {token}'.format(token=configuration_dict['api_token'])) + check_run_system('appcenter distribute release --app "{username}/{app_name}" -f "{ipa_path}" -g Internal'.format( + username=configuration_dict['username'], + app_name=configuration_dict['app_name'], + ipa_path=args.ipa, + + )) + if args.dsyms is not None: + check_run_system('appcenter crashes upload-symbols --app "{username}/{app_name}" --symbol "{dsym_path}"'.format( + username=configuration_dict['username'], + app_name=configuration_dict['app_name'], + dsym_path=args.dsyms + )) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(prog='deploy-appcenter') + + parser.add_argument( + '--configuration', + required=True, + help='Path to configuration json.' + ) + parser.add_argument( + '--ipa', + required=True, + help='Path to IPA.' + ) + parser.add_argument( + '--dsyms', + required=False, + help='Path to DSYMs.zip.' + ) + + if len(sys.argv) < 2: + parser.print_help() + sys.exit(1) + + args = parser.parse_args() + + deploy_to_appcenter(args)