From 6fa250a1152dc9bcf2ab3726fe579a77a66e3e43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Priit=20L=C3=A4tt?= Date: Wed, 23 Aug 2023 15:15:48 +0300 Subject: [PATCH] Fix running `app-store-connect get-certificate` without certificate private key (#337) --- .github/workflows/run-checks.yml | 2 +- CHANGELOG.md | 6 ++++++ pyproject.toml | 2 +- src/codemagic/__version__.py | 2 +- src/codemagic/tools/app_store_connect.py | 19 +++++++++++++------ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-checks.yml b/.github/workflows/run-checks.yml index af3de712..feb28766 100644 --- a/.github/workflows/run-checks.yml +++ b/.github/workflows/run-checks.yml @@ -25,7 +25,7 @@ jobs: - name: Install dependencies run: | - curl -sSL https://install.python-poetry.org | python + curl -sSL https://install.python-poetry.org | python - --version 1.5.1 poetry config virtualenvs.in-project true poetry install --no-interaction diff --git a/CHANGELOG.md b/CHANGELOG.md index 49fd77eb..6d5fcc9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +Version 0.42.1 +------------- + +**Bugfixes** +- Do not require certificate private key to show certificate information using `app-store-connect get-certificate` if certificate is not saved to disk. [PR #XYZ](https://github.com/codemagic-ci-cd/cli-tools/pull/XYZ) + Version 0.42.0 ------------- diff --git a/pyproject.toml b/pyproject.toml index 62f64495..967fed8f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "codemagic-cli-tools" -version = "0.42.0" +version = "0.42.1" description = "CLI tools used in Codemagic builds" readme = "README.md" authors = [ diff --git a/src/codemagic/__version__.py b/src/codemagic/__version__.py index e3569c8d..478a4d77 100644 --- a/src/codemagic/__version__.py +++ b/src/codemagic/__version__.py @@ -1,5 +1,5 @@ __title__ = "codemagic-cli-tools" __description__ = "CLI tools used in Codemagic builds" -__version__ = "0.42.0.dev" +__version__ = "0.42.1.dev" __url__ = "https://github.com/codemagic-ci-cd/cli-tools" __licence__ = "GNU General Public License v3.0" diff --git a/src/codemagic/tools/app_store_connect.py b/src/codemagic/tools/app_store_connect.py index 12aa2330..02061fa0 100755 --- a/src/codemagic/tools/app_store_connect.py +++ b/src/codemagic/tools/app_store_connect.py @@ -19,6 +19,7 @@ from typing import Set from typing import Tuple from typing import Union +from typing import cast from codemagic import cli from codemagic.apple import AppStoreConnectApiError @@ -700,15 +701,18 @@ def get_certificate( """ private_key = _get_certificate_key(certificate_key, certificate_key_password) - if save and private_key is None: + if save and not private_key: raise AppStoreConnectError("Cannot save resource without certificate private key") - else: - assert private_key is not None certificate = self._get_resource(certificate_resource_id, self.api_client.signing_certificates, should_print) if save: - self._save_certificate(certificate, private_key, p12_container_password, p12_container_save_path) + self._save_certificate( + certificate, + cast(PrivateKey, private_key), + p12_container_password, + p12_container_save_path, + ) return certificate @cli.action( @@ -781,8 +785,11 @@ def list_certificates( self.logger.info(f"- {certificate.get_display_info()}") if save: - assert private_key is not None # Make mypy happy - self._save_certificates(certificates, private_key, p12_container_password) + self._save_certificates( + certificates, + cast(PrivateKey, private_key), + p12_container_password, + ) return certificates