Package: codemagic-cli-tools
Codemagic CLI ToolsCodemagic CLI Tools are a set of command-line utilities for managing Android and iOS app builds,
code signing, and deployment. The tools are used to power mobile app builds atcodemagic.iobut can be also used in other virtual environments or locally.InstallingCodemagic CLI Tools are available onPyPIand can be installed and updated usingpip.python -m pip install codemagic-cli-toolsThe package requires Python version 3.7+.Command line usageInstalling the package adds the following executables to your path:android-app-bundleandroid-keystoreapp-store-connectcodemagic-cli-toolsgit-changeloggoogle-playkeychainuniversal-apkxcode-projectOnline documentation for all installed executables can be found underdocs.Alternatively, you could see the documentation by using--helpoption from command line:<command>--helpto see general description and subcommands for the tool, or<command><subcommand>--helpto get detailed information of the subcommand.For example:$ keychain create --help
usage: keychain create [-h] [--log-stream {stderr,stdout}] [--no-color] [--version] [-s] [-v] [-pw PASSWORD] [-p PATH]

Create a macOS keychain, add it to the search list

optional arguments:
  -h, --help            show this help message and exit

Optional arguments for command create:
  -pw PASSWORD, --password PASSWORD
                        Keychain password. Alternatively to entering PASSWORD in plaintext, it may also be specified using the "@env:" prefix followed by an environment variable name, or the "@file:" prefix followed by a path to the file containing the value. Example: "@env:<variable>" uses the value in the environment variable named "<variable>", and "@file:<file_path>" uses the value from the file at "<file_path>". [Default: '']

Options:
  --log-stream {stderr,stdout}
                        Log output stream. [Default: stderr]
  --no-color            Do not use ANSI colors to format terminal output
  --version             Show tool version and exit
  -s, --silent          Disable log output for commands
  -v, --verbose         Enable verbose logging for commands

Optional arguments for keychain:
  -p PATH, --path PATH  Keychain path. If not provided, the system default keychain will be used insteadUsage from PythonIn addition to the command line interface, the package also provides a mirroring Python API.
All utilities that are available as CLI tools are accessible from Python in packagecodemagic.tools.
The CLI actions are instance methods that are decorated by theactiondecorator. For example, you can use theKeychaintool from Python source as follows:In[1]:frompathlibimportPathIn[2]:fromcodemagic.toolsimportKeychainIn[3]:Keychain().get_default()Out[3]:PosixPath('/Users/priit/Library/Keychains/login.keychain-db')In[4]:keychain=Keychain(Path("/tmp/new.keychain"))In[5]:keychain.create()Out[5]:PosixPath('/tmp/new.keychain')In[6]:keychain.make_default()In[7]:Keychain().get_default()Out[7]:PosixPath('/private/tmp/new.keychain')DevelopmentThis project usesPoetryto manage dependencies. Before starting development, please ensure that your
machine has Poetry available. Installation instructions can be found from theirdocs.Assuming you've already cloned therepositoryitself, or a fork of it, you can get started by runningpoetryinstallThis will install all required dependencies specified in thepoetry.lockfile.The source code of the project lives inside thesrcdirectory and tests are
implemented in thetestsdirectory.Code formatting and linting rulesAutomatic code formatting is done withBlack.
Invoke Black checks from repository root directory withpoetryrunblack--check.Linting rules are enforced usingRuff.
Checks can be started from repository root withpoetryrunruffcheck.Static type checksA huge portion of the Python source code has type hints, and all public methods or functions
are expected to have type hints. Static type checks of the source code are performed usingMypyfrom the repository root by runningpoetryrunmypy.Running testsPytestis used as the framework. As mentioned above,
tests are stored in thetestsdirectory, separated from package source code. Test code layout
mirrors the structure of thecodemagicpackage in the source directory.Tests can be started by running the following command from the repository root:poetryrunpytestNote that tests that targetApp Store Connect APIorGoogle Play Developer APIlive endpoints
are skipped by default for obvious reasons. They can be enabled (either for TDD or other reasons)
by setting the environment variableRUN_LIVE_API_TESTSto any non-empty value.Note that for the tests to run successfully, you'd have to define the following environment variables:For App Store Connect:exportTEST_APPLE_KEY_IDENTIFIER=...# Key IDexportTEST_APPLE_ISSUER_ID=...# Issued IDAnd either of the two:exportTEST_APPLE_PRIVATE_KEY_PATH=...# Path to private key in .p8 formatexportTEST_APPLE_PRIVATE_KEY_CONTENT=...# Content of .p8 private keyThose can be obtained fromApp Store Connect -> Users and Access -> Keys.
For more information follow Apple's official documentation aboutCreating API Keys for App Store Connect API.For Google Play:exportTEST_GCLOUD_PACKAGE_NAME=...# Package name (Ex: com.google.example)'And either of the two:exportTEST_GCLOUD_SERVICE_ACCOUNT_CREDENTIALS_PATH=...# Path to gcloud service account creedentials with `JSON` key typeexportTEST_GCLOUD_SERVICE_ACCOUNT_CREDENTIALS_CONTENT=...# Content of gcloud service account creedentials with `JSON` key typeFor Firebase:
Either of the two:exportTEST_FIREBASE_SERVICE_ACCOUNT_CREDENTIALS_PATH=...# Path to gcloud service account creedentials with `JSON` key typeexportTEST_FIREBASE_SERVICE_ACCOUNT_CREDENTIALS_CONTENT=...# Content of gcloud service account creedentials with `JSON` key typePre-commit hooksOptionally, thepre-commitframework can be used to ensure that
the source code updates are compliant with all the rules mentioned above.Installation instructions are available in theirdocs.The repository already contains pre-configured.pre-commit-config.yaml, so to enable
the hooks, just runpre-commitinstall