Fix deployment of iOS to TestFlight (#5208)
* use API Key for iOS build & deployment * fix api key file path * iOS API key from p8 file instead of json * Properly split api key on newlines
This commit is contained in:
parent
3404495133
commit
d68cc9c5e1
1 changed files with 36 additions and 8 deletions
|
|
@ -84,11 +84,11 @@ lane :set_app_version do
|
|||
unless version_number.nil? || version_number.empty?
|
||||
package = load_config_json('../package.json')
|
||||
package['version'] = version_number
|
||||
save_config_json('../package.json', package)
|
||||
save_json_as_file('../package.json', package)
|
||||
|
||||
lock = load_config_json('../package-lock.json')
|
||||
lock['version'] = version_number
|
||||
save_config_json('../package-lock.json', lock)
|
||||
save_json_as_file('../package-lock.json', lock)
|
||||
|
||||
android_set_version_name(
|
||||
gradle_file: './android/app/build.gradle',
|
||||
|
|
@ -166,7 +166,7 @@ lane :configure do
|
|||
end
|
||||
|
||||
# Save the config.json file
|
||||
save_config_json('../dist/assets/config.json', json)
|
||||
save_json_as_file('../dist/assets/config.json', json)
|
||||
|
||||
configured = true
|
||||
end
|
||||
|
|
@ -630,7 +630,7 @@ platform :android do
|
|||
json['TelemetryEnabled'] = true
|
||||
json['TelemetryUrl'] = ENV['TELEMETRY_URL']
|
||||
json['TelemetryApiKey'] = ENV['TELEMETRY_API_KEY']
|
||||
save_config_json('../dist/assets/config.json', json)
|
||||
save_json_as_file('../dist/assets/config.json', json)
|
||||
|
||||
beta_dir = './android/app/src/main/java/com/mattermost/rnbeta/'
|
||||
|
||||
|
|
@ -809,7 +809,7 @@ def load_config_json(json_path)
|
|||
JSON.parse(config_file)
|
||||
end
|
||||
|
||||
def save_config_json(json_path, json)
|
||||
def save_json_as_file(json_path, json)
|
||||
File.open(json_path, 'w') do |f|
|
||||
f.write(JSON.pretty_generate(json))
|
||||
f.write("\n")
|
||||
|
|
@ -849,9 +849,37 @@ def submit_to_testflight(ipa_path)
|
|||
|
||||
if !ipa.nil?
|
||||
UI.success("ipa file #{ipa}")
|
||||
pilot(
|
||||
ipa: ipa
|
||||
)
|
||||
unless ENV['IOS_API_KEY_ID'].nil? || ENV['IOS_API_KEY_ID'].empty? ||
|
||||
ENV['IOS_API_ISSUER_ID'].nil? || ENV['IOS_API_ISSUER_ID'].empty? ||
|
||||
ENV['IOS_API_KEY'].nil? || ENV['IOS_API_KEY'].empty?
|
||||
api_key_path = "#{ENV['IOS_API_KEY_ID']}.p8"
|
||||
File.open("../#{api_key_path}", 'w') do |f|
|
||||
key_string = ENV['IOS_API_KEY']
|
||||
p8_array = key_string.split('\n')
|
||||
p8_array.each_with_index do |value, index|
|
||||
f.write(value)
|
||||
f.write("\n") unless index == p8_array.length - 1
|
||||
end
|
||||
end
|
||||
|
||||
api_key = app_store_connect_api_key(
|
||||
key_id: ENV['IOS_API_KEY_ID'],
|
||||
issuer_id: ENV['IOS_API_ISSUER_ID'],
|
||||
key_filepath: "./#{api_key_path}",
|
||||
in_house: ENV['IOS_IN_HOUSE'] == 'true', # optional but may be required if using match/sigh
|
||||
)
|
||||
|
||||
File.delete("../#{api_key_path}")
|
||||
pilot(
|
||||
ipa: ipa,
|
||||
api_key: api_key
|
||||
)
|
||||
else
|
||||
UI.success("Uploading with Username / Password")
|
||||
pilot(
|
||||
ipa: ipa
|
||||
)
|
||||
end
|
||||
else
|
||||
UI.user_error! "ipa file does not exist #{ipa}"
|
||||
return
|
||||
|
|
|
|||
Loading…
Reference in a new issue