Skip to content

Commit

Permalink
Fix running app-store-connect get-certificate without certificate p…
Browse files Browse the repository at this point in the history
…rivate key (#337)
  • Loading branch information
priitlatt authored Aug 23, 2023
1 parent 691d14f commit 6fa250a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/run-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
-------------

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 = [
Expand Down
2 changes: 1 addition & 1 deletion src/codemagic/__version__.py
Original file line number Diff line number Diff line change
@@ -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"
19 changes: 13 additions & 6 deletions src/codemagic/tools/app_store_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 6fa250a

Please sign in to comment.