Compare commits

...

7 Commits

5 changed files with 57 additions and 25 deletions

View File

@ -7,7 +7,7 @@ module Fastlane
def self.run(params) def self.run(params)
# Check parameters # Check parameters
unless Helper::AndroidCdHelper.is_set(params[:beta_type]) unless Helper::AndroidCdHelper.is_set(params[:beta_type])
UI.error("❌ Parameters beta_type cannot be null") UI.user_error!("❌ Parameters beta_type cannot be null")
puts("Error on beta type parameter") puts("Error on beta type parameter")
end end
@ -17,23 +17,23 @@ module Fastlane
Helper::AndroidCdHelper.decrypt_android_keys('.') Helper::AndroidCdHelper.decrypt_android_keys('.')
# Clean the project before building # Clean the project before building
Fastlane::Actions.gradle(task: "clean") other_action.gradle(task: "clean")
# Set the build number based on the number of commits # Set the build number based on the number of commits
build_number = Fastlane::Actions.number_of_commits build_number = other_action.number_of_commits
# Build the Android App Bundle # Build the Android App Bundle
Actions(GradleAction.run( other_action.gradle(
task: "bundle", task: "bundle",
build_type: "Release", build_type: "Release",
print_command: true, print_command: true,
properties: { properties: {
"android.injected.version.code" => build_number "android.injected.version.code" => build_number
} }
)) )
# Upload the Android App Bundle to the Play Store # Upload the Android App Bundle to the Play Store
Actions::UploadToPlayStoreAction.run( other_action.upload_to_play_store(
track: params[:beta_type], track: params[:beta_type],
json_key: './service_account_key.json', json_key: './service_account_key.json',
aab: '../build/app/outputs/bundle/release/app-release.aab', aab: '../build/app/outputs/bundle/release/app-release.aab',
@ -44,6 +44,12 @@ module Fastlane
version_code: build_number version_code: build_number
) )
# Delete artifacts files
artifacts = ['android_keys.zip', 'key.jks', 'key.properties', 'service_account_key.json']
artifacts.each do |file|
File.delete(file) if File.exist?(file)
end
UI.success('🍺 Successfully build & deploy appbundle to Google Play Store') UI.success('🍺 Successfully build & deploy appbundle to Google Play Store')
end end

View File

@ -7,14 +7,12 @@ module Fastlane
def self.run(params) def self.run(params)
# Check from parameters # Check from parameters
unless Helper::AndroidCdHelper.is_set(params[:from]) unless Helper::AndroidCdHelper.is_set(params[:from])
UI.error("❌ Parameters from cannot be null") UI.user_error!("❌ Parameters from cannot be null")
puts("Error on beta type parameter")
end end
# Check destination parameters # Check destination parameters
unless Helper::AndroidCdHelper.is_set(params[:destination]) unless Helper::AndroidCdHelper.is_set(params[:destination])
UI.error("❌ Parameters destination cannot be null") UI.user_error!("❌ Parameters destination cannot be null")
puts("Error on beta type parameter")
end end
UI.message("⌛️ Promoting to Google Play Store from #{params[:from]} to #{params[:destination]}..") UI.message("⌛️ Promoting to Google Play Store from #{params[:from]} to #{params[:destination]}..")
@ -23,7 +21,7 @@ module Fastlane
Helper::AndroidCdHelper.decrypt_android_keys('.') Helper::AndroidCdHelper.decrypt_android_keys('.')
# Upload the Android App Bundle to the Play Store # Upload the Android App Bundle to the Play Store
Fastlane::Actions.upload_to_play_store( other_action.upload_to_play_store(
track: params[:from], track: params[:from],
json_key: './service_account_key.json', json_key: './service_account_key.json',
skip_upload_apk: true, skip_upload_apk: true,

View File

@ -17,7 +17,7 @@ module Fastlane
# Move the extracted files to the current directory # Move the extracted files to the current directory
`jar xvf #{android_directory} && mv #{android_directory}/android_keys/* #{android_directory}` `jar xvf #{android_directory} && mv #{android_directory}/android_keys/* #{android_directory}`
else else
puts("Erreur lors de la décompression du fichier GPG") UI.user_error!("Erreur lors de la décompression du fichier GPG")
end end
end end

View File

@ -7,8 +7,14 @@ module Fastlane
def self.run(params) def self.run(params)
# Check parameters # Check parameters
unless Helper::IosCdHelper.is_set(params[:beta_type]) unless Helper::IosCdHelper.is_set(params[:beta_type])
UI.error("❌ Parameters beta_type cannot be null") raise ArgumentError, "❌ Parameters beta_type cannot be null"
puts("Error on beta type parameter") end
# Check if match password exist
match_password = ENV['MATCH_PASSWORD']
if match_password.nil? || match_password.empty?
raise ArgumentError, "❌ match password must be provided"
end end
UI.message("⌛️ Building and deploying to Store in #{params[:beta_type]}..") UI.message("⌛️ Building and deploying to Store in #{params[:beta_type]}..")
@ -18,9 +24,23 @@ module Fastlane
UI.message("👉🏼 Credentials decrypted.") UI.message("👉🏼 Credentials decrypted.")
# Retrieve credentials # Retrieve credentials
creds = Helper::IosCdHelper.parseIosCredentials('.') creds = Helper::IosCdHelper.parse_ios_credentials('.')
UI.message("👉🏼 Credentials parsed.") UI.message("👉🏼 Credentials parsed.")
# Delete decrypted artifacts
artifacts = ['ios_keys.zip', 'ios_credentials.json']
artifacts.each do |file|
File.delete(file) if File.exist?(file)
end
# Check credentials
required_fields = ['developer_app_id', 'username', 'developer_app_identifier', 'app_identifier_extensions', 'apple_issuer_id', 'apple_key_id', 'team_id', 'team_name', 'apple_key_content', 'git_url', 'git_basic_authorization', 'provisioning_profiles', 'temp_keychain_user', 'temp_keychain_password']
missing_fields = required_fields - creds.keys
unless missing_fields.empty?
raise ArgumentError, "❌ missing keys in credential json file : #{missing_fields}"
end
# Delete keychain if existing # Delete keychain if existing
if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db")) if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db"))
other_action.delete_keychain( other_action.delete_keychain(
@ -82,7 +102,7 @@ module Fastlane
api_key: api_key, api_key: api_key,
type: 'appstore', type: 'appstore',
app_identifier: creds['app_identifier_extensions'], app_identifier: creds['app_identifier_extensions'],
git_basic_authorization: Base64.strict_encode64(ENV["GIT_AUTHORIZATION"]), git_basic_authorization: Base64.strict_encode64(creds['git_basic_authorization']),
keychain_name: creds['temp_keychain_user'].to_s, keychain_name: creds['temp_keychain_user'].to_s,
keychain_password: creds['temp_keychain_password'].to_s, keychain_password: creds['temp_keychain_password'].to_s,
git_url: creds['git_url'].to_s, git_url: creds['git_url'].to_s,
@ -124,6 +144,12 @@ module Fastlane
name: creds['temp_keychain_user'] name: creds['temp_keychain_user']
) )
end end
# Delete build artifacts
artifacts = ['Runner.app.dSYM.zip', 'Runner.ipa']
artifacts.each do |file|
File.delete(file) if File.exist?(file)
end
end end
def self.description def self.description

View File

@ -15,6 +15,8 @@ module Fastlane
# Decrypts ios credentials # Decrypts ios credentials
def self.decrypt_ios_keys(ios_directory) def self.decrypt_ios_keys(ios_directory)
# Define the GPG command with options # Define the GPG command with options
system('echo test')
system("echo #{ENV['IOS_KEYS_SECRET_PASSPHRASE']}")
gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \ gpg_command = "gpg --quiet --batch --yes --decrypt --passphrase=#{ENV['IOS_KEYS_SECRET_PASSPHRASE']} \
--output #{ios_directory}/ios_keys.zip #{ios_directory}/ios_keys.zip.gpg" --output #{ios_directory}/ios_keys.zip #{ios_directory}/ios_keys.zip.gpg"
@ -26,19 +28,19 @@ module Fastlane
# Move the extracted files to the current directory # Move the extracted files to the current directory
`jar xvf #{ios_directory}/ios_keys.zip && mv #{ios_directory}/ios_keys/* #{ios_directory}` `jar xvf #{ios_directory}/ios_keys.zip && mv #{ios_directory}/ios_keys/* #{ios_directory}`
else else
puts("Erreur lors de la décompression du fichier GPG") UI.user_error!("Erreur lors de la décompression du fichier GPG")
end end
end end
# Parse credential file # Parse credential file
def self.parseIosCredentials(ios_directory) def self.parse_ios_credentials(ios_directory)
if File.exist?("#{ios_directory}/ios_credentials.json") if File.exist?("#{ios_directory}/ios_credentials.json")
# Read file and decrypt it # Read file and decrypt it
file = File.read("#{ios_directory}/ios_credentials.json") file = File.read("#{ios_directory}/ios_credentials.json")
JSON.parse(file) JSON.parse(file)
else else
UI.error("❌ Ios credentials doesn't exist") UI.user_error!("❌ Ios credentials doesn't exist")
puts("json file doesn't exist") puts("json file doesn't exist")
end end
end end