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)
# Check parameters
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")
end
@ -17,23 +17,23 @@ module Fastlane
Helper::AndroidCdHelper.decrypt_android_keys('.')
# 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
build_number = Fastlane::Actions.number_of_commits
build_number = other_action.number_of_commits
# Build the Android App Bundle
Actions(GradleAction.run(
other_action.gradle(
task: "bundle",
build_type: "Release",
print_command: true,
properties: {
"android.injected.version.code" => build_number
}
))
)
# Upload the Android App Bundle to the Play Store
Actions::UploadToPlayStoreAction.run(
other_action.upload_to_play_store(
track: params[:beta_type],
json_key: './service_account_key.json',
aab: '../build/app/outputs/bundle/release/app-release.aab',
@ -44,6 +44,12 @@ module Fastlane
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')
end

View File

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

View File

@ -17,7 +17,7 @@ module Fastlane
# Move the extracted files to the current directory
`jar xvf #{android_directory} && mv #{android_directory}/android_keys/* #{android_directory}`
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

View File

@ -7,8 +7,14 @@ module Fastlane
def self.run(params)
# Check parameters
unless Helper::IosCdHelper.is_set(params[:beta_type])
UI.error("❌ Parameters beta_type cannot be null")
puts("Error on beta type parameter")
raise ArgumentError, "❌ Parameters beta_type cannot be null"
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
UI.message("⌛️ Building and deploying to Store in #{params[:beta_type]}..")
@ -18,9 +24,23 @@ module Fastlane
UI.message("👉🏼 Credentials decrypted.")
# Retrieve credentials
creds = Helper::IosCdHelper.parseIosCredentials('.')
creds = Helper::IosCdHelper.parse_ios_credentials('.')
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
if File.exist?(File.expand_path("~/Library/Keychains/#{name}-db"))
other_action.delete_keychain(
@ -82,7 +102,7 @@ module Fastlane
api_key: api_key,
type: 'appstore',
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_password: creds['temp_keychain_password'].to_s,
git_url: creds['git_url'].to_s,
@ -124,6 +144,12 @@ module Fastlane
name: creds['temp_keychain_user']
)
end
# Delete build artifacts
artifacts = ['Runner.app.dSYM.zip', 'Runner.ipa']
artifacts.each do |file|
File.delete(file) if File.exist?(file)
end
end
def self.description

View File

@ -15,6 +15,8 @@ module Fastlane
# Decrypts ios credentials
def self.decrypt_ios_keys(ios_directory)
# 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']} \
--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
`jar xvf #{ios_directory}/ios_keys.zip && mv #{ios_directory}/ios_keys/* #{ios_directory}`
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
# Parse credential file
def self.parseIosCredentials(ios_directory)
def self.parse_ios_credentials(ios_directory)
if File.exist?("#{ios_directory}/ios_credentials.json")
# Read file and decrypt it
file = File.read("#{ios_directory}/ios_credentials.json")
JSON.parse(file)
else
UI.error("❌ Ios credentials doesn't exist")
UI.user_error!("❌ Ios credentials doesn't exist")
puts("json file doesn't exist")
end
end