Skip to content

Commit 4877ad5

Browse files
author
Dale Myers
committed
Add method to release a version
1 parent a0b9c8a commit 4877ad5

File tree

1 file changed

+49
-1
lines changed

1 file changed

+49
-1
lines changed

asconnect/version_client.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,54 @@ def submit_for_review(
478478
f"Submit failed due to server-side intermittent issue. Will sleep for 1 minute and try again, left attempt: {max_attempts - 1}."
479479
)
480480
time.sleep(60)
481-
self.submit_for_review(version_id=version_id, max_attempts=max_attempts - 1)
481+
self.submit_for_review(
482+
version_id=version_id, max_attempts=max_attempts - 1
483+
)
484+
else:
485+
raise # Re-raise the caught exception
486+
487+
def release(
488+
self,
489+
*,
490+
version_id: str,
491+
max_attempts: int = 3,
492+
) -> None:
493+
"""Release an approved version
494+
495+
:param version_id: The ID of the version to release
496+
:param max_attempts: The number of attempts allowed
497+
498+
:raises AppStoreConnectError: If runs into unretriable error or exceeds retry count
499+
"""
500+
501+
try:
502+
self.log.info(f"Releasing version {version_id}")
503+
504+
self.http_client.post(
505+
endpoint="appStoreVersionReleaseRequests",
506+
data={
507+
"data": {
508+
"type": "appStoreVersionReleaseRequests",
509+
"relationships": {
510+
"appStoreVersion": {
511+
"data": {"type": "appStoreVersions", "id": version_id}
512+
}
513+
},
514+
}
515+
},
516+
log_response=True,
517+
)
518+
519+
except AppStoreConnectError as ex:
520+
if (
521+
max_attempts > 0
522+
and ex.response.status_code >= 500
523+
and ex.response.status_code < 600
524+
):
525+
self.log.info(
526+
f"Submit failed due to server-side intermittent issue. Will sleep for 1 minute and try again, left attempt: {max_attempts - 1}."
527+
)
528+
time.sleep(60)
529+
self.release(version_id=version_id, max_attempts=max_attempts - 1)
482530
else:
483531
raise # Re-raise the caught exception

0 commit comments

Comments
 (0)