Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix running app-store-connect get-certificate without certificate private key #337

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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