9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/fastlane/plugin/fivethree_ionic/actions/fiv_android_keystore_action.rb', line 9
def self.run(params)
output_directory = params[:output_directory]
keystore_name = params[:keystore_name]
keystore_path = File.join(output_directory, keystore_name) + '.keystore'
if File.directory?(output_directory)
if File.exists?(keystore_path)
return keystore_path
end
else
UI.message "android keystore doesnt exist yet. creating one for you..."
Dir.mkdir output_directory
end
puts "Please enter the keystore password for new keystore:"
keychain_entry = CredentialsManager::AccountManager.new(user: "#{keystore_name}_android_keystore_storepass")
password = keychain_entry.password
puts "Please enter the keystore password for new keystore:"
keypass_entry = CredentialsManager::AccountManager.new(user: "#{keystore_name}_android_keystore_keypass")
key_password = keypass_entry.password
alias_name = Fastlane::Actions::PromptAction.run(text:"Enter kexystore alias")
full_name = Fastlane::Actions::PromptAction.run(text:"Enter kexystore full name")
org = Fastlane::Actions::PromptAction.run(text:"Enter kexystore org")
org_unit = Fastlane::Actions::PromptAction.run(text:"Enter kexystore org unit")
city_locality = Fastlane::Actions::PromptAction.run(text:"Enter city")
state_province = Fastlane::Actions::PromptAction.run(text:"Enter state")
country = Fastlane::Actions::PromptAction.run(text:"country")
Actions.lane_context[SharedValues::ANDROID_KEYSTORE_KEYSTORE_PATH] = keystore_path
unless File.file?(keystore_path)
keytool_parts = [
"keytool -genkey -v",
"-keystore #{keystore_path}",
"-alias #{alias_name}",
"-keyalg RSA -keysize 2048 -validity 10000",
"-storepass #{password} ",
"-keypass #{key_password}",
"-dname \"CN=#{full_name}, OU=#{org_unit}, O=#{org}, L=#{city_locality}, S=#{state_province}, C=#{country}\"",
]
sh keytool_parts.join(" ")
else
UI.message "Keystore file already exists - #{keystore_path}"
end
release_signing_path = File.join(output_directory, "release-signing.properties")
Actions.lane_context[SharedValues::ANDROID_KEYSTORE_RELEASE_SIGNING_PATH] = release_signing_path
unless File.file?(release_signing_path)
out_file = File.new(release_signing_path, "w")
out_file.puts("storeFile=#{keystore_name}")
out_file.puts("storePassword=#{password}")
out_file.puts("keyAlias=#{alias_name}")
out_file.puts("keyPassword=#{key_password}")
out_file.close
else
UI.message "release-signing.properties file already exists - #{release_signing_path}"
end
return keystore_path
end
|