Created
November 12, 2021 19:02
-
-
Save adamschlesinger/ed94d023ab771124506bdd29c29301a3 to your computer and use it in GitHub Desktop.
Helper fastlane script for generating push certs, provisioning profiles, and distro certs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This file contains the fastlane.tools configuration | |
# You can find the documentation at https://docs.fastlane.tools | |
# | |
# For a list of all available actions, check out | |
# | |
# https://docs.fastlane.tools/actions | |
# | |
# For a list of all available plugins, check out | |
# | |
# https://docs.fastlane.tools/plugins/available-plugins | |
# | |
# Uncomment the line if you want fastlane to automatically update itself | |
# update_fastlane | |
default_platform(:ios) | |
platform :ios do | |
lane :make_push do | |
# change these as necessary (or setup env variables) | |
force = true | |
development = false | |
app_identifier = "{YOUR_BUNDLE_ID_GOES_HERE}" | |
out_dir = "#{Dir.pwd}/../out" | |
Dir.mkdir(out_dir) unless File.directory?(out_dir) | |
password = SecureRandom.urlsafe_base64(12) | |
get_push_certificate( | |
force: force, | |
app_identifier: app_identifier, | |
save_private_key: true, | |
output_path: out_dir, | |
p12_password: password, | |
development: development | |
) | |
env_name = development == true ? 'development' : 'production' | |
File.write("#{out_dir}/#{env_name}_#{app_identifier}_p12_pass", password) | |
app_name = `echo #{app_identifier} | pcregrep -ou "(?:(?!\\.).)+$" | tr -d "\n"` | |
system("zip -j #{out_dir}/#{app_name}-#{env_name}-pushcerts.zip #{out_dir}/*") | |
end | |
lane :make_profiles do | |
# change these as necessary (or setup env variables) | |
platform = "ios" | |
distro_type = "appstore" | |
force = false | |
main_bundle_id = "{YOUR_BUNDLE_ID_GOES_HERE}" | |
app_identifiers = [ | |
main_bundle_id, | |
"#{main_bundle_id}.ServiceExtension" # remove or rename me necessary | |
] | |
work_dir = "#{Dir.pwd}/../workspace" | |
out_dir = "#{Dir.pwd}/../out" | |
Dir.mkdir(work_dir) unless File.directory?(work_dir) | |
Dir.mkdir(out_dir) unless File.directory?(out_dir) | |
sync_code_signing( | |
app_identifier: app_identifiers, | |
git_url: "{YOUR_REPO_GOES_HERE}", | |
platform: platform, | |
type: distro_type, | |
force: force, | |
force_for_new_devices: true, | |
generate_apple_certs: true, | |
output_path: work_dir | |
) | |
system("mv #{work_dir}/*.mobileprovision #{out_dir}") | |
password = SecureRandom.urlsafe_base64(12) | |
cert_id = `basename #{work_dir}/*.cer .cer | tr -d "\n"` | |
system("openssl x509 -inform der -in #{work_dir}/#{cert_id}.cer -out #{work_dir}/cert.pem") | |
system("openssl pkcs12 -export -out #{out_dir}/#{cert_id}.p12 -inkey #{work_dir}/#{cert_id}.p12 -in #{work_dir}/cert.pem -password pass:#{password}") | |
File.write("#{out_dir}/#{cert_id}_p12_pass", password) | |
app_name = `echo #{bundle_id} | pcregrep -ou "(?:(?!\\.).)+$" | tr -d "\n"` | |
system("zip -j #{out_dir}/#{app_name}-#{distro_type}.zip #{out_dir}/*") | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment