Class: Mysigner::Upload::AscSubmitter

Inherits:
Object
  • Object
show all
Defined in:
lib/mysigner/upload/asc_submitter.rb

Overview

Drives Apple’s REST API directly to submit a freshly-uploaded build for App Store review in ‘–local-only` mode. Replaces the historical “submit-for-review is not automated” hand-off banner.

The vault-mode submit path (Mysigner::Upload::AppStoreSubmission + AppStoreAutomation) calls MySigner-internal endpoints; in local-only we cannot — the whole point of local-only is no server round-trip. So we re-implement just the App Store Connect REST calls a submission actually needs, using the same JWT the AscRestUploader already minted.

Flow (per developer.apple.com/documentation/appstoreconnectapi):

1. POLL  /v1/builds?filter[app]=…&filter[version]=…   until processingState == VALID
2. FIND  /v1/apps/<id>/appStoreVersions?filter[versionString]=…
   or CREATE /v1/appStoreVersions when none exists in PREPARE_FOR_SUBMISSION
3. PATCH /v1/appStoreVersions/<v_id>/relationships/build  (attach build)
4a. POST  /v1/reviewSubmissions                            (create submission container)
4b. POST  /v1/reviewSubmissionItems                        (attach the version)
4c. PATCH /v1/reviewSubmissions/<id> {submitted: true}     (flip to submitted)

WHY 4a/4b/4c instead of the older POST /v1/appStoreVersionSubmissions: Apple deprecated ‘appStoreVersionSubmissions` in favour of the `reviewSubmissions` choreography. The old endpoint silently 4xx’s for apps onboarded after the cut-over, so we use the modern path unconditionally — it works for all apps regardless of vintage.

Returns the submission id (String). Raises a typed error on each foreseeable failure so the CLI rescue can give a one-line, actionable hint without parsing Apple’s raw error bodies.

Defined Under Namespace

Classes: AppleApiError, BuildProcessingTimeoutError, SubmissionRejectedError, VersionAlreadyReleasedError, VersionInFlightError

Constant Summary collapse

APPLE_ASC_BASE =
'https://api.appstoreconnect.apple.com'
DEFAULT_PROCESSING_TIMEOUT =

30 minutes is the working ceiling for build processing on Apple’s side. Most builds finish in <10 minutes but occasional Apple-side backlogs push past 15. Beyond 30 the user almost certainly wants to walk away rather than keep the CLI blocked.

30 * 60
DEFAULT_PROCESSING_POLL_INTERVAL =
30

Instance Method Summary collapse

Constructor Details

#initialize(jwt:, apple_app_id:, cf_bundle_version:, cf_bundle_short_version_string:, platform: 'IOS', processing_timeout: DEFAULT_PROCESSING_TIMEOUT, processing_poll_interval: DEFAULT_PROCESSING_POLL_INTERVAL, logger: $stderr) ⇒ AscSubmitter

Returns a new instance of AscSubmitter.



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/mysigner/upload/asc_submitter.rb', line 86

def initialize(jwt:, apple_app_id:, cf_bundle_version:, cf_bundle_short_version_string:,
               platform: 'IOS',
               processing_timeout: DEFAULT_PROCESSING_TIMEOUT,
               processing_poll_interval: DEFAULT_PROCESSING_POLL_INTERVAL,
               logger: $stderr)
  @jwt = jwt
  @apple_app_id = apple_app_id.to_s
  @cf_bundle_version = cf_bundle_version.to_s
  @cf_bundle_short_version_string = cf_bundle_short_version_string.to_s
  @platform = platform.to_s
  @processing_timeout = processing_timeout
  @processing_poll_interval = processing_poll_interval
  @logger = logger
end

Instance Method Details

#submit!Object

Drives steps 1–4 end-to-end and returns the submission id on success.



102
103
104
105
106
107
# File 'lib/mysigner/upload/asc_submitter.rb', line 102

def submit!
  build_id = wait_for_build_valid!
  version_id = find_or_create_app_store_version!
  attach_build!(version_id, build_id)
  submit_for_review_via_review_submissions!(version_id)
end