codemagic-cli-tools


Namecodemagic-cli-tools JSON
Version 0.50.5 PyPI version JSON
download
home_pagehttps://github.com/codemagic-ci-cd/cli-tools
SummaryCLI tools used in Codemagic builds
upload_time2024-03-19 09:09:36
maintainer
docs_urlNone
authorPriit Lätt
requires_python>=3.7,<4.0
licenseGPL-3.0-or-later
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Codemagic CLI Tools

Codemagic 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 at [codemagic.io](https://codemagic.io) but can be also used in other virtual environments or locally.

# Installing

Codemagic CLI Tools are available on [PyPI](https://pypi.org/project/codemagic-cli-tools/)
and can be installed and updated using [pip](https://pip.pypa.io/en/stable/getting-started/).

```
python -m pip install codemagic-cli-tools
```

The package requires Python version 3.7+.

# Command line usage

Installing the package adds the following executables to your path:

- [`android-app-bundle`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/android-app-bundle/README.md)
- [`android-keystore`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/android-keystore/README.md)
- [`app-store-connect`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/README.md)
- [`codemagic-cli-tools`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/codemagic-cli-tools/README.md)
- [`git-changelog`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/git-changelog/README.md)
- [`google-play`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/google-play/README.md)
- [`keychain`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/keychain/README.md)
- [`universal-apk`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/universal-apk/README.md)
- [`xcode-project`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/xcode-project/README.md)

Online documentation for all installed executables can be found under
[`docs`](https://github.com/codemagic-ci-cd/cli-tools/tree/master/docs#cli-tools).

Alternatively, you could see the documentation by using `--help` option from command line:

```bash
<command> --help
```
to see general description and subcommands for the tool, or

```bash
<command> <subcommand> --help
```
to 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 instead
```

# Usage from Python

In 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 package
[`codemagic.tools`](https://github.com/codemagic-ci-cd/cli-tools/blob/v0.28.0/src/codemagic/tools/__init__.py).
The CLI actions are instance methods that are decorated by the [`action`](https://github.com/codemagic-ci-cd/cli-tools/blob/v0.28.0/src/codemagic/cli/cli_app.py#L385)
decorator. For example, you can use the [`Keychain`](https://github.com/codemagic-ci-cd/cli-tools/blob/v0.28.0/src/codemagic/tools/keychain.py#L111)
tool from Python source as follows:

```python
In [1]: from pathlib import Path

In [2]: from codemagic.tools import Keychain

In [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')
```

# Development

This project uses [Poetry](https://python-poetry.org/) to manage dependencies. Before starting development, please ensure that your
machine has Poetry available. Installation instructions can be found from their
[docs](https://python-poetry.org/docs/#installation).

Assuming you've already cloned the [repository](https://github.com/codemagic-ci-cd/cli-tools/)
itself, or a fork of it, you can get started by running

```shell
poetry install
```

This will install all required dependencies specified in the `poetry.lock` file.

The source code of the project lives inside the `src` directory and tests are
implemented in the `tests` directory.

### Code formatting and linting rules

Automatic code formatting is done with [Black](https://github.com/psf/black).
Invoke Black checks from repository root directory with

```shell
poetry run black --check .
```

Linting rules are enforced using [Ruff](https://beta.ruff.rs).
Checks can be started from repository root with

```shell
poetry run ruff check .
```

### Static type checks

A 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 using
[Mypy](http://mypy-lang.org/) from the repository root by running

```shell
poetry run mypy .
```

### Running tests

[Pytest](https://docs.pytest.org/en/stable/) is used as the framework. As mentioned above,
tests are stored in the `tests` directory, separated from package source code. Test code layout
mirrors the structure of the `codemagic` package in the source directory.

Tests can be started by running the following command from the repository root:

```shell
poetry run pytest
```

Note that tests that target [App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi) or
[Google Play Developer API](https://developers.google.com/android-publisher) live endpoints
are skipped by default for obvious reasons. They can be enabled (either for TDD or other reasons)
by setting the environment variable `RUN_LIVE_API_TESTS` to 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:
    ```shell
    export TEST_APPLE_KEY_IDENTIFIER=...  # Key ID
    export TEST_APPLE_ISSUER_ID=...  # Issued ID
    ```
    And either of the two:
    ```bash
    export TEST_APPLE_PRIVATE_KEY_PATH=...  # Path to private key in .p8 format
    export TEST_APPLE_PRIVATE_KEY_CONTENT=...  # Content of .p8 private key
    ```
  Those can be obtained from [App Store Connect -> Users and Access -> Keys](https://appstoreconnect.apple.com/access/api).
  For more information follow Apple's official documentation about [Creating API Keys for App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api).

- For Google Play:
    ```shell
    export TEST_GCLOUD_PACKAGE_NAME=... # Package name (Ex: com.google.example)'
    ```
    And either of the two:
    ```shell
    export TEST_GCLOUD_SERVICE_ACCOUNT_CREDENTIALS_PATH=... # Path to gcloud service account creedentials with `JSON` key type
    export TEST_GCLOUD_SERVICE_ACCOUNT_CREDENTIALS_CONTENT=... # Content of gcloud service account creedentials with `JSON` key type
    ```

- For Firebase:
    Either of the two:
    ```shell
    export TEST_FIREBASE_SERVICE_ACCOUNT_CREDENTIALS_PATH=... # Path to gcloud service account creedentials with `JSON` key type
    export TEST_FIREBASE_SERVICE_ACCOUNT_CREDENTIALS_CONTENT=... # Content of gcloud service account creedentials with `JSON` key type
    ```

### Pre-commit hooks

Optionally, the [pre-commit](https://pre-commit.com/) framework can be used to ensure that
the source code updates are compliant with all the rules mentioned above.

Installation instructions are available in their [docs](https://pre-commit.com/#installation).

The repository already contains pre-configured `.pre-commit-config.yaml`, so to enable
the hooks, just run

```shell
pre-commit install
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/codemagic-ci-cd/cli-tools",
    "name": "codemagic-cli-tools",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "Priit L\u00e4tt",
    "author_email": "priit@nevercode.io",
    "download_url": "https://files.pythonhosted.org/packages/41/3c/a645a807f71b91768752c46036060eb5e025966eec7f08fa34fcda8ec1d3/codemagic_cli_tools-0.50.5.tar.gz",
    "platform": null,
    "description": "# Codemagic CLI Tools\n\nCodemagic CLI Tools are a set of command-line utilities for managing Android and iOS app builds,\ncode signing, and deployment. The tools are used to power mobile app builds at [codemagic.io](https://codemagic.io) but can be also used in other virtual environments or locally.\n\n# Installing\n\nCodemagic CLI Tools are available on [PyPI](https://pypi.org/project/codemagic-cli-tools/)\nand can be installed and updated using [pip](https://pip.pypa.io/en/stable/getting-started/).\n\n```\npython -m pip install codemagic-cli-tools\n```\n\nThe package requires Python version 3.7+.\n\n# Command line usage\n\nInstalling the package adds the following executables to your path:\n\n- [`android-app-bundle`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/android-app-bundle/README.md)\n- [`android-keystore`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/android-keystore/README.md)\n- [`app-store-connect`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/app-store-connect/README.md)\n- [`codemagic-cli-tools`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/codemagic-cli-tools/README.md)\n- [`git-changelog`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/git-changelog/README.md)\n- [`google-play`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/google-play/README.md)\n- [`keychain`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/keychain/README.md)\n- [`universal-apk`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/universal-apk/README.md)\n- [`xcode-project`](https://github.com/codemagic-ci-cd/cli-tools/blob/master/docs/xcode-project/README.md)\n\nOnline documentation for all installed executables can be found under\n[`docs`](https://github.com/codemagic-ci-cd/cli-tools/tree/master/docs#cli-tools).\n\nAlternatively, you could see the documentation by using `--help` option from command line:\n\n```bash\n<command> --help\n```\nto see general description and subcommands for the tool, or\n\n```bash\n<command> <subcommand> --help\n```\nto get detailed information of the subcommand.\n\n**For example:**\n\n```\n$ keychain create --help\nusage: keychain create [-h] [--log-stream {stderr,stdout}] [--no-color] [--version] [-s] [-v] [-pw PASSWORD] [-p PATH]\n\nCreate a macOS keychain, add it to the search list\n\noptional arguments:\n  -h, --help            show this help message and exit\n\nOptional arguments for command create:\n  -pw PASSWORD, --password PASSWORD\n                        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: '']\n\nOptions:\n  --log-stream {stderr,stdout}\n                        Log output stream. [Default: stderr]\n  --no-color            Do not use ANSI colors to format terminal output\n  --version             Show tool version and exit\n  -s, --silent          Disable log output for commands\n  -v, --verbose         Enable verbose logging for commands\n\nOptional arguments for keychain:\n  -p PATH, --path PATH  Keychain path. If not provided, the system default keychain will be used instead\n```\n\n# Usage from Python\n\nIn addition to the command line interface, the package also provides a mirroring Python API.\nAll utilities that are available as CLI tools are accessible from Python in package\n[`codemagic.tools`](https://github.com/codemagic-ci-cd/cli-tools/blob/v0.28.0/src/codemagic/tools/__init__.py).\nThe CLI actions are instance methods that are decorated by the [`action`](https://github.com/codemagic-ci-cd/cli-tools/blob/v0.28.0/src/codemagic/cli/cli_app.py#L385)\ndecorator. For example, you can use the [`Keychain`](https://github.com/codemagic-ci-cd/cli-tools/blob/v0.28.0/src/codemagic/tools/keychain.py#L111)\ntool from Python source as follows:\n\n```python\nIn [1]: from pathlib import Path\n\nIn [2]: from codemagic.tools import Keychain\n\nIn [3]: Keychain().get_default()\nOut[3]: PosixPath('/Users/priit/Library/Keychains/login.keychain-db')\n\nIn [4]: keychain = Keychain(Path(\"/tmp/new.keychain\"))\n\nIn [5]: keychain.create()\nOut[5]: PosixPath('/tmp/new.keychain')\n\nIn [6]: keychain.make_default()\n\nIn [7]: Keychain().get_default()\nOut[7]: PosixPath('/private/tmp/new.keychain')\n```\n\n# Development\n\nThis project uses [Poetry](https://python-poetry.org/) to manage dependencies. Before starting development, please ensure that your\nmachine has Poetry available. Installation instructions can be found from their\n[docs](https://python-poetry.org/docs/#installation).\n\nAssuming you've already cloned the [repository](https://github.com/codemagic-ci-cd/cli-tools/)\nitself, or a fork of it, you can get started by running\n\n```shell\npoetry install\n```\n\nThis will install all required dependencies specified in the `poetry.lock` file.\n\nThe source code of the project lives inside the `src` directory and tests are\nimplemented in the `tests` directory.\n\n### Code formatting and linting rules\n\nAutomatic code formatting is done with [Black](https://github.com/psf/black).\nInvoke Black checks from repository root directory with\n\n```shell\npoetry run black --check .\n```\n\nLinting rules are enforced using [Ruff](https://beta.ruff.rs).\nChecks can be started from repository root with\n\n```shell\npoetry run ruff check .\n```\n\n### Static type checks\n\nA huge portion of the Python source code has type hints, and all public methods or functions\nare expected to have type hints. Static type checks of the source code are performed using\n[Mypy](http://mypy-lang.org/) from the repository root by running\n\n```shell\npoetry run mypy .\n```\n\n### Running tests\n\n[Pytest](https://docs.pytest.org/en/stable/) is used as the framework. As mentioned above,\ntests are stored in the `tests` directory, separated from package source code. Test code layout\nmirrors the structure of the `codemagic` package in the source directory.\n\nTests can be started by running the following command from the repository root:\n\n```shell\npoetry run pytest\n```\n\nNote that tests that target [App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi) or\n[Google Play Developer API](https://developers.google.com/android-publisher) live endpoints\nare skipped by default for obvious reasons. They can be enabled (either for TDD or other reasons)\nby setting the environment variable `RUN_LIVE_API_TESTS` to any non-empty value.\n\nNote that for the tests to run successfully, you'd have to define the following environment variables:\n- For App Store Connect:\n    ```shell\n    export TEST_APPLE_KEY_IDENTIFIER=...  # Key ID\n    export TEST_APPLE_ISSUER_ID=...  # Issued ID\n    ```\n    And either of the two:\n    ```bash\n    export TEST_APPLE_PRIVATE_KEY_PATH=...  # Path to private key in .p8 format\n    export TEST_APPLE_PRIVATE_KEY_CONTENT=...  # Content of .p8 private key\n    ```\n  Those can be obtained from [App Store Connect -> Users and Access -> Keys](https://appstoreconnect.apple.com/access/api).\n  For more information follow Apple's official documentation about [Creating API Keys for App Store Connect API](https://developer.apple.com/documentation/appstoreconnectapi/creating_api_keys_for_app_store_connect_api).\n\n- For Google Play:\n    ```shell\n    export TEST_GCLOUD_PACKAGE_NAME=... # Package name (Ex: com.google.example)'\n    ```\n    And either of the two:\n    ```shell\n    export TEST_GCLOUD_SERVICE_ACCOUNT_CREDENTIALS_PATH=... # Path to gcloud service account creedentials with `JSON` key type\n    export TEST_GCLOUD_SERVICE_ACCOUNT_CREDENTIALS_CONTENT=... # Content of gcloud service account creedentials with `JSON` key type\n    ```\n\n- For Firebase:\n    Either of the two:\n    ```shell\n    export TEST_FIREBASE_SERVICE_ACCOUNT_CREDENTIALS_PATH=... # Path to gcloud service account creedentials with `JSON` key type\n    export TEST_FIREBASE_SERVICE_ACCOUNT_CREDENTIALS_CONTENT=... # Content of gcloud service account creedentials with `JSON` key type\n    ```\n\n### Pre-commit hooks\n\nOptionally, the [pre-commit](https://pre-commit.com/) framework can be used to ensure that\nthe source code updates are compliant with all the rules mentioned above.\n\nInstallation instructions are available in their [docs](https://pre-commit.com/#installation).\n\nThe repository already contains pre-configured `.pre-commit-config.yaml`, so to enable\nthe hooks, just run\n\n```shell\npre-commit install\n```\n",
    "bugtrack_url": null,
    "license": "GPL-3.0-or-later",
    "summary": "CLI tools used in Codemagic builds",
    "version": "0.50.5",
    "project_urls": {
        "Changelog": "https://github.com/codemagic-ci-cd/cli-tools/blob/master/CHANGELOG.md",
        "Documentation": "https://github.com/codemagic-ci-cd/cli-tools/tree/master/docs#cli-tools",
        "Homepage": "https://github.com/codemagic-ci-cd/cli-tools",
        "Issue Tracker": "https://github.com/codemagic-ci-cd/cli-tools/issues",
        "Repository": "https://github.com/codemagic-ci-cd/cli-tools"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e1076b616e01eb955a8437a40e9d2092b9d489718ead486a39a5b6c5724987a0",
                "md5": "bc7ff514504c84a2965937ee3cdbc9a6",
                "sha256": "08d569c266e11688aa2315f7760c98bf97912ebeac15c6f83a7b629546872974"
            },
            "downloads": -1,
            "filename": "codemagic_cli_tools-0.50.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bc7ff514504c84a2965937ee3cdbc9a6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7,<4.0",
            "size": 27492804,
            "upload_time": "2024-03-19T09:09:31",
            "upload_time_iso_8601": "2024-03-19T09:09:31.256337Z",
            "url": "https://files.pythonhosted.org/packages/e1/07/6b616e01eb955a8437a40e9d2092b9d489718ead486a39a5b6c5724987a0/codemagic_cli_tools-0.50.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "413ca645a807f71b91768752c46036060eb5e025966eec7f08fa34fcda8ec1d3",
                "md5": "1b8274620942d9d5112b98684017338f",
                "sha256": "83b26ea8ae81e833424f40773a5c10186a2460f03dc77c546aad02d96233b3c5"
            },
            "downloads": -1,
            "filename": "codemagic_cli_tools-0.50.5.tar.gz",
            "has_sig": false,
            "md5_digest": "1b8274620942d9d5112b98684017338f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7,<4.0",
            "size": 47080406,
            "upload_time": "2024-03-19T09:09:36",
            "upload_time_iso_8601": "2024-03-19T09:09:36.720550Z",
            "url": "https://files.pythonhosted.org/packages/41/3c/a645a807f71b91768752c46036060eb5e025966eec7f08fa34fcda8ec1d3/codemagic_cli_tools-0.50.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-19 09:09:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "codemagic-ci-cd",
    "github_project": "cli-tools",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "codemagic-cli-tools"
}
        
Elapsed time: 0.22123s