latest_testflight_build_number returns the build number (e.g. "2"), not
the marketing version. Previous fix used the version: kwarg which maps
to filter[preReleaseVersion.version] — that's the marketing version
("0.1.70") and never matched the integer build number, so the query
returned no builds and the lane spun on "processing state: unknown"
until timeout.
Apple's API names are confusing: filter[version] is the build number,
filter[preReleaseVersion.version] is the marketing version. The
build_number: kwarg in spaceship maps to filter[version], which is
what we want.
65 lines
2.0 KiB
Ruby
65 lines
2.0 KiB
Ruby
default_platform(:ios)
|
|
|
|
APP_IDENTIFIER = "sh.paseo"
|
|
|
|
platform :ios do
|
|
desc "Submit the latest TestFlight build to App Store Review"
|
|
lane :submit_review do
|
|
api_key = app_store_connect_api_key(
|
|
key_id: ENV.fetch("ASC_KEY_ID"),
|
|
issuer_id: ENV.fetch("ASC_ISSUER_ID"),
|
|
key_filepath: ENV.fetch("ASC_KEY_P8"),
|
|
)
|
|
|
|
build_number = latest_testflight_build_number(
|
|
api_key: api_key,
|
|
app_identifier: APP_IDENTIFIER,
|
|
)
|
|
|
|
require "spaceship"
|
|
Spaceship::ConnectAPI.token = Spaceship::ConnectAPI::Token.create(
|
|
key_id: ENV.fetch("ASC_KEY_ID"),
|
|
issuer_id: ENV.fetch("ASC_ISSUER_ID"),
|
|
filepath: ENV.fetch("ASC_KEY_P8"),
|
|
)
|
|
app = Spaceship::ConnectAPI::App.find(APP_IDENTIFIER)
|
|
UI.user_error!("Could not find app #{APP_IDENTIFIER} on App Store Connect") if app.nil?
|
|
|
|
deadline = Time.now + (30 * 60)
|
|
loop do
|
|
builds = Spaceship::ConnectAPI::Build.all(
|
|
app_id: app.id,
|
|
build_number: build_number.to_s,
|
|
)
|
|
build = builds.find { |b| b.pre_release_version&.platform == "IOS" }
|
|
state = build&.processing_state
|
|
UI.message("Build #{build_number} processing state: #{state || 'unknown'}")
|
|
break if state == "VALID"
|
|
if state == "INVALID" || state == "FAILED"
|
|
UI.user_error!("Build #{build_number} failed App Store processing (state: #{state}).")
|
|
end
|
|
if Time.now > deadline
|
|
UI.user_error!("Timed out waiting for build #{build_number} to finish processing on App Store Connect.")
|
|
end
|
|
sleep(30)
|
|
end
|
|
|
|
deliver(
|
|
api_key: api_key,
|
|
app_identifier: APP_IDENTIFIER,
|
|
build_number: build_number.to_s,
|
|
submit_for_review: true,
|
|
automatic_release: true,
|
|
force: true,
|
|
skip_binary_upload: true,
|
|
skip_screenshots: true,
|
|
skip_metadata: true,
|
|
precheck_include_in_app_purchases: false,
|
|
submission_information: {
|
|
add_id_info_uses_idfa: false,
|
|
export_compliance_uses_encryption: false,
|
|
},
|
|
)
|
|
end
|
|
end
|