Class: Mysigner::Upload::AscRestUploader

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

Defined Under Namespace

Classes: AltoolUploadError, BuildVersionConflictError, MissingLocalCredentialsError

Constant Summary collapse

TERMINAL_APPLE_STATES =
%w[COMPLETE FAILED INVALIDATED].freeze
POLL_INTERVAL =
10
POLL_TIMEOUT =
600
CHUNK_RETRIES =
2
APPLE_ASC_BASE =
'https://api.appstoreconnect.apple.com'
APPLE_PRIVATE_KEYS_DIR =

Apple’s hardcoded discovery path for ASC private keys. ‘altool –apiKey KEY_ID` looks for AuthKey_<KEY_ID>.p8 in this directory (and only this directory) — no flag exists to override it. We ensure the .p8 lives here before invoking altool.

File.expand_path('~/.appstoreconnect/private_keys').freeze

Instance Method Summary collapse

Constructor Details

#initialize(client:, organization_id:, ipa_path:, apple_app_id:, cf_bundle_version:, cf_bundle_short_version_string:, platform: 'IOS', poll_interval: POLL_INTERVAL, poll_timeout: POLL_TIMEOUT, local_only: false, asc_creds: nil) ⇒ AscRestUploader

Returns a new instance of AscRestUploader.



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/mysigner/upload/asc_rest_uploader.rb', line 49

def initialize(client:, organization_id:, ipa_path:, apple_app_id:,
               cf_bundle_version:, cf_bundle_short_version_string:,
               platform: 'IOS', poll_interval: POLL_INTERVAL, poll_timeout: POLL_TIMEOUT,
               local_only: false, asc_creds: nil)
  @client = client
  @org_id = organization_id
  @ipa_path = ipa_path
  @apple_app_id = apple_app_id
  @cf_bundle_version = cf_bundle_version
  @cf_bundle_short_version_string = cf_bundle_short_version_string
  @platform = platform
  @poll_interval = poll_interval
  @poll_timeout = poll_timeout
  @local_only = local_only
  # mysigner-22 Phase 5 — pre-resolved AscCreds Struct from the
  # CredentialResolver cascade. When nil (legacy callers / unit tests),
  # we fall back to the resolver inside resolve_asc_creds with default
  # args (which preserves the Keychain-only behavior the existing specs
  # pin).
  @asc_creds = asc_creds
end

Instance Method Details

#callObject



71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/mysigner/upload/asc_rest_uploader.rb', line 71

def call
  return call_altool! if @local_only

  build_upload_id, ops = create_build_upload_via_server

  File.open(@ipa_path, 'rb') do |f|
    ops.each { |op| put_chunk_with_retry(f, op) }
  end

  md5 = Digest::MD5.file(@ipa_path).hexdigest
  sha = Digest::SHA256.file(@ipa_path).hexdigest

  mark_uploaded_via_server(build_upload_id, md5: md5, sha: sha)

  final = poll_until_terminal_via_server(build_upload_id)
  { build_upload_id: build_upload_id, final_state: final }
end