Skip to content

Commit

Permalink
Add option to expire builds only for selected platform (#407)
Browse files Browse the repository at this point in the history
  • Loading branch information
priitlatt authored May 30, 2024
1 parent 136737a commit 53f13aa
Show file tree
Hide file tree
Showing 12 changed files with 52 additions and 5 deletions.
16 changes: 14 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
Version UNRELEASED
Version 0.52.0
-------------

**Feature**
- Add optional argument `--platform` to action `app-store-connect apps builds` to list builds only for selected platform. [PR #407](https://github.com/codemagic-ci-cd/cli-tools/pull/407)
- Add optional argument `--platform` to action `app-store-connect builds list` to list builds only for selected platform. [PR #407](https://github.com/codemagic-ci-cd/cli-tools/pull/407)
- Add optional argument `--platform` to action `app-store-connect apps expire-build-submitted-for-review` to expire builds only for specified platform. [PR #407](https://github.com/codemagic-ci-cd/cli-tools/pull/407)

**Bugfixes**
- Fix argument `--credentials` validation for tool `google-play`. [PR #405](https://github.com/codemagic-ci-cd/cli-tools/pull/405)
- Action `app-store-connect publish` will only expire builds for the same platform that is being published when invoked with option `--expire-build-submitted-for-review`. [PR #407](https://github.com/codemagic-ci-cd/cli-tools/pull/407)
- Fix argument `--credentials` validation for tool `google-play`. [PR #406](https://github.com/codemagic-ci-cd/cli-tools/pull/406)

**Documentation**
- Update documentation for actions: [PR #407](https://github.com/codemagic-ci-cd/cli-tools/pull/407)
- `app-store-connect apps builds`,
- `app-store-connect apps expire-build-submitted-for-review`,
- `app-store-connect builds list`.

Version 0.51.1
-------------
Expand Down
5 changes: 5 additions & 0 deletions docs/app-store-connect/apps/builds.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ app-store-connect apps builds [-h] [--log-stream STREAM] [--no-color] [--version
[--not-expired]
[--pre-release-version PRE_RELEASE_VERSION]
[--processing-state PROCESSING_STATE]
[--platform PLATFORM]
APPLICATION_ID_RESOURCE_ID
```
### Required arguments for action `builds`
Expand Down Expand Up @@ -62,6 +63,10 @@ Version of the build published to Testflight that identifies an iteration of the


Build processing state
##### `--platform=IOS | MAC_OS | TV_OS`


Apple operating systems
### Optional arguments for command `app-store-connect`

##### `--log-api-calls`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ app-store-connect apps expire-build-submitted-for-review [-h] [--log-stream STRE
[--private-key PRIVATE_KEY]
[--certificates-dir CERTIFICATES_DIRECTORY]
[--profiles-dir PROFILES_DIRECTORY]
[--platform PLATFORM]
APPLICATION_ID_RESOURCE_ID
```
### Required arguments for action `expire-build-submitted-for-review`
Expand All @@ -25,6 +26,12 @@ app-store-connect apps expire-build-submitted-for-review [-h] [--log-stream STRE


Application Apple ID. An automatically generated ID assigned to your app
### Optional arguments for action `expire-build-submitted-for-review`

##### `--platform=IOS | MAC_OS | TV_OS`


Apple operating systems
### Optional arguments for command `app-store-connect`

##### `--log-api-calls`
Expand Down
5 changes: 5 additions & 0 deletions docs/app-store-connect/builds/list.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ app-store-connect builds list [-h] [--log-stream STREAM] [--no-color] [--version
[--not-expired]
[--pre-release-version PRE_RELEASE_VERSION]
[--processing-state PROCESSING_STATE]
[--platform PLATFORM]
```
### Optional arguments for action `list`

Expand Down Expand Up @@ -60,6 +61,10 @@ Version of the build published to Testflight that identifies an iteration of the


Build processing state
##### `--platform=IOS | MAC_OS | TV_OS`


Apple operating systems
### Optional arguments for command `app-store-connect`

##### `--log-api-calls`
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.51.1"
version = "0.52.0"
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.51.1.dev"
__version__ = "0.55.0.dev"
__url__ = "https://github.com/codemagic-ci-cd/cli-tools"
__licence__ = "GNU General Public License v3.0"
3 changes: 3 additions & 0 deletions src/codemagic/apple/resources/resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,3 +355,6 @@ def __str__(self) -> str:
value = self._format_attribute_value(attribute_name, value)
s += f"\n{name}: {value}"
return s

def __repr__(self):
return f'<{self.__class__.__name__}: "{self.id}">'
2 changes: 2 additions & 0 deletions src/codemagic/tools/app_store_connect/abstract_base_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ def expire_app_builds(
def expire_build_submitted_for_review(
self,
application_id: ResourceId,
platform: Optional[Platform] = None,
should_print: bool = False,
) -> Optional[Build]:
from .action_groups import AppsActionGroup
Expand Down Expand Up @@ -439,6 +440,7 @@ def list_builds(
processing_state: Optional[BuildProcessingState] = None,
beta_review_state: Optional[Union[BetaReviewState, Sequence[BetaReviewState]]] = None,
build_version_number: Optional[int] = None,
platform: Optional[Platform] = None,
should_print: bool = True,
) -> List[Build]:
from .action_groups import BuildsActionGroup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from ..arguments import ArgumentGroups
from ..arguments import BuildArgument
from ..arguments import BundleIdArgument
from ..arguments import CommonArgument
from ..arguments import ReviewSubmissionArgument

if TYPE_CHECKING:
Expand Down Expand Up @@ -197,11 +198,13 @@ def expire_app_builds(
@cli.action(
"expire-build-submitted-for-review",
AppArgument.APPLICATION_ID_RESOURCE_ID,
CommonArgument.PLATFORM,
action_group=AppStoreConnectActionGroup.APPS,
)
def expire_build_submitted_for_review(
self,
application_id: ResourceId,
platform: Optional[Platform] = None,
should_print: bool = False,
) -> Optional[Build]:
"""
Expand All @@ -217,6 +220,7 @@ def expire_build_submitted_for_review(
application_id=application_id,
not_expired=True,
beta_review_state=states_to_cancel,
platform=platform,
should_print=should_print,
)
try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from codemagic.apple.resources import PreReleaseVersion
from codemagic.apple.resources import ResourceId
from codemagic.apple.resources.enums import BetaReviewState
from codemagic.apple.resources.enums import Platform
from codemagic.cli import Argument
from codemagic.cli import Colors

Expand Down Expand Up @@ -76,6 +77,7 @@ def list_builds(
processing_state: Optional[BuildProcessingState] = None,
beta_review_state: Optional[Union[BetaReviewState, Sequence[BetaReviewState]]] = None,
build_version_number: Optional[int] = None,
platform: Optional[Platform] = None,
should_print: bool = True,
) -> List[Build]:
"""
Expand All @@ -95,6 +97,7 @@ def list_builds(
beta_app_review_submission_beta_review_state=beta_review_state,
version=build_version_number,
pre_release_version_version=pre_release_version,
pre_release_version_platform=platform,
)
return self._list_resources(
builds_filter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,13 @@ def submit_to_testflight(
build = self.wait_until_build_is_processed(build, max_processing_minutes)

if expire_build_submitted_for_review:
pre_release_version = self.api_client.builds.read_pre_release_version(build)
self.logger.info(Colors.BLUE("\nExpire previous build before creating submission"))
self.expire_build_submitted_for_review(application_id=app.id, should_print=False)
self.expire_build_submitted_for_review(
application_id=app.id,
platform=pre_release_version.attributes.platform if pre_release_version else None,
should_print=False,
)

return self.create_beta_app_review_submission(build.id)

Expand Down
1 change: 1 addition & 0 deletions src/codemagic/tools/app_store_connect/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,7 @@ class ArgumentGroups:
BuildArgument.NOT_EXPIRED,
BuildArgument.PRE_RELEASE_VERSION,
BuildArgument.PROCESSING_STATE,
CommonArgument.PLATFORM,
)
PACKAGE_UPLOAD_ARGUMENTS = (
PublishArgument.ENABLE_PACKAGE_VALIDATION,
Expand Down

0 comments on commit 53f13aa

Please sign in to comment.