Codemagic CLI Tools

0.64.0 · active · verified Sat Apr 11

Codemagic CLI Tools is a collection of command-line utilities designed to simplify Android and iOS app builds, code signing, and deployment. These tools power the codemagic.io CI/CD service but can also be used locally or in other CI/CD environments. The library is currently at version 0.64.0 and sees active development with frequent releases addressing new features, bug fixes, and compatibility updates, often tied to Xcode and App Store Connect changes.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up environment variables for App Store Connect API keys and then use the `app-store-connect fetch-signing-files` CLI command. This command is crucial for managing iOS code signing assets, such as provisioning profiles and certificates. Securely providing credentials via environment variables is a common and recommended practice.

import os

# Set required environment variables for App Store Connect API key
# Replace with your actual Issuer ID, Key Identifier, and a path to your .p8 private key file
# It's recommended to load these from a secure source (e.g., CI/CD secrets) in production.
os.environ['APP_STORE_CONNECT_ISSUER_ID'] = os.environ.get('APP_STORE_CONNECT_ISSUER_ID', 'YOUR_ISSUER_ID')
os.environ['APP_STORE_CONNECT_KEY_IDENTIFIER'] = os.environ.get('APP_STORE_CONNECT_KEY_IDENTIFIER', 'YOUR_KEY_IDENTIFIER')
os.environ['APP_STORE_CONNECT_PRIVATE_KEY_FILE'] = os.environ.get('APP_STORE_CONNECT_PRIVATE_KEY_FILE', '/path/to/AuthKey_YOUR_KEY_IDENTIFIER.p8')

# Example CLI command: Fetch iOS signing files
# This command attempts to fetch or create provisioning profiles and certificates
# for a given bundle ID from App Store Connect.
# NOTE: In v0.64.0, default save locations changed (see warnings).
cmd = (
    "app-store-connect fetch-signing-files "
    "--issuer-id $APP_STORE_CONNECT_ISSUER_ID "
    "--key-id $APP_STORE_CONNECT_KEY_IDENTIFIER "
    "--private-key @file:$APP_STORE_CONNECT_PRIVATE_KEY_FILE "
    "com.example.yourapp"
)

print(f"Running command:\n{cmd}")
# In a real script, you would use subprocess.run(cmd, shell=True, check=True)
# For quickstart, we just print the command as direct execution requires setup.
# import subprocess
# try:
#     result = subprocess.run(cmd, shell=True, check=True, capture_output=True, text=True)
#     print("STDOUT:\n", result.stdout)
#     print("STDERR:\n", result.stderr)
# except subprocess.CalledProcessError as e:
#     print(f"Command failed with error: {e}")
#     print("STDOUT:\n", e.stdout)
#     print("STDERR:\n", e.stderr)

view raw JSON →