Codemagic CLI tools
How to use Codemagic CLI tools locally or in other environments
codemagic-cli-tools is a set of tools to simplify builds at Codemagic. They can be installed with via pip and run locally.
pip3 install codemagic-cli-tools
Build and code sign an Xcode project
To fetch (or create and download) the provisioning profile(s) and certificate for MY_BUNDLE_ID
app, use the app-store-connect tool.
app-store-connect fetch-signing-files \
--issuer-id ISSUER_ID \
--key-id KEY_IDENTIFIER \
--private-key PRIVATE_KEY \
--certificate-key PRIVATE_KEY \
MY_BUNDLE_ID
By default, your certificate will be saved to $HOME/Library/MobileDevice/Certificates
and the provisioning profile(s) will be saved to $HOME/Library/MobileDevice/Provisioning Profiles
.
Refer to Signing iOS apps for more information about accessing App Store Connect.
To initialize keychain at system default keychain path with empty keychain password and add your certificate.p12
with certificate password, use the keychain tool with the following command:
keychain initialize
keychain add-certificates --certificate /path/to/certificate.p12 --certificate-password CERTIFICATE_PASSWORD
Note that --certificate
option can be either a path literal, or a glob pattern to match certificates.
To use the provisioning profile from /path/to/profile.mobileprovision
in your Xcode project located at /path/to/MyProject.xcodeproj
and generate an .ipa archive using scheme MyScheme
, use xcode-project with the following command:
xcode-project use-profiles --project /path/to/MyProject.xcodeproj --profile /path/to/profile.mobileprovision
xcode-project build-ipa --project /path/to/MyProject.xcodeproj --scheme MyScheme
Note that --project
option can be either a path literal, or a glob pattern to match projects in the working directory (default is **/*.xcodeproj
).
--profile
option can be a glob pattern as well (default is $HOME/Library/MobileDevice/Provisioning Profiles/*.mobileprovision
).
Generate universal .apk(s) with user-specified keys from the app bundle
To build .apk files(s) from the app bundle(s) found with /path/to/**/*.aab
glob pattern with keystore /path/to/keystore.keystore
, KEYSTORE_PASSWORD
, KEY_ALIAS
and KEY_PASSWORD
, use the android-app-bundle tool:
android-app-bundle build-universal-apk \
--bundle '/path/to/**/*.aab' \
--ks /path/to/keystore.keystore \
--ks-pass KEYSTORE_PASSWORD \
--ks-key-alias KEY_ALIAS \
--key-pass KEY_PASSWORD
If --bundle
option is not specified, default glob pattern **/*.aab
will be used. Please make sure to wrap the pattern in single quotes.
Tip: Instead of entering ISSUER_ID
, KEY_IDENTIFIER
, PRIVATE_KEY
, CERTIFICATE_PASSWORD
, KEYSTORE_PASSWORD
, KEY_PASSWORD
as plaintext, you may specify them using an @env:
prefix followed by an environment variable name, or @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 file at <file_path>
.
Please refer to the documentation for more details.
Generate a changelog text from Git history
To generate a changelog text from Git history, use the git-changelog tool. For example, to generate a changelog to CHANGELOG
file starting from the previous tag, use:
git-changelog generate --previous-commit ${CM_PREVIOUS_COMMIT} \
`git rev-list --tags --skip=1 --max-count=1` > CHANGELOG