repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/upload_app_privacy_details_to_app_store.rb | fastlane/lib/fastlane/actions/upload_app_privacy_details_to_app_store.rb | module Fastlane
module Actions
class UploadAppPrivacyDetailsToAppStoreAction < Action
DEFAULT_PATH = Fastlane::Helper.fastlane_enabled_folder_path
DEFAULT_FILE_NAME = "app_privacy_details.json"
def self.run(params)
require 'spaceship'
# Prompts select team if multiple teams and none specified
UI.message("Login to App Store Connect (#{params[:username]})")
Spaceship::ConnectAPI.login(params[:username], use_portal: false, use_tunes: true, tunes_team_id: params[:team_id], team_name: params[:team_name])
UI.message("Login successful")
# Get App
app = Spaceship::ConnectAPI::App.find(params[:app_identifier])
unless app
UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
end
# Attempt to load JSON file
usages_config = load_json_file(params)
# Start interactive questions to generate and save JSON file
unless usages_config
usages_config = ask_interactive_questions_for_json
if params[:skip_json_file_saving]
UI.message("Skipping JSON file saving...")
else
json = JSON.pretty_generate(usages_config)
path = output_path(params)
UI.message("Writing file to #{path}")
File.write(path, json)
end
end
# Process JSON file to save app data usages to API
if params[:skip_upload]
UI.message("Skipping uploading of data... (so you can verify your JSON file)")
else
upload_app_data_usages(params, app, usages_config)
end
end
def self.load_json_file(params)
path = params[:json_path]
return nil if path.nil?
return JSON.parse(File.read(path))
end
def self.output_path(params)
path = params[:output_json_path]
return File.absolute_path(path)
end
def self.ask_interactive_questions_for_json(show_intro = true)
if show_intro
UI.important("You did not provide a JSON file for updating the app data usages")
UI.important("fastlane will now run you through interactive question to generate the JSON file")
UI.important("")
UI.important("This JSON file can be saved in source control and used in this action with the :json_file option")
unless UI.confirm("Ready to start?")
UI.user_error!("Cancelled")
end
end
# Fetch categories and purposes used for generating interactive questions
categories = Spaceship::ConnectAPI::AppDataUsageCategory.all(includes: "grouping")
purposes = Spaceship::ConnectAPI::AppDataUsagePurpose.all
json = []
unless UI.confirm("Are you collecting data?")
json << {
"data_protections" => [Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_NOT_COLLECTED]
}
return json
end
categories.each do |category|
# Ask if using category
next unless UI.confirm("Collect data for #{category.id}?")
purpose_names = purposes.map(&:id).join(', ')
UI.message("How will this data be used? You'll be offered with #{purpose_names}")
# Ask purposes
selected_purposes = []
loop do
purposes.each do |purpose|
selected_purposes << purpose if UI.confirm("Used for #{purpose.id}?")
end
break unless selected_purposes.empty?
break unless UI.confirm("No purposes selected. Do you want to try again?")
end
# Skip asking protections if purposes were skipped
next if selected_purposes.empty?
# Ask protections
is_linked_to_user = UI.confirm("Is #{category.id} linked to the user?")
is_used_for_tracking = UI.confirm("Is #{category.id} used for tracking purposes?")
# Map answers to values for API requests
protection_id = is_linked_to_user ? Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_LINKED_TO_YOU : Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_NOT_LINKED_TO_YOU
tracking_id = is_used_for_tracking ? Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_USED_TO_TRACK_YOU : nil
json << {
"category" => category.id,
"purposes" => selected_purposes.map(&:id).sort.uniq,
"data_protections" => [
protection_id, tracking_id
].compact.sort.uniq
}
end
json.sort_by! { |c| c["category"] }
# Recursively call this method if no categories were selected for data collection
if json.empty?
UI.error("No categories were selected for data collection.")
json = ask_interactive_questions_for_json(false)
end
return json
end
def self.upload_app_data_usages(params, app, usages_config)
UI.message("Preparing to upload App Data Usage")
# Delete all existing usages for new ones
all_usages = Spaceship::ConnectAPI::AppDataUsage.all(app_id: app.id, includes: "category,grouping,purpose,dataProtection", limit: 500)
all_usages.each(&:delete!)
usages_config.each do |usage_config|
category = usage_config["category"]
purposes = usage_config["purposes"] || []
data_protections = usage_config["data_protections"] || []
# There will not be any purposes if "not collecting data"
# However, an AppDataUsage still needs to be created for not collecting data
# Creating an array with nil so that purposes can be iterated over and
# that AppDataUsage can be created
purposes = [nil] if purposes.empty?
purposes.each do |purpose|
data_protections.each do |data_protection|
if data_protection == Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_NOT_COLLECTED
UI.message("Setting #{data_protection}")
else
UI.message("Setting #{category} and #{purpose} to #{data_protection}")
end
Spaceship::ConnectAPI::AppDataUsage.create(
app_id: app.id,
app_data_usage_category_id: category,
app_data_usage_protection_id: data_protection,
app_data_usage_purpose_id: purpose
)
end
end
end
# Publish
if params[:skip_publish]
UI.message("Skipping app data usage publishing... (so you can verify on App Store Connect)")
else
publish_state = Spaceship::ConnectAPI::AppDataUsagesPublishState.get(app_id: app.id)
if publish_state.published
UI.important("App data usage is already published")
else
UI.important("App data usage not published! Going to publish...")
publish_state.publish!
UI.important("App data usage is now published")
end
end
end
def self.description
"Upload App Privacy Details for an app in App Store Connect"
end
def self.available_options
user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
[
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FASTLANE_USER",
description: "Your Apple ID Username for App Store Connect",
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_APP_IDENTIFIER",
description: "The bundle identifier of your app",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :team_id,
env_name: "FASTLANE_ITC_TEAM_ID",
description: "The ID of your App Store Connect team if you're in multiple teams",
optional: true,
skip_type_validation: true, # as we also allow integers, which we convert to strings anyway
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :team_name,
env_name: "FASTLANE_ITC_TEAM_NAME",
description: "The name of your App Store Connect team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name),
default_value_dynamic: true),
# JSON paths
FastlaneCore::ConfigItem.new(key: :json_path,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_JSON_PATH",
description: "Path to the app usage data JSON",
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not find JSON file at path '#{File.expand_path(value)}'") unless File.exist?(value)
UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
end),
FastlaneCore::ConfigItem.new(key: :output_json_path,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_OUTPUT_JSON_PATH",
description: "Path to the app usage data JSON file generated by interactive questions",
conflicting_options: [:skip_json_file_saving],
default_value: File.join(DEFAULT_PATH, DEFAULT_FILE_NAME)),
# Skipping options
FastlaneCore::ConfigItem.new(key: :skip_json_file_saving,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_OUTPUT_SKIP_JSON_FILE_SAVING",
description: "Whether to skip the saving of the JSON file",
conflicting_options: [:skip_output_json_path],
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_upload,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_OUTPUT_SKIP_UPLOAD",
description: "Whether to skip the upload and only create the JSON file with interactive questions",
conflicting_options: [:skip_publish],
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_publish,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_OUTPUT_SKIP_PUBLISH",
description: "Whether to skip the publishing",
conflicting_options: [:skip_upload],
type: Boolean,
default_value: false)
]
end
def self.author
"joshdholtz"
end
def self.is_supported?(platform)
[:ios, :mac, :tvos].include?(platform)
end
def self.details
"Upload App Privacy Details for an app in App Store Connect. For more detail information, view https://docs.fastlane.tools/uploading-app-privacy-details"
end
def self.example_code
[
'upload_app_privacy_details_to_app_store(
username: "your@email.com",
team_name: "Your Team",
app_identifier: "com.your.bundle"
)',
'upload_app_privacy_details_to_app_store(
username: "your@email.com",
team_name: "Your Team",
app_identifier: "com.your.bundle",
json_path: "fastlane/app_data_usages.json"
)'
]
end
def self.category
:production
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/setup_ci.rb | fastlane/lib/fastlane/actions/setup_ci.rb | module Fastlane
module Actions
class SetupCiAction < Action
def self.run(params)
unless should_run?(params)
UI.message("Not running on CI, skipping CI setup")
return
end
case detect_provider(params)
when 'circleci', 'codebuild'
setup_output_paths
end
setup_keychain(params)
end
def self.should_run?(params)
Helper.ci? || params[:force]
end
def self.detect_provider(params)
params[:provider] || (Helper.is_circle_ci? ? 'circleci' : nil) || (Helper.is_codebuild? ? 'codebuild' : nil)
end
def self.setup_keychain(params)
unless Helper.mac?
UI.message("Skipping Keychain setup on non-macOS CI Agent")
return
end
unless ENV["MATCH_KEYCHAIN_NAME"].nil?
UI.message("Skipping Keychain setup as a keychain was already specified")
return
end
keychain_name = params[:keychain_name]
ENV["MATCH_KEYCHAIN_NAME"] = keychain_name
ENV["MATCH_KEYCHAIN_PASSWORD"] = ""
UI.message("Creating temporary keychain: \"#{keychain_name}\".")
Actions::CreateKeychainAction.run(
name: keychain_name,
default_keychain: true,
unlock: true,
timeout: params[:timeout],
lock_when_sleeps: true,
password: "",
add_to_search_list: true
)
UI.message("Enabling match readonly mode.")
ENV["MATCH_READONLY"] = true.to_s
end
def self.setup_output_paths
unless ENV["FL_OUTPUT_DIR"]
UI.message("Skipping Log Path setup as FL_OUTPUT_DIR is unset")
return
end
root = Pathname.new(ENV["FL_OUTPUT_DIR"])
ENV["SCAN_OUTPUT_DIRECTORY"] = (root + "scan").to_s
ENV["GYM_OUTPUT_DIRECTORY"] = (root + "gym").to_s
ENV["FL_BUILDLOG_PATH"] = (root + "buildlogs").to_s
ENV["SCAN_INCLUDE_SIMULATOR_LOGS"] = true.to_s
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Setup the keychain and match to work with CI"
end
def self.details
list = <<-LIST.markdown_list(true)
Creates a new temporary keychain for use with match
Switches match to `readonly` mode to not create new profiles/cert on CI
Sets up log and test result paths to be easily collectible
LIST
[
list,
"This action helps with CI integration. Add this to the top of your Fastfile if you use CI."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :force,
env_name: "FL_SETUP_CI_FORCE",
description: "Force setup, even if not executed by CI",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :provider,
env_name: "FL_SETUP_CI_PROVIDER",
description: "CI provider. If none is set, the provider is detected automatically",
optional: true,
verify_block: proc do |value|
value = value.to_s
# Validate both 'travis' and 'circleci' for backwards compatibility, even
# though only the latter receives special treatment by this action
UI.user_error!("A given CI provider '#{value}' is not supported. Available CI providers: 'travis', 'circleci'") unless ["travis", "circleci"].include?(value)
end),
FastlaneCore::ConfigItem.new(key: :timeout,
env_name: "FL_SETUP_CI_TIMEOUT",
description: "Set a custom timeout in seconds for keychain. Set `0` if you want to specify 'no time-out'",
type: Integer,
default_value: 3600),
FastlaneCore::ConfigItem.new(key: :keychain_name,
env_name: "FL_SETUP_CI_KEYCHAIN_NAME",
description: "Set a custom keychain name",
type: String,
default_value: "fastlane_tmp_keychain")
]
end
def self.authors
["mollyIV", "svenmuennich"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'setup_ci(
provider: "circleci"
)',
'setup_ci(
provider: "circleci",
timeout: 0
)',
'setup_ci(
provider: "circleci",
timeout: 0,
keychain_name: "custom_keychain_name"
)'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/sync_code_signing.rb | fastlane/lib/fastlane/actions/sync_code_signing.rb | module Fastlane
module Actions
module SharedValues
MATCH_PROVISIONING_PROFILE_MAPPING = :MATCH_PROVISIONING_PROFILE_MAPPING
SIGH_PROFILE_TYPE ||= :SIGH_PROFILE_TYPE # originally defined in GetProvisioningProfileAction
end
class SyncCodeSigningAction < Action
def self.run(params)
require 'match'
params.load_configuration_file("Matchfile")
# Only set :api_key from SharedValues if :api_key_path isn't set (conflicting options)
unless params[:api_key_path]
params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
end
Match::Runner.new.run(params)
define_profile_type(params)
define_provisioning_profile_mapping(params)
end
def self.define_profile_type(params)
profile_type = "app-store"
profile_type = "ad-hoc" if params[:type] == 'adhoc'
profile_type = "development" if params[:type] == 'development'
profile_type = "enterprise" if params[:type] == 'enterprise'
UI.message("Setting Provisioning Profile type to '#{profile_type}'")
Actions.lane_context[SharedValues::SIGH_PROFILE_TYPE] = profile_type
end
# Maps the bundle identifier to the appropriate provisioning profile
# This is used in the _gym_ action as part of the export options
# e.g.
#
# export_options: {
# provisioningProfiles: { "me.themoji.app.beta": "match AppStore me.themoji.app.beta" }
# }
#
def self.define_provisioning_profile_mapping(params)
mapping = Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING] || {}
# Array (...) to make sure it's an Array, Ruby is magic, try this
# Array(1) # => [1]
# Array([1, 2]) # => [1, 2]
Array(params[:app_identifier]).each do |app_identifier|
env_variable_name = Match::Utils.environment_variable_name_profile_name(app_identifier: app_identifier,
type: Match.profile_type_sym(params[:type]),
platform: params[:platform])
if params[:derive_catalyst_app_identifier]
app_identifier = "maccatalyst.#{app_identifier}"
end
mapping[app_identifier] = ENV[env_variable_name]
end
Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING] = mapping
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Easily sync your certificates and profiles across your team (via _match_)"
end
def self.details
"More information: https://docs.fastlane.tools/actions/match/"
end
def self.available_options
require 'match'
Match::Options.available_options
end
def self.output
[
['MATCH_PROVISIONING_PROFILE_MAPPING', 'The match provisioning profile mapping'],
['SIGH_PROFILE_TYPE', 'The profile type, can be app-store, ad-hoc, development, enterprise, can be used in `build_app` as a default value for `export_method`']
]
end
def self.return_value
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'sync_code_signing(type: "appstore", app_identifier: "tools.fastlane.app")',
'sync_code_signing(type: "development", readonly: true)',
'sync_code_signing(app_identifier: ["tools.fastlane.app", "tools.fastlane.sleepy"])',
'match # alias for "sync_code_signing"'
]
end
def self.category
:code_signing
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/erb.rb | fastlane/lib/fastlane/actions/erb.rb | module Fastlane
module Actions
class ErbAction < Action
def self.run(params)
template = File.read(params[:template])
trim_mode = params[:trim_mode]
result = Fastlane::ErbTemplateHelper.render(template, params[:placeholders], trim_mode)
File.open(params[:destination], 'w') { |file| file.write(result) } if params[:destination]
UI.message("Successfully parsed template: '#{params[:template]}' and rendered output to: #{params[:destination]}") if params[:destination]
result
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Allows to Generate output files based on ERB templates"
end
def self.details
[
"Renders an ERB template with `:placeholders` given as a hash via parameter.",
"If no `:destination` is set, it returns the rendered template as string."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :template,
short_option: "-T",
env_name: "FL_ERB_SRC",
description: "ERB Template File",
optional: false),
FastlaneCore::ConfigItem.new(key: :destination,
short_option: "-D",
env_name: "FL_ERB_DST",
description: "Destination file",
optional: true),
FastlaneCore::ConfigItem.new(key: :placeholders,
short_option: "-p",
env_name: "FL_ERB_PLACEHOLDERS",
description: "Placeholders given as a hash",
default_value: {},
type: Hash),
FastlaneCore::ConfigItem.new(key: :trim_mode,
short_option: "-t",
env_name: "FL_ERB_TRIM_MODE",
description: "Trim mode applied to the ERB",
optional: true)
]
end
def self.authors
["hjanuschka"]
end
def self.example_code
[
'# Example `erb` template:
# Variable1 <%= var1 %>
# Variable2 <%= var2 %>
# <% for item in var3 %>
# <%= item %>
# <% end %>
erb(
template: "1.erb",
destination: "/tmp/rendered.out",
placeholders: {
:var1 => 123,
:var2 => "string",
:var3 => ["element1", "element2"]
}
)'
]
end
def self.category
:misc
end
def self.is_supported?(platform)
true
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/actions_helper.rb | fastlane/lib/fastlane/actions/actions_helper.rb | module Fastlane
module Actions
module SharedValues
LANE_NAME = :LANE_NAME
PLATFORM_NAME = :PLATFORM_NAME
ENVIRONMENT = :ENVIRONMENT
# A slightly decorated hash that will store and fetch sensitive data
# but not display it while iterating keys and values
class LaneContextValues < Hash
def initialize
@sensitive_context = {}
end
def set_sensitive(key, value)
@sensitive_context[key] = value
end
def [](key)
if @sensitive_context.key?(key)
return @sensitive_context[key]
end
super
end
end
end
def self.reset_aliases
@alias_actions = nil
end
def self.alias_actions
unless @alias_actions
@alias_actions = {}
ActionsList.all_actions do |action, name|
next unless action.respond_to?(:aliases)
@alias_actions[name] = action.aliases
end
end
@alias_actions
end
def self.executed_actions
@executed_actions ||= []
end
# The shared hash can be accessed by any action and contains information like the screenshots path or beta URL
def self.lane_context
@lane_context ||= SharedValues::LaneContextValues.new
end
# Used in tests to get a clear lane before every test
def self.clear_lane_context
@lane_context = nil
end
# Pass a block which should be tracked. One block = one testcase
# @param step_name (String) the name of the currently built code (e.g. snapshot, sigh, ...)
# This might be nil, in which case the step is not printed out to the terminal
def self.execute_action(step_name)
start = Time.now # before the raise block, since `start` is required in the ensure block
UI.crash!("No block given") unless block_given?
error = nil
exc = nil
begin
UI.header("Step: " + step_name) if step_name
yield
rescue => ex
exc = ex
error = caller.join("\n") + "\n\n" + ex.to_s
end
ensure
# This is also called, when the block has a return statement
if step_name
duration = Time.now - start
executed_actions << {
name: step_name,
error: error,
time: duration
}
end
raise exc if exc
end
# returns a list of official integrations
# rubocop:disable Naming/AccessorMethodName
def self.get_all_official_actions
Dir[File.expand_path('*.rb', File.dirname(__FILE__))].collect do |file|
File.basename(file).gsub('.rb', '').to_sym
end
end
# rubocop:enable Naming/AccessorMethodName
# Returns the class ref to the action based on the action name
# Returns nil if the action is not available
def self.action_class_ref(action_name)
class_name = action_name.to_s.fastlane_class + 'Action'
class_ref = nil
begin
class_ref = Fastlane::Actions.const_get(class_name)
rescue NameError
return nil
end
return class_ref
end
def self.load_default_actions
Dir[File.expand_path('*.rb', File.dirname(__FILE__))].each do |file|
require file
end
end
# Import all the helpers
def self.load_helpers
Dir[File.expand_path('../helper/*.rb', File.dirname(__FILE__))].each do |file|
require file
end
end
def self.load_external_actions(path)
UI.user_error!("You need to pass a valid path") unless File.exist?(path)
class_refs = []
Dir[File.expand_path('*.rb', path)].each do |file|
begin
require file
rescue SyntaxError => ex
content = File.read(file, encoding: "utf-8")
ex.to_s.lines
.collect { |error| error.match(/#{file}:(\d+):(.*)/) }
.reject(&:nil?)
.each { |error| UI.content_error(content, error[1]) }
UI.user_error!("Syntax error in #{File.basename(file)}")
next
end
file_name = File.basename(file).gsub('.rb', '')
class_name = file_name.fastlane_class + 'Action'
begin
class_ref = Fastlane::Actions.const_get(class_name)
class_refs << class_ref
if class_ref.respond_to?(:run)
UI.success("Successfully loaded custom action '#{file}'.") if FastlaneCore::Globals.verbose?
else
UI.error("Could not find method 'run' in class #{class_name}.")
UI.error('For more information, check out the docs: https://docs.fastlane.tools/')
UI.user_error!("Action '#{file_name}' is damaged!", show_github_issues: true)
end
rescue NameError
# Action not found
UI.error("Could not find '#{class_name}' class defined.")
UI.error('For more information, check out the docs: https://docs.fastlane.tools/')
UI.user_error!("Action '#{file_name}' is damaged!", show_github_issues: true)
end
end
Actions.reset_aliases
return class_refs
end
def self.formerly_bundled_actions
["xcake"]
end
# Returns a boolean indicating whether the class
# reference is a Fastlane::Action
def self.is_class_action?(class_ref)
return false if class_ref.nil?
is_an_action = class_ref < Fastlane::Action
return is_an_action || false
end
# Returns a boolean indicating if the class
# reference is a deprecated Fastlane::Action
def self.is_deprecated?(class_ref)
is_class_action?(class_ref) && class_ref.category == :deprecated
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/validate_play_store_json_key.rb | fastlane/lib/fastlane/actions/validate_play_store_json_key.rb | require 'supply/client'
module Fastlane
module Actions
class ValidatePlayStoreJsonKeyAction < Action
def self.run(params)
FastlaneCore::PrintTable.print_values(
config: params,
mask_keys: [:json_key_data],
title: "Summary for validate_play_store_json_key"
)
begin
client = Supply::Client.make_from_config(params: params)
FastlaneCore::UI.success("Successfully established connection to Google Play Store.")
FastlaneCore::UI.verbose("client: " + client.inspect)
rescue => e
UI.error("Could not establish a connection to Google Play Store with this json key file.")
UI.error("#{e.message}\n#{e.backtrace.join("\n")}") if FastlaneCore::Globals.verbose?
end
end
def self.description
"Validate that the Google Play Store `json_key` works"
end
def self.authors
["janpio"]
end
def self.details
"Use this action to test and validate your private key json key file used to connect and authenticate with the Google Play API"
end
def self.example_code
[
"validate_play_store_json_key(
json_key: 'path/to/you/json/key/file'
)"
]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :json_key,
env_name: "SUPPLY_JSON_KEY",
short_option: "-j",
conflicting_options: [:json_key_data],
optional: true,
description: "The path to a file containing service account JSON, used to authenticate with Google",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
end),
FastlaneCore::ConfigItem.new(key: :json_key_data,
env_name: "SUPPLY_JSON_KEY_DATA",
short_option: "-c",
conflicting_options: [:json_key],
optional: true,
description: "The raw service account JSON data used to authenticate with Google",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
default_value_dynamic: true,
verify_block: proc do |value|
begin
JSON.parse(value)
rescue JSON::ParserError
UI.user_error!("Could not parse service account json: JSON::ParseError")
end
end),
# stuff
FastlaneCore::ConfigItem.new(key: :root_url,
env_name: "SUPPLY_ROOT_URL",
description: "Root URL for the Google Play API. The provided URL will be used for API calls in place of https://www.googleapis.com/",
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not parse URL '#{value}'") unless value =~ URI.regexp
end),
FastlaneCore::ConfigItem.new(key: :timeout,
env_name: "SUPPLY_TIMEOUT",
optional: true,
description: "Timeout for read, open, and send (in seconds)",
type: Integer,
default_value: 300)
]
end
def self.is_supported?(platform)
[:android].include?(platform)
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/pilot.rb | fastlane/lib/fastlane/actions/pilot.rb | module Fastlane
module Actions
require 'fastlane/actions/upload_to_testflight'
class PilotAction < UploadToTestflightAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `upload_to_testflight` action"
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/create_pull_request.rb | fastlane/lib/fastlane/actions/create_pull_request.rb | module Fastlane
module Actions
module SharedValues
CREATE_PULL_REQUEST_HTML_URL = :CREATE_PULL_REQUEST_HTML_URL
CREATE_PULL_REQUEST_NUMBER = :CREATE_PULL_REQUEST_NUMBER
end
class CreatePullRequestAction < Action
def self.run(params)
UI.message("Creating new pull request from '#{params[:head]}' to branch '#{params[:base]}' of '#{params[:repo]}'")
payload = {
'title' => params[:title],
'head' => params[:head],
'base' => params[:base]
}
payload['body'] = params[:body] if params[:body]
payload['draft'] = params[:draft] if params[:draft]
GithubApiAction.run(
server_url: params[:api_url],
api_token: params[:api_token],
api_bearer: params[:api_bearer],
http_method: 'POST',
path: "repos/#{params[:repo]}/pulls",
body: payload,
error_handlers: {
'*' => proc do |result|
UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
return nil
end
}
) do |result|
json = result[:json]
number = json['number']
html_url = json['html_url']
UI.success("Successfully created pull request ##{number}. You can see it at '#{html_url}'")
# Add labels to pull request
add_labels(params, number) if params[:labels]
# Add assignees to pull request
add_assignees(params, number) if params[:assignees]
# Add reviewers to pull request
add_reviewers(params, number) if params[:reviewers] || params[:team_reviewers]
# Add a milestone to pull request
add_milestone(params, number) if params[:milestone]
Actions.lane_context[SharedValues::CREATE_PULL_REQUEST_HTML_URL] = html_url
Actions.lane_context[SharedValues::CREATE_PULL_REQUEST_NUMBER] = number
return html_url
end
end
def self.add_labels(params, number)
payload = {
'labels' => params[:labels]
}
GithubApiAction.run(
server_url: params[:api_url],
api_token: params[:api_token],
api_bearer: params[:api_bearer],
http_method: 'PATCH',
path: "repos/#{params[:repo]}/issues/#{number}",
body: payload,
error_handlers: {
'*' => proc do |result|
UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
return nil
end
}
)
end
def self.add_assignees(params, number)
payload = {
'assignees' => params[:assignees]
}
GithubApiAction.run(
server_url: params[:api_url],
api_token: params[:api_token],
api_bearer: params[:api_bearer],
http_method: 'POST',
path: "repos/#{params[:repo]}/issues/#{number}/assignees",
body: payload,
error_handlers: {
'*' => proc do |result|
UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
return nil
end
}
)
end
def self.add_reviewers(params, number)
payload = {}
if params[:reviewers]
payload["reviewers"] = params[:reviewers]
end
if params[:team_reviewers]
payload["team_reviewers"] = params[:team_reviewers]
end
GithubApiAction.run(
server_url: params[:api_url],
api_token: params[:api_token],
api_bearer: params[:api_bearer],
http_method: 'POST',
path: "repos/#{params[:repo]}/pulls/#{number}/requested_reviewers",
body: payload,
error_handlers: {
'*' => proc do |result|
UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
return nil
end
}
)
end
def self.add_milestone(params, number)
payload = {}
if params[:milestone]
payload["milestone"] = params[:milestone]
end
GithubApiAction.run(
server_url: params[:api_url],
api_token: params[:api_token],
api_bearer: params[:api_bearer],
http_method: 'PATCH',
path: "repos/#{params[:repo]}/issues/#{number}",
body: payload,
error_handlers: {
'*' => proc do |result|
UI.error("GitHub responded with #{result[:status]}: #{result[:body]}")
return nil
end
}
)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"This will create a new pull request on GitHub"
end
def self.output
[
['CREATE_PULL_REQUEST_HTML_URL', 'The HTML URL to the created pull request'],
['CREATE_PULL_REQUEST_NUMBER', 'The identifier number of the created pull request']
]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :api_token,
env_name: "GITHUB_PULL_REQUEST_API_TOKEN",
description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens",
sensitive: true,
code_gen_sensitive: true,
default_value: ENV["GITHUB_API_TOKEN"],
default_value_dynamic: true,
conflicting_options: [:api_bearer],
optional: true),
FastlaneCore::ConfigItem.new(key: :api_bearer,
env_name: "GITHUB_PULL_REQUEST_API_BEARER",
description: "Use a Bearer authorization token. Usually generated by GitHub Apps, e.g. GitHub Actions GITHUB_TOKEN environment variable",
sensitive: true,
code_gen_sensitive: true,
conflicting_options: [:api_token],
optional: true,
default_value: nil),
FastlaneCore::ConfigItem.new(key: :repo,
env_name: "GITHUB_PULL_REQUEST_REPO",
description: "The name of the repository you want to submit the pull request to",
optional: false),
FastlaneCore::ConfigItem.new(key: :title,
env_name: "GITHUB_PULL_REQUEST_TITLE",
description: "The title of the pull request",
optional: false),
FastlaneCore::ConfigItem.new(key: :body,
env_name: "GITHUB_PULL_REQUEST_BODY",
description: "The contents of the pull request",
optional: true),
FastlaneCore::ConfigItem.new(key: :draft,
env_name: "GITHUB_PULL_REQUEST_DRAFT",
description: "Indicates whether the pull request is a draft",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :labels,
env_name: "GITHUB_PULL_REQUEST_LABELS",
description: "The labels for the pull request",
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :milestone,
env_name: "GITHUB_PULL_REQUEST_MILESTONE",
description: "The milestone ID (Integer) for the pull request",
type: Numeric,
optional: true),
FastlaneCore::ConfigItem.new(key: :head,
env_name: "GITHUB_PULL_REQUEST_HEAD",
description: "The name of the branch where your changes are implemented (defaults to the current branch name)",
default_value: Actions.git_branch,
default_value_dynamic: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :base,
env_name: "GITHUB_PULL_REQUEST_BASE",
description: "The name of the branch you want your changes pulled into (defaults to `master`)",
default_value: 'master',
optional: true),
FastlaneCore::ConfigItem.new(key: :api_url,
env_name: "GITHUB_PULL_REQUEST_API_URL",
description: "The URL of GitHub API - used when the Enterprise (default to `https://api.github.com`)",
code_gen_default_value: 'https://api.github.com',
default_value: 'https://api.github.com',
optional: true),
FastlaneCore::ConfigItem.new(key: :assignees,
env_name: "GITHUB_PULL_REQUEST_ASSIGNEES",
description: "The assignees for the pull request",
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :reviewers,
env_name: "GITHUB_PULL_REQUEST_REVIEWERS",
description: "The reviewers (slug) for the pull request",
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :team_reviewers,
env_name: "GITHUB_PULL_REQUEST_TEAM_REVIEWERS",
description: "The team reviewers (slug) for the pull request",
type: Array,
optional: true)
]
end
def self.author
["seei", "tommeier", "marumemomo", "elneruda", "kagemiku"]
end
def self.is_supported?(platform)
return true
end
def self.return_value
"The pull request URL when successful"
end
def self.example_code
[
'create_pull_request(
api_token: "secret", # optional, defaults to ENV["GITHUB_API_TOKEN"]
repo: "fastlane/fastlane",
title: "Amazing new feature",
head: "my-feature", # optional, defaults to current branch name
base: "master", # optional, defaults to "master"
body: "Please pull this in!", # optional
api_url: "http://yourdomain/api/v3" # optional, for GitHub Enterprise, defaults to "https://api.github.com"
)'
]
end
def self.category
:source_control
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/download_dsyms.rb | fastlane/lib/fastlane/actions/download_dsyms.rb | module Fastlane
module Actions
module SharedValues
DSYM_PATHS = :DSYM_PATHS
DSYM_LATEST_UPLOADED_DATE = :DSYM_LATEST_UPLOADED_DATE
end
class DownloadDsymsAction < Action
# rubocop:disable Metrics/PerceivedComplexity
def self.run(params)
require 'openssl'
require 'spaceship'
require 'net/http'
require 'date'
if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path]))
UI.message("Creating authorization token for App Store Connect API")
Spaceship::ConnectAPI.token = api_token
elsif !Spaceship::ConnectAPI.token.nil?
UI.message("Using existing authorization token for App Store Connect API")
else
# Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
# Prompts select team if multiple teams and none specified
UI.message("Login to App Store Connect (#{params[:username]})")
Spaceship::ConnectAPI.login(params[:username], use_portal: false, use_tunes: true)
UI.message("Login successful")
end
# Get App
app = Spaceship::ConnectAPI::App.find(params[:app_identifier])
unless app
UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
end
# Process options
version = params[:version]
build_number = params[:build_number].to_s unless params[:build_number].nil?
itc_platform = params[:platform]
output_directory = params[:output_directory]
wait_for_dsym_processing = params[:wait_for_dsym_processing]
wait_timeout = params[:wait_timeout]
min_version = Gem::Version.new(params[:min_version]) if params[:min_version]
after_uploaded_date = DateTime.parse(params[:after_uploaded_date]) unless params[:after_uploaded_date].nil?
platform = Spaceship::ConnectAPI::Platform.map(itc_platform)
# Set version if it is latest
if version == 'latest'
# Try to grab the edit version first, else fallback to live version
UI.message("Looking for latest build...")
latest_build = get_latest_build!(app_id: app.id, platform: platform)
version = latest_build.app_version
build_number = latest_build.version
elsif version == 'live'
UI.message("Looking for live version...")
live_version = app.get_live_app_store_version(platform: platform)
UI.user_error!("Could not find live version for your app, please try setting 'latest' or a specific version") if live_version.nil?
# No need to search for candidates, because released App Store version should only have one build
version = live_version.version_string
build_number = live_version.build.version
end
# Make sure output_directory has a slash on the end
if output_directory && !output_directory.end_with?('/')
output_directory += '/'
end
# Write a nice message
message = []
message << "Looking for dSYM files for '#{params[:app_identifier]}' on platform #{platform}"
message << "v#{version}" if version
message << "(#{build_number})" if build_number
UI.message(message.join(" "))
filter = { app: app.id }
filter["preReleaseVersion.platform"] = platform
filter["preReleaseVersion.version"] = version if version
filter["version"] = build_number if build_number
build_resp = Spaceship::ConnectAPI.get_builds(filter: filter, sort: "-uploadedDate", includes: "preReleaseVersion,buildBundles")
build_resp.all_pages_each do |build|
asc_app_version = build.app_version
asc_build_number = build.version
uploaded_date = DateTime.parse(build.uploaded_date)
message = []
message << "Found train (version): #{asc_app_version}"
message << ", comparing to supplied version: #{version}" if version
UI.verbose(message.join(" "))
if version && version != asc_app_version
UI.verbose("Version #{version} doesn't match: #{asc_app_version}")
next
end
if min_version && min_version > Gem::Version.new(asc_app_version)
UI.verbose("Min version #{min_version} not reached: #{asc_app_version}")
next
end
if after_uploaded_date && after_uploaded_date >= uploaded_date
UI.verbose("Upload date #{after_uploaded_date} not reached: #{uploaded_date}")
break
end
message = []
message << "Found build version: #{asc_build_number}"
message << ", comparing to supplied build_number: #{build_number}" if build_number
UI.verbose(message.join(" "))
if build_number && asc_build_number != build_number
UI.verbose("build_version: #{asc_build_number} doesn't match: #{build_number}")
next
end
UI.verbose("Build_version: #{asc_build_number} matches #{build_number}, grabbing dsym_url") if build_number
download_dsym(build: build, app: app, wait_for_dsym_processing: wait_for_dsym_processing, wait_timeout: wait_timeout, output_directory: output_directory)
end
end
def self.download_dsym(build: nil, app: nil, wait_for_dsym_processing: nil, wait_timeout: nil, output_directory: nil)
start = Time.now
dsym_urls = []
loop do
build_bundles = build.build_bundles.select { |b| b.includes_symbols == true }
dsym_urls = build_bundles.map(&:dsym_url).compact
break if build_bundles.count == dsym_urls.count
if !wait_for_dsym_processing || (Time.now - start) > wait_timeout
# In some cases, AppStoreConnect does not process the dSYMs, thus no error should be thrown.
UI.message("Could not find any dSYM for #{build.version} (#{build.app_version})")
break
else
UI.message("Waiting for dSYM file to appear...")
sleep(30) unless FastlaneCore::Helper.is_test?
build = Spaceship::ConnectAPI::Build.get(build_id: build.id)
end
end
if dsym_urls.count == 0
UI.message("No dSYM URL for #{build.version} (#{build.app_version})")
else
dsym_urls.each do |url|
self.download(url, build, app, output_directory)
end
end
end
# rubocop:enable Metrics/PerceivedComplexity
def self.get_latest_build!(app_id: nil, platform: nil)
filter = { app: app_id }
filter["preReleaseVersion.platform"] = platform
latest_build = Spaceship::ConnectAPI.get_builds(filter: filter, sort: "-uploadedDate", includes: "preReleaseVersion,buildBundles").first
if latest_build.nil?
UI.user_error!("Could not find any build for platform #{platform}") if platform
UI.user_error!("Could not find any build")
end
return latest_build
end
def self.download(download_url, build, app, output_directory)
result = self.download_file(download_url)
path = write_dsym(result, app.bundle_id, build.app_version, build.version, output_directory)
UI.success("🔑 Successfully downloaded dSYM file for #{build.app_version} - #{build.version} to '#{path}'")
Actions.lane_context[SharedValues::DSYM_PATHS] ||= []
Actions.lane_context[SharedValues::DSYM_PATHS] << File.expand_path(path)
unless build.uploaded_date.nil?
Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE] ||= build.uploaded_date
current_latest = Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE]
Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE] = [current_latest, build.uploaded_date].max
UI.verbose("Most recent build uploaded_date #{Actions.lane_context[SharedValues::DSYM_LATEST_UPLOADED_DATE]}")
end
end
def self.write_dsym(data, bundle_id, train_number, build_number, output_directory)
file_name = "#{bundle_id}-#{train_number}-#{build_number}.dSYM.zip"
if output_directory
file_name = output_directory + file_name
end
File.binwrite(file_name, data)
file_name
end
def self.download_file(url)
uri = URI.parse(url)
if ENV['http_proxy']
UI.verbose("Found 'http_proxy' environment variable so connect via proxy")
proxy_uri = URI.parse(ENV['http_proxy'])
http = Net::HTTP.new(uri.host, uri.port, proxy_uri.host, proxy_uri.port)
else
http = Net::HTTP.new(uri.host, uri.port)
end
http.read_timeout = 300
http.use_ssl = (uri.scheme == "https")
res = http.get(uri.request_uri)
res.body
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Download dSYM files from App Store Connect for Bitcode apps"
end
def self.details
sample = <<-SAMPLE.markdown_sample
```ruby
lane :refresh_dsyms do
download_dsyms # Download dSYM files from iTC
upload_symbols_to_crashlytics # Upload them to Crashlytics
clean_build_artifacts # Delete the local dSYM files
end
```
SAMPLE
[
"This action downloads dSYM files from App Store Connect after the ipa gets re-compiled by Apple. Useful if you have Bitcode enabled.".markdown_preserve_newlines,
sample
].join("\n")
end
def self.available_options
user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
[
FastlaneCore::ConfigItem.new(key: :api_key_path,
env_names: ["DOWNLOAD_DSYMS_API_KEY_PATH", "APP_STORE_CONNECT_API_KEY_PATH"],
description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
optional: true,
conflicting_options: [:api_key],
verify_block: proc do |value|
UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_names: ["DOWNLOAD_DSYMS_API_KEY", "APP_STORE_CONNECT_API_KEY"],
description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#use-return-value-and-pass-in-as-an-option)",
type: Hash,
default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
default_value_dynamic: true,
optional: true,
sensitive: true,
conflicting_options: [:api_key_path]),
FastlaneCore::ConfigItem.new(key: :username,
short_option: "-u",
env_name: "DOWNLOAD_DSYMS_USERNAME",
description: "Your Apple ID Username for App Store Connect",
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
env_name: "DOWNLOAD_DSYMS_APP_IDENTIFIER",
description: "The bundle identifier of your app",
optional: false,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :team_id,
short_option: "-k",
env_name: "DOWNLOAD_DSYMS_TEAM_ID",
description: "The ID of your App Store Connect team if you're in multiple teams",
optional: true,
skip_type_validation: true, # as we also allow integers, which we convert to strings anyway
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :team_name,
short_option: "-e",
env_name: "DOWNLOAD_DSYMS_TEAM_NAME",
description: "The name of your App Store Connect team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_ITC_TEAM_NAME"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :platform,
short_option: "-p",
env_name: "DOWNLOAD_DSYMS_PLATFORM",
description: "The app platform for dSYMs you wish to download (ios, xros, appletvos)",
default_value: :ios),
FastlaneCore::ConfigItem.new(key: :version,
short_option: "-v",
env_name: "DOWNLOAD_DSYMS_VERSION",
description: "The app version for dSYMs you wish to download, pass in 'latest' to download only the latest build's dSYMs or 'live' to download only the live version dSYMs",
optional: true),
FastlaneCore::ConfigItem.new(key: :build_number,
short_option: "-b",
env_name: "DOWNLOAD_DSYMS_BUILD_NUMBER",
description: "The app build_number for dSYMs you wish to download",
optional: true,
skip_type_validation: true), # as we also allow integers, which we convert to strings anyway
FastlaneCore::ConfigItem.new(key: :min_version,
short_option: "-m",
env_name: "DOWNLOAD_DSYMS_MIN_VERSION",
description: "The minimum app version for dSYMs you wish to download",
optional: true),
FastlaneCore::ConfigItem.new(key: :after_uploaded_date,
short_option: "-d",
env_name: "DOWNLOAD_DSYMS_AFTER_UPLOADED_DATE",
description: "The uploaded date after which you wish to download dSYMs",
optional: true),
FastlaneCore::ConfigItem.new(key: :output_directory,
short_option: "-s",
env_name: "DOWNLOAD_DSYMS_OUTPUT_DIRECTORY",
description: "Where to save the download dSYMs, defaults to the current path",
optional: true),
FastlaneCore::ConfigItem.new(key: :wait_for_dsym_processing,
short_option: "-w",
env_name: "DOWNLOAD_DSYMS_WAIT_FOR_DSYM_PROCESSING",
description: "Wait for dSYMs to process",
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :wait_timeout,
short_option: "-t",
env_name: "DOWNLOAD_DSYMS_WAIT_TIMEOUT",
description: "Number of seconds to wait for dSYMs to process",
optional: true,
default_value: 300,
type: Integer)
]
end
def self.output
[
['DSYM_PATHS', 'An array to all the zipped dSYM files'],
['DSYM_LATEST_UPLOADED_DATE', 'Date of the most recent uploaded time of successfully downloaded dSYM files']
]
end
def self.return_value
nil
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :appletvos, :xros].include?(platform)
end
def self.example_code
[
'download_dsyms',
'download_dsyms(version: "1.0.0", build_number: "345")',
'download_dsyms(version: "1.0.1", build_number: 42)',
'download_dsyms(version: "live")',
'download_dsyms(min_version: "1.2.3")',
'download_dsyms(after_uploaded_date: "2020-09-11T19:00:00+01:00")'
]
end
def self.category
:app_store_connect
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/ruby_version.rb | fastlane/lib/fastlane/actions/ruby_version.rb | module Fastlane
module Actions
module SharedValues
end
class RubyVersionAction < Action
def self.run(params)
params = nil unless params.kind_of?(Array)
value = (params || []).first
defined_version = Gem::Version.new(value) if value
UI.user_error!("Please pass minimum ruby version as parameter to ruby_version") unless defined_version
if Gem::Version.new(RUBY_VERSION) < defined_version
error_message = "The Fastfile requires a ruby version of >= #{defined_version}. You are on #{RUBY_VERSION}."
UI.user_error!(error_message)
end
UI.message("Your ruby version #{RUBY_VERSION} matches the minimum requirement of #{defined_version} ✅")
end
def self.step_text
"Verifying Ruby version"
end
def self.author
"sebastianvarela"
end
def self.description
"Verifies the minimum ruby version required"
end
def self.example_code
[
'ruby_version("2.4.0")'
]
end
def self.details
[
"Add this to your `Fastfile` to require a certain version of _ruby_.",
"Put it at the top of your `Fastfile` to ensure that _fastlane_ is executed appropriately."
].join("\n")
end
def self.category
:misc
end
def self.is_supported?(platform)
true
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/import.rb | fastlane/lib/fastlane/actions/import.rb | module Fastlane
module Actions
class ImportAction < Action
def self.run(params)
# this is implemented in the fast_file.rb
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Import another Fastfile to use its lanes"
end
def self.details
[
"This is useful if you have shared lanes across multiple apps and you want to store a Fastfile in a separate folder.",
"The path must be relative to the Fastfile this is called from."
].join("\n")
end
def self.available_options
end
def self.output
[]
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'import("./path/to/other/Fastfile")'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/build_android_app.rb | fastlane/lib/fastlane/actions/build_android_app.rb | module Fastlane
module Actions
require 'fastlane/actions/gradle'
class BuildAndroidAppAction < GradleAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `gradle` action"
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/register_device.rb | fastlane/lib/fastlane/actions/register_device.rb | require 'credentials_manager'
module Fastlane
module Actions
class RegisterDeviceAction < Action
def self.is_supported?(platform)
platform == :ios
end
def self.run(params)
require 'spaceship'
name = params[:name]
platform = params[:platform]
udid = params[:udid]
platform = Spaceship::ConnectAPI::BundleIdPlatform.map(platform)
if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path]))
UI.message("Creating authorization token for App Store Connect API")
Spaceship::ConnectAPI.token = api_token
elsif !Spaceship::ConnectAPI.token.nil?
UI.message("Using existing authorization token for App Store Connect API")
else
UI.message("Login to App Store Connect (#{params[:username]})")
credentials = CredentialsManager::AccountManager.new(user: params[:username])
Spaceship::ConnectAPI.login(credentials.user, credentials.password, use_portal: true, use_tunes: false)
UI.message("Login successful")
end
begin
Spaceship::ConnectAPI::Device.find_or_create(udid, name: name, platform: platform)
rescue => ex
UI.error(ex.to_s)
UI.crash!("Failed to register new device (name: #{name}, platform: #{platform}, UDID: #{udid})")
end
UI.success("Successfully registered new device")
return udid
end
def self.description
"Registers a new device to the Apple Dev Portal"
end
def self.available_options
user = CredentialsManager::AppfileConfig.try_fetch_value(:apple_dev_portal_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME].to_s
[
FastlaneCore::ConfigItem.new(key: :name,
env_name: "FL_REGISTER_DEVICE_NAME",
description: "Provide the name of the device to register as"),
FastlaneCore::ConfigItem.new(key: :platform,
env_name: "FL_REGISTER_DEVICE_PLATFORM",
description: "Provide the platform of the device to register as (ios, mac)",
optional: true,
default_value: platform.empty? ? "ios" : platform,
verify_block: proc do |value|
UI.user_error!("The platform can only be ios or mac") unless %w(ios mac).include?(value)
end),
FastlaneCore::ConfigItem.new(key: :udid,
env_name: "FL_REGISTER_DEVICE_UDID",
description: "Provide the UDID of the device to register as"),
FastlaneCore::ConfigItem.new(key: :api_key_path,
env_names: ["FL_REGISTER_DEVICE_API_KEY_PATH", "APP_STORE_CONNECT_API_KEY_PATH"],
description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
optional: true,
conflicting_options: [:api_key],
verify_block: proc do |value|
UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_names: ["FL_REGISTER_DEVICE_API_KEY", "APP_STORE_CONNECT_API_KEY"],
description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)",
type: Hash,
default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
default_value_dynamic: true,
optional: true,
sensitive: true,
conflicting_options: [:api_key_path]),
FastlaneCore::ConfigItem.new(key: :team_id,
env_name: "REGISTER_DEVICE_TEAM_ID",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
default_value_dynamic: true,
description: "The ID of your Developer Portal team if you're in multiple teams",
optional: true,
verify_block: proc do |value|
ENV["FASTLANE_TEAM_ID"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :team_name,
env_name: "REGISTER_DEVICE_TEAM_NAME",
description: "The name of your Developer Portal team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_name),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_TEAM_NAME"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "DELIVER_USER",
description: "Optional: Your Apple ID",
optional: true,
default_value: user,
default_value_dynamic: true)
]
end
def self.details
[
"This will register an iOS device with the Developer Portal so that you can include it in your provisioning profiles.",
"This is an optimistic action, in that it will only ever add a device to the member center. If the device has already been registered within the member center, it will be left alone in the member center.",
"The action will connect to the Apple Developer Portal using the username you specified in your `Appfile` with `apple_id`, but you can override it using the `:username` option."
].join("\n")
end
def self.author
"pvinis"
end
def self.example_code
[
'register_device(
name: "Luka iPhone 6",
udid: "1234567890123456789012345678901234567890"
) # Simply provide the name and udid of the device',
'register_device(
name: "Luka iPhone 6",
udid: "1234567890123456789012345678901234567890",
team_id: "XXXXXXXXXX", # Optional, if you"re a member of multiple teams, then you need to pass the team ID here.
username: "luka@goonbee.com" # Optional, lets you override the Apple Member Center username.
)'
]
end
def self.return_type
:string
end
def self.category
:code_signing
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/cloc.rb | fastlane/lib/fastlane/actions/cloc.rb | module Fastlane
module Actions
class ClocAction < Action
def self.run(params)
cloc_binary = params[:binary_path]
exclude_dirs = params[:exclude_dir].nil? ? '' : "--exclude-dir=#{params[:exclude_dir]}"
xml_format = params[:xml]
out_dir = params[:output_directory]
output_file = xml_format ? "#{out_dir}/cloc.xml" : "#{out_dir}/cloc.txt"
source_directory = params[:source_directory]
command = [
cloc_binary,
exclude_dirs,
'--by-file',
xml_format ? '--xml ' : '',
"--out=#{output_file}",
source_directory
].join(' ').strip
Actions.sh(command)
end
def self.description
"Generates a Code Count that can be read by Jenkins (xml format)"
end
def self.details
[
"This action will run cloc to generate a SLOC report that the Jenkins SLOCCount plugin can read.",
"See [https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin](https://wiki.jenkins-ci.org/display/JENKINS/SLOCCount+Plugin) and [https://github.com/AlDanial/cloc](https://github.com/AlDanial/cloc) for more information."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :binary_path,
env_name: "FL_CLOC_BINARY_PATH",
description: "Where the cloc binary lives on your system (full path including 'cloc')",
optional: true,
default_value: '/usr/local/bin/cloc'),
FastlaneCore::ConfigItem.new(key: :exclude_dir,
env_name: "FL_CLOC_EXCLUDE_DIR",
description: "Comma separated list of directories to exclude",
optional: true),
FastlaneCore::ConfigItem.new(key: :output_directory,
env_name: "FL_CLOC_OUTPUT_DIRECTORY",
description: "Where to put the generated report file",
default_value: "build"),
FastlaneCore::ConfigItem.new(key: :source_directory,
env_name: "FL_CLOC_SOURCE_DIRECTORY",
description: "Where to look for the source code (relative to the project root folder)",
default_value: ""),
FastlaneCore::ConfigItem.new(key: :xml,
env_name: "FL_CLOC_XML",
description: "Should we generate an XML File (if false, it will generate a plain text file)?",
type: Boolean,
default_value: true)
]
end
def self.authors
["intere"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'cloc(
exclude_dir: "ThirdParty,Resources",
output_directory: "reports",
source_directory: "MyCoolApp"
)'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/upload_to_app_store.rb | fastlane/lib/fastlane/actions/upload_to_app_store.rb | module Fastlane
module Actions
module SharedValues
end
class UploadToAppStoreAction < Action
def self.run(config)
require 'deliver'
begin
config.load_configuration_file("Deliverfile")
config[:screenshots_path] ||= Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH] if Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH]
config[:ipa] ||= Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] if Actions.lane_context[SharedValues::IPA_OUTPUT_PATH]
config[:pkg] ||= Actions.lane_context[SharedValues::PKG_OUTPUT_PATH] if Actions.lane_context[SharedValues::PKG_OUTPUT_PATH]
# Only set :api_key from SharedValues if :api_key_path isn't set (conflicting options)
unless config[:api_key_path]
config[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
end
return config if Helper.test?
Deliver::Runner.new(config).run
end
end
def self.description
"Upload metadata and binary to App Store Connect (via _deliver_)"
end
def self.details
[
"Using _upload_to_app_store_ after _build_app_ and _capture_screenshots_ will automatically upload the latest ipa and screenshots with no other configuration.",
"",
"If you don't want to verify an HTML preview for App Store builds, use the `:force` option.",
"This is useful when running _fastlane_ on your Continuous Integration server:",
"`_upload_to_app_store_(force: true)`",
"If your account is on multiple teams and you need to tell the `iTMSTransporter` which 'provider' to use, you can set the `:itc_provider` option to pass this info."
].join("\n")
end
def self.available_options
require "deliver"
require "deliver/options"
FastlaneCore::CommanderGenerator.new.generate(Deliver::Options.available_options)
end
def self.author
"KrauseFx"
end
def self.is_supported?(platform)
[:ios, :mac, :xros].include?(platform)
end
def self.example_code
[
'upload_to_app_store(
force: true, # Set to true to skip verification of HTML preview
itc_provider: "abcde12345" # pass a specific value to the iTMSTransporter -itc_provider option
)',
'deliver # alias for "upload_to_app_store"',
'appstore # alias for "upload_to_app_store"'
]
end
def self.category
:production
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/setup_jenkins.rb | fastlane/lib/fastlane/actions/setup_jenkins.rb | module Fastlane
module Actions
class SetupJenkinsAction < Action
USED_ENV_NAMES = [
"BACKUP_XCARCHIVE_DESTINATION",
"DERIVED_DATA_PATH",
"FL_CARTHAGE_DERIVED_DATA",
"FL_SLATHER_BUILD_DIRECTORY",
"GYM_BUILD_PATH",
"GYM_CODE_SIGNING_IDENTITY",
"GYM_DERIVED_DATA_PATH",
"GYM_OUTPUT_DIRECTORY",
"GYM_RESULT_BUNDLE",
"SCAN_DERIVED_DATA_PATH",
"SCAN_OUTPUT_DIRECTORY",
"SCAN_RESULT_BUNDLE",
"XCODE_DERIVED_DATA_PATH",
"MATCH_KEYCHAIN_NAME",
"MATCH_KEYCHAIN_PASSWORD",
"MATCH_READONLY"
].freeze
def self.run(params)
# Stop if not executed by CI
if !Helper.ci? && !params[:force]
UI.important("Not executed by Continuous Integration system.")
return
end
# Print table
FastlaneCore::PrintTable.print_values(
config: params,
title: "Summary for Setup Jenkins Action"
)
# Keychain
if params[:unlock_keychain] && params[:keychain_path]
keychain_path = params[:keychain_path]
UI.message("Unlocking keychain: \"#{keychain_path}\".")
Actions::UnlockKeychainAction.run(
path: keychain_path,
password: params[:keychain_password],
add_to_search_list: params[:add_keychain_to_search_list],
set_default: params[:set_default_keychain]
)
ENV['MATCH_KEYCHAIN_NAME'] ||= keychain_path
ENV['MATCH_KEYCHAIN_PASSWORD'] ||= params[:keychain_password]
ENV["MATCH_READONLY"] ||= true.to_s
end
# Code signing identity
if params[:set_code_signing_identity] && params[:code_signing_identity]
code_signing_identity = params[:code_signing_identity]
UI.message("Set code signing identity: \"#{code_signing_identity}\".")
ENV['GYM_CODE_SIGNING_IDENTITY'] = code_signing_identity
end
# Set output directory
if params[:output_directory]
output_directory_path = File.expand_path(params[:output_directory])
UI.message("Set output directory path to: \"#{output_directory_path}\".")
ENV['GYM_BUILD_PATH'] = output_directory_path
ENV['GYM_OUTPUT_DIRECTORY'] = output_directory_path
ENV['SCAN_OUTPUT_DIRECTORY'] = output_directory_path
ENV['BACKUP_XCARCHIVE_DESTINATION'] = output_directory_path
end
# Set derived data
if params[:derived_data_path]
derived_data_path = File.expand_path(params[:derived_data_path])
UI.message("Set derived data path to: \"#{derived_data_path}\".")
ENV['DERIVED_DATA_PATH'] = derived_data_path # Used by clear_derived_data.
ENV['XCODE_DERIVED_DATA_PATH'] = derived_data_path
ENV['GYM_DERIVED_DATA_PATH'] = derived_data_path
ENV['SCAN_DERIVED_DATA_PATH'] = derived_data_path
ENV['FL_CARTHAGE_DERIVED_DATA'] = derived_data_path
ENV['FL_SLATHER_BUILD_DIRECTORY'] = derived_data_path
end
# Set result bundle
if params[:result_bundle]
UI.message("Set result bundle.")
ENV['GYM_RESULT_BUNDLE'] = "YES"
ENV['SCAN_RESULT_BUNDLE'] = "YES"
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Setup xcodebuild, gym and scan for easier Jenkins integration"
end
def self.details
list = <<-LIST.markdown_list(true)
Adds and unlocks keychains from Jenkins 'Keychains and Provisioning Profiles Plugin'
Sets unlocked keychain to be used by Match
Sets code signing identity from Jenkins 'Keychains and Provisioning Profiles Plugin'
Sets output directory to './output' (gym, scan and backup_xcarchive)
Sets derived data path to './derivedData' (xcodebuild, gym, scan and clear_derived_data, carthage)
Produce result bundle (gym and scan)
LIST
[
list,
"This action helps with Jenkins integration. Creates own derived data for each job. All build results like IPA files and archives will be stored in the `./output` directory.",
"The action also works with [Keychains and Provisioning Profiles Plugin](https://wiki.jenkins-ci.org/display/JENKINS/Keychains+and+Provisioning+Profiles+Plugin), the selected keychain will be automatically unlocked and the selected code signing identity will be used.",
"[Match](https://docs.fastlane.tools/actions/match/) will be also set up to use the unlocked keychain and set in read-only mode, if its environment variables were not yet defined.",
"By default this action will only work when _fastlane_ is executed on a CI system."
].join("\n")
end
def self.available_options
[
# General
FastlaneCore::ConfigItem.new(key: :force,
env_name: "FL_SETUP_JENKINS_FORCE",
description: "Force setup, even if not executed by Jenkins",
type: Boolean,
default_value: false),
# Keychain
FastlaneCore::ConfigItem.new(key: :unlock_keychain,
env_name: "FL_SETUP_JENKINS_UNLOCK_KEYCHAIN",
description: "Unlocks keychain",
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :add_keychain_to_search_list,
env_name: "FL_SETUP_JENKINS_ADD_KEYCHAIN_TO_SEARCH_LIST",
description: "Add to keychain search list, valid values are true, false, :add, and :replace",
skip_type_validation: true, # allow Boolean, Symbol
default_value: :replace),
FastlaneCore::ConfigItem.new(key: :set_default_keychain,
env_name: "FL_SETUP_JENKINS_SET_DEFAULT_KEYCHAIN",
description: "Set keychain as default",
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :keychain_path,
env_name: "KEYCHAIN_PATH",
description: "Path to keychain",
optional: true),
FastlaneCore::ConfigItem.new(key: :keychain_password,
env_name: "KEYCHAIN_PASSWORD",
description: "Keychain password",
sensitive: true,
default_value: ""),
# Code signing identity
FastlaneCore::ConfigItem.new(key: :set_code_signing_identity,
env_name: "FL_SETUP_JENKINS_SET_CODE_SIGNING_IDENTITY",
description: "Set code signing identity from CODE_SIGNING_IDENTITY environment",
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :code_signing_identity,
env_name: "CODE_SIGNING_IDENTITY",
description: "Code signing identity",
optional: true),
# Xcode parameters
FastlaneCore::ConfigItem.new(key: :output_directory,
env_name: "FL_SETUP_JENKINS_OUTPUT_DIRECTORY",
description: "The directory in which the ipa file should be stored in",
default_value: "./output"),
FastlaneCore::ConfigItem.new(key: :derived_data_path,
env_name: "FL_SETUP_JENKINS_DERIVED_DATA_PATH",
description: "The directory where built products and other derived data will go",
default_value: "./derivedData"),
FastlaneCore::ConfigItem.new(key: :result_bundle,
env_name: "FL_SETUP_JENKINS_RESULT_BUNDLE",
description: "Produce the result bundle describing what occurred will be placed",
type: Boolean,
default_value: true)
]
end
def self.authors
["bartoszj"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'setup_jenkins'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/frameit.rb | fastlane/lib/fastlane/actions/frameit.rb | module Fastlane
module Actions
require 'fastlane/actions/frame_screenshots'
class FrameitAction < FrameScreenshotsAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `frame_screenshots` action"
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/clipboard.rb | fastlane/lib/fastlane/actions/clipboard.rb | module Fastlane
module Actions
class ClipboardAction < Action
def self.run(params)
value = params[:value]
truncated_value = value[0..800].gsub(/\s\w+\s*$/, '...')
UI.message("Storing '#{truncated_value}' in the clipboard 🎨")
FastlaneCore::Clipboard.copy(content: value)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Copies a given string into the clipboard. Works only on macOS"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :value,
env_name: "FL_CLIPBOARD_VALUE",
description: "The string that should be copied into the clipboard")
]
end
def self.authors
["KrauseFx", "joshdholtz", "rogerluan"]
end
def self.is_supported?(platform)
FastlaneCore::Clipboard.is_supported?
end
def self.example_code
[
'clipboard(value: "https://docs.fastlane.tools/")',
'clipboard(value: lane_context[SharedValues::HOCKEY_DOWNLOAD_LINK] || "")'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/commit_github_file.rb | fastlane/lib/fastlane/actions/commit_github_file.rb | module Fastlane
module Actions
module SharedValues
COMMIT_GITHUB_FILE_HTML_LINK = :COMMIT_GITHUB_FILE_HTML_LINK
COMMIT_GITHUB_FILE_SHA = :COMMIT_GITHUB_FILE_SHA
COMMIT_GITHUB_FILE_JSON = :COMMIT_GITHUB_FILE_JSON
end
class CommitGithubFileAction < Action
def self.run(params)
repo_name = params[:repository_name]
branch = params[:branch] ||= 'master'
commit_message = params[:message]
file_path = params[:path]
file_name = File.basename(file_path)
expanded_file_path = File.expand_path(file_path)
UI.important("Creating commit on #{repo_name} on branch \"#{branch}\" for file \"#{file_path}\"")
api_file_path = file_path
api_file_path = "/#{api_file_path}" unless api_file_path.start_with?('/')
api_file_path = api_file_path[0..-2] if api_file_path.end_with?('/')
payload = {
path: api_file_path,
message: commit_message || "Updated : #{file_name}",
content: Base64.encode64(File.open(expanded_file_path).read),
branch: branch
}
UI.message("Committing #{api_file_path}")
GithubApiAction.run({
server_url: params[:server_url],
api_token: params[:api_token],
api_bearer: params[:api_bearer],
secure: params[:secure],
http_method: "PUT",
path: File.join("repos", params[:repository_name], "contents", api_file_path),
body: payload,
error_handlers: {
422 => proc do |result|
json = result[:json]
UI.error(json || result[:body])
error = if json['message'] == "Invalid request.\n\n\"sha\" wasn't supplied."
"File already exists - please remove from repo before uploading or rename this upload"
else
"Unprocessable error"
end
UI.user_error!(error)
end
}
}) do |result|
UI.success("Successfully committed file to GitHub")
json = result[:json]
html_url = json['commit']['html_url']
download_url = json['content']['download_url']
commit_sha = json['commit']['sha']
UI.important("Commit: \"#{html_url}\"")
UI.important("SHA: \"#{commit_sha}\"")
UI.important("Download at: \"#{download_url}\"")
Actions.lane_context[SharedValues::COMMIT_GITHUB_FILE_HTML_LINK] = html_url
Actions.lane_context[SharedValues::COMMIT_GITHUB_FILE_SHA] = commit_sha
Actions.lane_context[SharedValues::COMMIT_GITHUB_FILE_JSON] = json
end
Actions.lane_context[SharedValues::COMMIT_GITHUB_FILE_JSON]
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"This will commit a file directly on GitHub via the API"
end
def self.details
[
"Commits a file directly to GitHub. You must provide your GitHub Personal token (get one from [https://github.com/settings/tokens/new](https://github.com/settings/tokens/new)), the repository name and the relative file path from the root git project.",
"Out parameters provide the commit sha created, which can be used for later usage for examples such as releases, the direct download link and the full response JSON.",
"Documentation: [https://developer.github.com/v3/repos/contents/#create-a-file](https://developer.github.com/v3/repos/contents/#create-a-file)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :repository_name,
env_name: "FL_COMMIT_GITHUB_FILE_REPOSITORY_NAME",
description: "The path to your repo, e.g. 'fastlane/fastlane'",
verify_block: proc do |value|
UI.user_error!("Please only pass the path, e.g. 'fastlane/fastlane'") if value.include?("github.com")
UI.user_error!("Please only pass the path, e.g. 'fastlane/fastlane'") if value.split('/').count != 2
end),
FastlaneCore::ConfigItem.new(key: :server_url,
env_name: "FL_COMMIT_GITHUB_FILE_SERVER_URL",
description: "The server url. e.g. 'https://your.internal.github.host/api/v3' (Default: 'https://api.github.com')",
default_value: "https://api.github.com",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please include the protocol in the server url, e.g. https://your.github.server/api/v3") unless value.include?("//")
end),
FastlaneCore::ConfigItem.new(key: :api_token,
env_name: "FL_COMMIT_GITHUB_FILE_API_TOKEN",
description: "Personal API Token for GitHub - generate one at https://github.com/settings/tokens",
conflicting_options: [:api_bearer],
sensitive: true,
code_gen_sensitive: true,
default_value: ENV["GITHUB_API_TOKEN"],
default_value_dynamic: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :api_bearer,
env_name: "FL_COMMIT_GITHUB_FILE_API_BEARER",
sensitive: true,
code_gen_sensitive: true,
description: "Use a Bearer authorization token. Usually generated by GitHub Apps, e.g. GitHub Actions GITHUB_TOKEN environment variable",
conflicting_options: [:api_token],
optional: true,
default_value: nil),
FastlaneCore::ConfigItem.new(key: :branch,
env_name: "FL_COMMIT_GITHUB_FILE_BRANCH",
description: "The branch that the file should be committed on (default: master)",
default_value: 'master',
optional: true),
FastlaneCore::ConfigItem.new(key: :path,
env_name: 'FL_COMMIT_GITHUB_FILE_PATH',
description: 'The relative path to your file from project root e.g. assets/my_app.xcarchive',
optional: false,
verify_block: proc do |value|
value = File.expand_path(value)
UI.user_error!("File not found at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :message,
env_name: "FL_COMMIT_GITHUB_FILE_MESSAGE",
description: "The commit message. Defaults to the file name",
default_value_dynamic: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :secure,
env_name: "FL_COMMIT_GITHUB_FILE_SECURE",
description: "Optionally disable secure requests (ssl_verify_peer)",
type: Boolean,
default_value: true,
optional: true)
]
end
def self.output
[
['COMMIT_GITHUB_FILE_HTML_LINK', 'Link to your committed file'],
['COMMIT_GITHUB_FILE_SHA', 'Commit SHA generated'],
['COMMIT_GITHUB_FILE_JSON', 'The whole commit JSON object response']
]
end
def self.return_type
:hash_of_strings
end
def self.return_value
[
"A hash containing all relevant information for this commit",
"Access things like 'html_url', 'sha', 'message'"
].join("\n")
end
def self.authors
["tommeier"]
end
def self.example_code
[
'response = commit_github_file(
repository_name: "fastlane/fastlane",
server_url: "https://api.github.com",
api_token: ENV["GITHUB_TOKEN"],
message: "Add my new file",
branch: "master",
path: "assets/my_new_file.xcarchive"
)'
]
end
def self.is_supported?(platform)
true
end
def self.category
:source_control
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/opt_out_usage.rb | fastlane/lib/fastlane/actions/opt_out_usage.rb | module Fastlane
module Actions
class OptOutUsageAction < Action
def self.run(params)
ENV['FASTLANE_OPT_OUT_USAGE'] = "YES"
UI.message("Disabled upload of used actions")
end
def self.description
"This will stop uploading the information which actions were run"
end
def self.details
[
"By default, _fastlane_ will track what actions are being used. No personal/sensitive information is recorded.",
"Learn more at [https://docs.fastlane.tools/#metrics](https://docs.fastlane.tools/#metrics).",
"Add `opt_out_usage` at the top of your Fastfile to disable metrics collection."
].join("\n")
end
def self.author
"KrauseFx"
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'opt_out_usage # add this to the top of your Fastfile'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/trainer.rb | fastlane/lib/fastlane/actions/trainer.rb | module Fastlane
module Actions
class TrainerAction < Action
def self.run(params)
require "trainer"
params[:path] = Actions.lane_context[Actions::SharedValues::SCAN_GENERATED_PLIST_FILE] if Actions.lane_context[Actions::SharedValues::SCAN_GENERATED_PLIST_FILE]
params[:path] ||= Actions.lane_context[Actions::SharedValues::SCAN_DERIVED_DATA_PATH] if Actions.lane_context[Actions::SharedValues::SCAN_DERIVED_DATA_PATH]
fail_build = params[:fail_build]
resulting_paths = Trainer::TestParser.auto_convert(params)
resulting_paths.each do |path, test_results|
UI.test_failure!("Unit tests failed") if fail_build && !test_results[:successful]
end
return resulting_paths
end
def self.description
"Convert the Xcode plist log to a JUnit report"
end
def self.detail
"Convert the Xcode plist log to a JUnit report. This will raise an exception if the tests failed"
end
def self.authors
["KrauseFx"]
end
def self.return_value
"A hash with the key being the path of the generated file, the value being if the tests were successful"
end
def self.available_options
require 'trainer'
FastlaneCore::CommanderGenerator.new.generate(Trainer::Options.available_options)
end
def self.is_supported?(platform)
%i[ios mac].include?(platform)
end
def self.category
:testing
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/fastlane_version.rb | fastlane/lib/fastlane/actions/fastlane_version.rb | require "fastlane/actions/min_fastlane_version"
module Fastlane
module Actions
class FastlaneVersionAction < MinFastlaneVersionAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `min_fastlane_version` action"
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/frame_screenshots.rb | fastlane/lib/fastlane/actions/frame_screenshots.rb | module Fastlane
module Actions
class FrameScreenshotsAction < Action
def self.run(config)
return if Helper.test?
require 'frameit'
UI.message("Framing screenshots at path #{config[:path]} (via frameit)")
Dir.chdir(config[:path]) do
Frameit.config = config
Frameit::Runner.new.run('.')
end
end
def self.description
"Adds device frames around all screenshots (via _frameit_)"
end
def self.details
[
"Uses [frameit](https://docs.fastlane.tools/actions/frameit/) to prepare perfect screenshots for the App Store, your website, QA or emails.",
"You can add background and titles to the framed screenshots as well."
].join("\n")
end
def self.available_options
require "frameit"
require "frameit/options"
FastlaneCore::CommanderGenerator.new.generate(Frameit::Options.available_options) + [
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FRAMEIT_SCREENSHOTS_PATH",
description: "The path to the directory containing the screenshots",
default_value: Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH] || FastlaneCore::FastlaneFolder.path,
default_value_dynamic: true)
]
end
def self.author
"KrauseFx"
end
def self.example_code
[
'frame_screenshots',
'frameit # alias for "frame_screenshots"',
'frame_screenshots(use_platform: "ANDROID")',
'frame_screenshots(silver: true)',
'frame_screenshots(path: "/screenshots")',
'frame_screenshots(rose_gold: true)'
]
end
def self.category
:screenshots
end
def self.is_supported?(platform)
[:ios, :mac, :android].include?(platform)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/backup_xcarchive.rb | fastlane/lib/fastlane/actions/backup_xcarchive.rb | module Fastlane
module Actions
module SharedValues
BACKUP_XCARCHIVE_FILE = :BACKUP_XCARCHIVE_FILE
end
class BackupXcarchiveAction < Action
require 'fileutils'
def self.run(params)
# Get params
xcarchive = params[:xcarchive]
base_destination = params[:destination]
zipped = params[:zip]
zip_filename = params[:zip_filename]
versioned = params[:versioned]
# Prepare destination folder
full_destination = base_destination
if versioned
date = Time.now.strftime("%Y-%m-%d")
version = `agvtool what-marketing-version -terse1`
subfolder = "#{date} #{version.strip}"
full_destination = File.expand_path(subfolder, base_destination)
end
FileUtils.mkdir(full_destination) unless File.exist?(full_destination)
# Save archive to destination
if zipped
Dir.mktmpdir("backup_xcarchive") do |dir|
UI.message("Compressing #{xcarchive}")
xcarchive_folder = File.expand_path(File.dirname(xcarchive))
xcarchive_file = File.basename(xcarchive)
zip_file = if zip_filename
File.join(dir, "#{zip_filename}.xcarchive.zip")
else
File.join(dir, "#{xcarchive_file}.zip")
end
# Create zip
Actions.sh(%(cd "#{xcarchive_folder}" && zip -r -X -y "#{zip_file}" "#{xcarchive_file}" > /dev/null))
# Moved to its final destination
FileUtils.mv(zip_file, full_destination)
Actions.lane_context[SharedValues::BACKUP_XCARCHIVE_FILE] = "#{full_destination}/#{File.basename(zip_file)}"
end
else
# Copy xcarchive file
FileUtils.cp_r(xcarchive, full_destination)
Actions.lane_context[SharedValues::BACKUP_XCARCHIVE_FILE] = "#{full_destination}/#{File.basename(xcarchive)}"
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Save your [zipped] xcarchive elsewhere from default path"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :xcarchive,
description: 'Path to your xcarchive file. Optional if you use the `xcodebuild` action',
default_value: Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE],
default_value_dynamic: true,
optional: false,
env_name: 'BACKUP_XCARCHIVE_ARCHIVE',
verify_block: proc do |value|
UI.user_error!("Couldn't find xcarchive file at path '#{value}'") if !Helper.test? && !File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :destination,
description: 'Where your archive will be placed',
optional: false,
env_name: 'BACKUP_XCARCHIVE_DESTINATION',
verify_block: proc do |value|
UI.user_error!("Couldn't find the destination folder at '#{value}'") if !Helper.test? && !File.directory?(value) && !File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :zip,
description: 'Enable compression of the archive',
type: Boolean,
default_value: true,
optional: true,
env_name: 'BACKUP_XCARCHIVE_ZIP'),
FastlaneCore::ConfigItem.new(key: :zip_filename,
description: 'Filename of the compressed archive. Will be appended by `.xcarchive.zip`. Default value is the output xcarchive filename',
default_value_dynamic: true,
optional: true,
env_name: 'BACKUP_XCARCHIVE_ZIP_FILENAME'),
FastlaneCore::ConfigItem.new(key: :versioned,
description: 'Create a versioned (date and app version) subfolder where to put the archive',
type: Boolean,
default_value: true,
optional: true,
env_name: 'BACKUP_XCARCHIVE_VERSIONED')
]
end
def self.output
[
['BACKUP_XCARCHIVE_FILE', 'Path to your saved xcarchive (compressed) file']
]
end
def self.author
['dral3x']
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'backup_xcarchive(
xcarchive: "/path/to/file.xcarchive", # Optional if you use the `xcodebuild` action
destination: "/somewhere/else/", # Where the backup should be created
zip_filename: "file.xcarchive", # The name of the backup file
zip: false, # Enable compression of the archive. Defaults to `true`.
versioned: true # Create a versioned (date and app version) subfolder where to put the archive
)'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/opt_out_crash_reporting.rb | fastlane/lib/fastlane/actions/opt_out_crash_reporting.rb | module Fastlane
module Actions
class OptOutCrashReportingAction < Action
def self.run(params)
UI.message("fastlane doesn't have crash reporting anymore, feel free to remove `opt_out_crash_reporting` from your Fastfile")
end
def self.description
"This will prevent reports from being uploaded when _fastlane_ crashes"
end
def self.details
"_fastlane_ doesn't have crash reporting anymore. Feel free to remove `opt_out_crash_reporting` from your Fastfile."
end
def self.authors
['mpirri', 'ohayon']
end
def self.is_supported?(platform)
true
end
def self.example_code
nil
end
def self.category
:deprecated
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/sh.rb | fastlane/lib/fastlane/actions/sh.rb | module Fastlane
module Actions
class ShAction < Action
def self.run(params)
# this is implemented in the sh_helper.rb
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Runs a shell command"
end
def self.details
[
"Allows running an arbitrary shell command.",
"Be aware of a specific behavior of `sh` action with regard to the working directory. For details, refer to [Advanced](https://docs.fastlane.tools/advanced/#directory-behavior)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :command,
description: 'Shell command to be executed',
optional: false),
FastlaneCore::ConfigItem.new(key: :log,
description: 'Determines whether fastlane should print out the executed command itself and output of the executed command. If command line option --troubleshoot is used, then it overrides this option to true',
optional: true,
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :error_callback,
description: 'A callback invoked with the command output if there is a non-zero exit status',
optional: true,
type: :string_callback,
default_value: nil)
]
end
def self.return_value
'Outputs the string and executes it. When running in tests, it returns the actual command instead of executing it'
end
def self.return_type
:string
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'sh("ls")',
'sh("git", "commit", "-m", "My message")'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/update_url_schemes.rb | fastlane/lib/fastlane/actions/update_url_schemes.rb | require 'plist'
module Fastlane
module Actions
class UpdateUrlSchemesAction < Action
def self.run(params)
path = params[:path]
url_schemes = params[:url_schemes]
update_url_schemes = params[:update_url_schemes]
hash = Plist.parse_xml(path)
# Create CFBundleURLTypes array with empty scheme if none exist
unless hash['CFBundleURLTypes']
hash['CFBundleURLTypes'] = [{
'CFBundleTypeRole' => 'Editor',
'CFBundleURLSchemes' => []
}]
end
# Updates schemes with update block if exists
# Else updates with array of strings if exist
# Otherwise shows error to user
if update_url_schemes
new_schemes = update_url_schemes.call(hash['CFBundleURLTypes'].first['CFBundleURLSchemes'])
# Verify array of strings
string = "The URL schemes must be an array of strings, got '#{new_schemes}'."
verify_schemes!(new_schemes, string)
hash['CFBundleURLTypes'].first['CFBundleURLSchemes'] = new_schemes
elsif url_schemes
hash['CFBundleURLTypes'].first['CFBundleURLSchemes'] = url_schemes
else
UI.user_error!("No `url_schemes` or `update_url_schemes` provided")
end
File.write(path, Plist::Emit.dump(hash))
end
def self.verify_schemes!(url_schemes, error_message)
UI.user_error!(error_message) unless url_schemes.kind_of?(Array)
url_schemes.each do |url_scheme|
UI.user_error!(error_message) unless url_scheme.kind_of?(String)
end
end
def self.description
'Updates the URL schemes in the given Info.plist'
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: 'FL_UPDATE_URL_SCHEMES_PATH',
description: 'The Plist file\'s path',
optional: false,
verify_block: proc do |path|
UI.user_error!("Could not find plist at path '#{path}'") unless File.exist?(path)
end),
FastlaneCore::ConfigItem.new(key: :url_schemes,
env_name: "FL_UPDATE_URL_SCHEMES_SCHEMES",
description: 'The new URL schemes',
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :update_url_schemes,
description: "Block that is called to update schemes with current schemes passed in as parameter",
optional: true,
type: :string_callback)
]
end
def self.details
[
"This action allows you to update the URL schemes of the app before building it.",
"For example, you can use this to set a different URL scheme for the alpha or beta version of the app."
].join("\n")
end
def self.output
[]
end
def self.authors
['kmikael']
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'update_url_schemes(
path: "path/to/Info.plist",
url_schemes: ["com.myapp"]
)',
'update_url_schemes(
path: "path/to/Info.plist",
update_url_schemes: proc do |schemes|
schemes + ["anotherscheme"]
end
)'
]
end
def self.category
:project
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/increment_build_number.rb | fastlane/lib/fastlane/actions/increment_build_number.rb | module Fastlane
module Actions
module SharedValues
BUILD_NUMBER ||= :BUILD_NUMBER
end
class IncrementBuildNumberAction < Action
require 'shellwords'
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.run(params)
folder = params[:xcodeproj] ? File.join(params[:xcodeproj], '..') : '.'
command_prefix = [
'cd',
File.expand_path(folder).shellescape,
'&&'
].join(' ')
command_suffix = [
'&&',
'cd',
'-'
].join(' ')
# More information about how to set up your project and how it works:
# https://developer.apple.com/library/ios/qa/qa1827/_index.html
# Attention: This is NOT the version number - but the build number
agv_disabled = !system([command_prefix, 'agvtool what-version', command_suffix].join(' '))
raise "Apple Generic Versioning is not enabled." if agv_disabled && params[:build_number].nil?
mode = params[:skip_info_plist] ? '' : ' -all'
command = [
command_prefix,
'agvtool',
params[:build_number] ? "new-version#{mode} #{params[:build_number].to_s.strip}" : "next-version#{mode}",
command_suffix
].join(' ')
output = Actions.sh(command)
if output.include?('$(SRCROOT)')
UI.error('Cannot set build number with plist path containing $(SRCROOT)')
UI.error('Please remove $(SRCROOT) in your Xcode target build settings')
end
# Store the new number in the shared hash
build_number = params[:build_number].to_s.strip
build_number = Actions.sh("#{command_prefix} agvtool what-version", log: false).split("\n").last.strip if build_number.to_s == ""
return Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number
rescue
UI.user_error!("Apple Generic Versioning is not enabled in this project.\nBefore being able to increment and read the version number from your Xcode project, you first need to setup your project properly. Please follow the guide at https://developer.apple.com/library/content/qa/qa1827/_index.html")
end
def self.description
"Increment the build number of your project"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :build_number,
env_name: "FL_BUILD_NUMBER_BUILD_NUMBER",
description: "Change to a specific version. When you provide this parameter, Apple Generic Versioning does not have to be enabled",
optional: true,
skip_type_validation: true), # allow Integer, String
FastlaneCore::ConfigItem.new(key: :skip_info_plist,
env_name: "FL_BUILD_NUMBER_SKIP_INFO_PLIST",
description: "Don't update Info.plist files when updating the build version",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "FL_BUILD_NUMBER_PROJECT",
description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with?(".xcworkspace")
UI.user_error!("Could not find Xcode project") if !File.exist?(value) && !Helper.test?
end)
]
end
def self.output
[
['BUILD_NUMBER', 'The new build number']
]
end
def self.return_value
"The new build number"
end
def self.return_type
:string
end
def self.author
"KrauseFx"
end
def self.example_code
[
'increment_build_number # automatically increment by one',
'increment_build_number(
build_number: "75" # set a specific number
)',
'increment_build_number(
build_number: 75, # specify specific build number (optional, omitting it increments by one)
xcodeproj: "./path/to/MyApp.xcodeproj" # (optional, you must specify the path to your main Xcode project if it is not in the project root directory)
)',
'build_number = increment_build_number'
]
end
def self.category
:project
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/lcov.rb | fastlane/lib/fastlane/actions/lcov.rb | module Fastlane
module Actions
class LcovAction < Action
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.run(options)
unless Helper.test?
UI.user_error!("lcov not installed, please install using `brew install lcov`") if `which lcov`.length == 0
end
gen_cov(options)
end
def self.description
"Generates coverage data using lcov"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :project_name,
env_name: "FL_LCOV_PROJECT_NAME",
description: "Name of the project"),
FastlaneCore::ConfigItem.new(key: :scheme,
env_name: "FL_LCOV_SCHEME",
description: "Scheme of the project"),
FastlaneCore::ConfigItem.new(key: :arch,
env_name: "FL_LCOV_ARCH",
description: "The build arch where will search .gcda files",
default_value: "i386"),
FastlaneCore::ConfigItem.new(key: :output_dir,
env_name: "FL_LCOV_OUTPUT_DIR",
description: "The output directory that coverage data will be stored. If not passed will use coverage_reports as default value",
optional: true,
default_value: "coverage_reports")
]
end
def self.author
"thiagolioy"
end
def self.gen_cov(options)
tmp_cov_file = "/tmp/coverage.info"
output_dir = options[:output_dir]
derived_data_path = derived_data_dir(options)
system("lcov --capture --directory \"#{derived_data_path}\" --output-file #{tmp_cov_file}")
system(gen_lcov_cmd(tmp_cov_file))
system("genhtml #{tmp_cov_file} --output-directory #{output_dir}")
end
def self.gen_lcov_cmd(cov_file)
cmd = "lcov "
exclude_dirs.each do |e|
cmd << "--remove #{cov_file} \"#{e}\" "
end
cmd << "--output #{cov_file} "
end
def self.derived_data_dir(options)
pn = options[:project_name]
sc = options[:scheme]
arch = options[:arch]
initial_path = "#{Dir.home}/Library/Developer/Xcode/DerivedData/"
end_path = "/Build/Intermediates/#{pn}.build/Debug-iphonesimulator/#{sc}.build/Objects-normal/#{arch}/"
match = find_project_dir(pn, initial_path)
"#{initial_path}#{match}#{end_path}"
end
def self.find_project_dir(project_name, path)
`ls -t #{path}| grep #{project_name} | head -1`.to_s.delete("\n")
end
def self.exclude_dirs
["/Applications/*", "/Frameworks/*"]
end
def self.example_code
[
'lcov(
project_name: "ProjectName",
scheme: "yourScheme",
output_dir: "cov_reports" # This value is optional. Default is coverage_reports
)'
]
end
def self.category
:testing
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/download_app_privacy_details_from_app_store.rb | fastlane/lib/fastlane/actions/download_app_privacy_details_from_app_store.rb | module Fastlane
module Actions
class DownloadAppPrivacyDetailsFromAppStoreAction < Action
DEFAULT_PATH = Fastlane::Helper.fastlane_enabled_folder_path
DEFAULT_FILE_NAME = "app_privacy_details.json"
def self.run(params)
require 'spaceship'
# Prompts select team if multiple teams and none specified
UI.message("Login to App Store Connect (#{params[:username]})")
Spaceship::ConnectAPI.login(params[:username], use_portal: false, use_tunes: true, tunes_team_id: params[:team_id], team_name: params[:team_name])
UI.message("Login successful")
# Get App
app = Spaceship::ConnectAPI::App.find(params[:app_identifier])
unless app
UI.user_error!("Could not find app with bundle identifier '#{params[:app_identifier]}' on account #{params[:username]}")
end
# Download usages and return a config
raw_usages = download_app_data_usages(params, app)
usages_config = []
if raw_usages.count == 1 && raw_usages.first.data_protection.id == Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_NOT_COLLECTED
usages_config << {
"data_protections" => [Spaceship::ConnectAPI::AppDataUsageDataProtection::ID::DATA_NOT_COLLECTED]
}
else
grouped_usages = raw_usages.group_by do |usage|
usage.category.id
end
grouped_usages.sort_by(&:first).each do |key, usage_group|
purposes = usage_group.map(&:purpose).compact || []
data_protections = usage_group.map(&:data_protection).compact || []
usages_config << {
"category" => key,
"purposes" => purposes.map(&:id).sort.uniq,
"data_protections" => data_protections.map(&:id).sort.uniq
}
end
end
# Save to JSON file
json = JSON.pretty_generate(usages_config)
path = output_path(params)
UI.message("Writing file to #{path}")
File.write(path, json)
end
def self.output_path(params)
path = params[:output_json_path]
return File.absolute_path(path)
end
def self.download_app_data_usages(params, app)
UI.message("Downloading App Data Usage")
# Delete all existing usages for new ones
Spaceship::ConnectAPI::AppDataUsage.all(app_id: app.id, includes: "category,grouping,purpose,dataProtection", limit: 500)
end
def self.description
"Download App Privacy Details from an app in App Store Connect"
end
def self.available_options
user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
[
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FASTLANE_USER",
description: "Your Apple ID Username for App Store Connect",
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_APP_IDENTIFIER",
description: "The bundle identifier of your app",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :team_id,
env_name: "FASTLANE_ITC_TEAM_ID",
description: "The ID of your App Store Connect team if you're in multiple teams",
optional: true,
skip_type_validation: true, # as we also allow integers, which we convert to strings anyway
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :team_name,
env_name: "FASTLANE_ITC_TEAM_NAME",
description: "The name of your App Store Connect team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name),
default_value_dynamic: true),
# JSON paths
FastlaneCore::ConfigItem.new(key: :output_json_path,
env_name: "UPLOAD_APP_PRIVACY_DETAILS_TO_APP_STORE_OUTPUT_JSON_PATH",
description: "Path to the app usage data JSON file generated by interactive questions",
conflicting_options: [:skip_json_file_saving],
default_value: File.join(DEFAULT_PATH, DEFAULT_FILE_NAME))
]
end
def self.author
"igor-makarov"
end
def self.is_supported?(platform)
[:ios, :mac, :tvos].include?(platform)
end
def self.details
"Download App Privacy Details from an app in App Store Connect. For more detail information, view https://docs.fastlane.tools/uploading-app-privacy-details"
end
def self.example_code
[
'download_app_privacy_details_from_app_store(
username: "your@email.com",
team_name: "Your Team",
app_identifier: "com.your.bundle"
)',
'download_app_privacy_details_from_app_store(
username: "your@email.com",
team_name: "Your Team",
app_identifier: "com.your.bundle",
output_json_path: "fastlane/app_data_usages.json"
)'
]
end
def self.category
:production
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/number_of_commits.rb | fastlane/lib/fastlane/actions/number_of_commits.rb | module Fastlane
module Actions
class NumberOfCommitsAction < Action
def self.is_git?
Actions.sh('git rev-parse HEAD')
return true
rescue
return false
end
def self.run(params)
if is_git?
if params[:all]
command = 'git rev-list --all --count'
else
command = 'git rev-list HEAD --count'
end
else
UI.user_error!("Not in a git repository.")
end
return Actions.sh(command).strip.to_i
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Return the number of commits in current git branch"
end
def self.return_value
"The total number of all commits in current git branch"
end
def self.return_type
:int
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :all,
env_name: "FL_NUMBER_OF_COMMITS_ALL",
optional: true,
type: Boolean,
description: "Returns number of all commits instead of current branch")
]
end
def self.details
"You can use this action to get the number of commits of this branch. This is useful if you want to set the build number to the number of commits. See `fastlane actions number_of_commits` for more details."
end
def self.authors
["onevcat", "samuelbeek"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'increment_build_number(build_number: number_of_commits)',
'build_number = number_of_commits(all: true)
increment_build_number(build_number: build_number)'
]
end
def self.category
:source_control
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/jira.rb | fastlane/lib/fastlane/actions/jira.rb | module Fastlane
module Actions
module SharedValues
JIRA_JSON = :JIRA_JSON
end
class JiraAction < Action
def self.run(params)
Actions.verify_gem!('jira-ruby')
require 'jira-ruby'
site = params[:url]
auth_type = :basic
context_path = params[:context_path]
username = params[:username]
password = params[:password]
ticket_id = params[:ticket_id]
comment_text = params[:comment_text]
options = {
site: site,
context_path: context_path,
auth_type: auth_type,
username: username,
password: password
}
begin
client = JIRA::Client.new(options)
issue = client.Issue.find(ticket_id)
comment = issue.comments.build
comment.save({ 'body' => comment_text })
# An exact representation of the JSON returned from the JIRA API
# https://github.com/sumoheavy/jira-ruby/blob/master/lib/jira/base.rb#L67
json_response = comment.attrs
raise 'Failed to add a comment on Jira ticket' if json_response.nil?
Actions.lane_context[SharedValues::JIRA_JSON] = json_response
UI.success('Successfully added a comment on Jira ticket')
return json_response
rescue => exception
message = "Received exception when adding a Jira comment: #{exception}"
if params[:fail_on_error]
UI.user_error!(message)
else
UI.error(message)
end
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Leave a comment on a Jira ticket"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :url,
env_name: "FL_JIRA_SITE",
description: "URL for Jira instance",
verify_block: proc do |value|
UI.user_error!("No url for Jira given, pass using `url: 'url'`") if value.to_s.length == 0
end),
FastlaneCore::ConfigItem.new(key: :context_path,
env_name: "FL_JIRA_CONTEXT_PATH",
description: "Appends to the url (ex: \"/jira\")",
optional: true,
default_value: ""),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FL_JIRA_USERNAME",
description: "Username for Jira instance",
verify_block: proc do |value|
UI.user_error!("No username") if value.to_s.length == 0
end),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_JIRA_PASSWORD",
description: "Password or API token for Jira",
sensitive: true,
verify_block: proc do |value|
UI.user_error!("No password") if value.to_s.length == 0
end),
FastlaneCore::ConfigItem.new(key: :ticket_id,
env_name: "FL_JIRA_TICKET_ID",
description: "Ticket ID for Jira, i.e. IOS-123",
verify_block: proc do |value|
UI.user_error!("No Ticket specified") if value.to_s.length == 0
end),
FastlaneCore::ConfigItem.new(key: :comment_text,
env_name: "FL_JIRA_COMMENT_TEXT",
description: "Text to add to the ticket as a comment",
verify_block: proc do |value|
UI.user_error!("No comment specified") if value.to_s.length == 0
end),
FastlaneCore::ConfigItem.new(key: :fail_on_error,
env_name: "FL_JIRA_FAIL_ON_ERROR",
description: "Should an error adding the Jira comment cause a failure?",
type: Boolean,
optional: true,
default_value: true) # Default value is true for 'Backward compatibility'
]
end
def self.output
[
['JIRA_JSON', 'The whole Jira API JSON object']
]
end
def self.return_value
[
"A hash containing all relevant information of the Jira comment",
"Access Jira comment 'id', 'author', 'body', and more"
].join("\n")
end
def self.return_type
:hash
end
def self.authors
["iAmChrisTruman", "crazymanish"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'jira(
url: "https://bugs.yourdomain.com",
username: "Your username",
password: "Your password or API token",
ticket_id: "IOS-123",
comment_text: "Text to post as a comment"
)', # How to get API token: https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/#get-an-api-token
'jira(
url: "https://yourserverdomain.com",
context_path: "/jira",
username: "Your username",
password: "Your password or API token",
ticket_id: "IOS-123",
comment_text: "Text to post as a comment"
)',
'jira(
ticket_id: "IOS-123",
comment_text: "Text to post as a comment",
fail_on_error: false
)'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/adb_devices.rb | fastlane/lib/fastlane/actions/adb_devices.rb | module Fastlane
module Actions
module SharedValues
end
class AdbDevicesAction < Action
def self.run(params)
adb = Helper::AdbHelper.new(adb_path: params[:adb_path])
result = adb.load_all_devices
return result
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Get an array of Connected android device serials"
end
def self.details
"Fetches device list via adb, e.g. run an adb command on all connected devices."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :adb_path,
env_name: "FL_ADB_PATH",
description: "The path to your `adb` binary (can be left blank if the ANDROID_SDK_ROOT environment variable is set)",
optional: true,
default_value: "adb")
]
end
def self.output
end
def self.example_code
[
'adb_devices.each do |device|
model = adb(command: "shell getprop ro.product.model",
serial: device.serial).strip
puts "Model #{model} is connected"
end'
]
end
def self.sample_return_value
[]
end
def self.category
:misc
end
def self.return_value
"Returns an array of all currently connected android devices"
end
def self.authors
["hjanuschka"]
end
def self.is_supported?(platform)
platform == :android
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/modify_services.rb | fastlane/lib/fastlane/actions/modify_services.rb | module Fastlane
module Actions
class ModifyServicesAction < Action
def self.run(params)
require 'produce'
Produce.config = params
Dir.chdir(FastlaneCore::FastlaneFolder.path || Dir.pwd) do
require 'produce/service'
services = params[:services]
enabled_services = services.select { |_k, v| v == true || (v != false && v.to_s != 'off') }.map { |k, v| [k, v == true || v.to_s == 'on' ? 'on' : v] }.to_h
disabled_services = services.select { |_k, v| v == false || v.to_s == 'off' }.map { |k, v| [k, 'off'] }.to_h
enabled_services_object = self.service_object
enabled_services.each do |k, v|
enabled_services_object.__hash__[k] = true
enabled_services_object.send("#{k}=", v)
end
Produce::Service.enable(enabled_services_object, nil) unless enabled_services.empty?
disabled_services_object = self.service_object
disabled_services.each do |k, v|
disabled_services_object.__hash__[k] = true
disabled_services_object.send("#{k}=", v)
end
Produce::Service.disable(disabled_services_object, nil) unless disabled_services.empty?
end
end
def self.service_object
service_object = Object.new
service_object.class.module_eval { attr_accessor :__hash__ }
service_object.__hash__ = {}
Produce::DeveloperCenter::ALLOWED_SERVICES.keys.each do |service|
name = self.services_mapping[service]
service_object.class.module_eval { attr_accessor :"#{name}" }
end
service_object
end
def self.services_mapping
{
access_wifi: 'access_wifi',
app_attest: 'app_attest',
app_group: 'app_group',
apple_pay: 'apple_pay',
associated_domains: 'associated_domains',
auto_fill_credential: 'auto_fill_credential',
class_kit: 'class_kit',
declared_age_range: 'declared_age_range',
icloud: 'icloud',
custom_network_protocol: 'custom_network_protocol',
data_protection: 'data_protection',
extended_virtual_address_space: 'extended_virtual_address_space',
family_controls: 'family_controls',
file_provider_testing_mode: 'file_provider_testing_mode',
fonts: 'fonts',
game_center: 'game_center',
health_kit: 'health_kit',
hls_interstitial_preview: 'hls_interstitial_preview',
home_kit: 'home_kit',
hotspot: 'hotspot',
in_app_purchase: 'in_app_purchase',
inter_app_audio: 'inter_app_audio',
low_latency_hls: 'low_latency_hls',
managed_associated_domains: 'managed_associated_domains',
maps: 'maps',
multipath: 'multipath',
network_extension: 'network_extension',
nfc_tag_reading: 'nfc_tag_reading',
personal_vpn: 'personal_vpn',
passbook: 'passbook',
push_notification: 'push_notification',
sign_in_with_apple: 'sign_in_with_apple',
siri_kit: 'siri_kit',
system_extension: 'system_extension',
user_management: 'user_management',
vpn_configuration: 'vpn_configuration',
wallet: 'wallet',
wireless_accessory: 'wireless_accessory',
car_play_audio_app: 'car_play_audio_app',
car_play_messaging_app: 'car_play_messaging_app',
car_play_navigation_app: 'car_play_navigation_app',
car_play_voip_calling_app: 'car_play_voip_calling_app',
critical_alerts: 'critical_alerts',
hotspot_helper: 'hotspot_helper',
driver_kit: 'driver_kit',
driver_kit_endpoint_security: 'driver_kit_endpoint_security',
driver_kit_family_hid_device: 'driver_kit_family_hid_device',
driver_kit_family_networking: 'driver_kit_family_networking',
driver_kit_family_serial: 'driver_kit_family_serial',
driver_kit_hid_event_service: 'driver_kit_hid_event_service',
driver_kit_transport_hid: 'driver_kit_transport_hid',
multitasking_camera_access: 'multitasking_camera_access',
sf_universal_link_api: 'sf_universal_link_api',
vp9_decoder: 'vp9_decoder',
music_kit: 'music_kit',
shazam_kit: 'shazam_kit',
communication_notifications: 'communication_notifications',
group_activities: 'group_activities',
health_kit_estimate_recalibration: 'health_kit_estimate_recalibration',
time_sensitive_notifications: 'time_sensitive_notifications'
}
end
def self.allowed_services_description
return Produce::DeveloperCenter::ALLOWED_SERVICES.map do |k, v|
"#{k}: (#{v.join('|')})(:on|:off)(true|false)"
end.join(", ")
end
def self.description
'Modifies the services of the app created on Developer Portal'
end
def self.details
[
"The options are the same as `:enable_services` in the [produce action](https://docs.fastlane.tools/actions/produce/#parameters_1)"
].join("\n")
end
def self.available_options
require 'produce'
user = CredentialsManager::AppfileConfig.try_fetch_value(:apple_dev_portal_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
[
FastlaneCore::ConfigItem.new(key: :username,
short_option: "-u",
env_name: "PRODUCE_USERNAME",
description: "Your Apple ID Username",
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
env_name: "PRODUCE_APP_IDENTIFIER",
short_option: "-a",
description: "App Identifier (Bundle ID, e.g. com.krausefx.app)",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :services,
display_in_shell: false,
env_name: "PRODUCE_ENABLE_SERVICES",
description: "Array with Spaceship App Services (e.g. #{allowed_services_description})",
type: Hash,
default_value: {},
verify_block: proc do |value|
allowed_keys = Produce::DeveloperCenter::ALLOWED_SERVICES.keys
UI.user_error!("enable_services has to be of type Hash") unless value.kind_of?(Hash)
value.each do |key, v|
UI.user_error!("The key: '#{key}' is not supported in `enable_services' - following keys are available: [#{allowed_keys.join(',')}]") unless allowed_keys.include?(key.to_sym)
end
end),
FastlaneCore::ConfigItem.new(key: :team_id,
short_option: "-b",
env_name: "PRODUCE_TEAM_ID",
description: "The ID of your Developer Portal team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_id),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_TEAM_ID"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :team_name,
short_option: "-l",
env_name: "PRODUCE_TEAM_NAME",
description: "The name of your Developer Portal team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:team_name),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_TEAM_NAME"] = value.to_s
end)
]
end
def self.author
"bhimsenpadalkar"
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'modify_services(
username: "test.account@gmail.com",
app_identifier: "com.someorg.app",
services: {
push_notification: "on",
associated_domains: "off",
wallet: :on,
apple_pay: :off,
data_protection: true,
multipath: false
})'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/notification.rb | fastlane/lib/fastlane/actions/notification.rb | module Fastlane
module Actions
class NotificationAction < Action
def self.run(params)
require 'terminal-notifier'
options = params.values
# :message is non-optional
message = options.delete(:message)
# remove nil keys, since `notify` below does not ignore them and instead translates them into empty strings in output, which looks ugly
options = options.select { |_, v| v }
option_map = {
app_icon: :appIcon,
content_image: :contentImage
}
options = options.transform_keys { |k| option_map.fetch(k, k) }
TerminalNotifier.notify(message, options)
end
def self.description
"Display a macOS notification with custom message and title"
end
def self.author
["champo", "cbowns", "KrauseFx", "amarcadet", "dusek"]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :title,
description: "The title to display in the notification",
default_value: 'fastlane'),
FastlaneCore::ConfigItem.new(key: :subtitle,
description: "A subtitle to display in the notification",
optional: true),
FastlaneCore::ConfigItem.new(key: :message,
description: "The message to display in the notification",
optional: false),
FastlaneCore::ConfigItem.new(key: :sound,
description: "The name of a sound to play when the notification appears (names are listed in Sound Preferences)",
optional: true),
FastlaneCore::ConfigItem.new(key: :activate,
description: "Bundle identifier of application to be opened when the notification is clicked",
optional: true),
FastlaneCore::ConfigItem.new(key: :app_icon,
description: "The URL of an image to display instead of the application icon (Mavericks+ only)",
optional: true),
FastlaneCore::ConfigItem.new(key: :content_image,
description: "The URL of an image to display attached to the notification (Mavericks+ only)",
optional: true),
FastlaneCore::ConfigItem.new(key: :open,
description: "URL of the resource to be opened when the notification is clicked",
optional: true),
FastlaneCore::ConfigItem.new(key: :execute,
description: "Shell command to run when the notification is clicked",
optional: true)
]
end
def self.is_supported?(platform)
Helper.mac?
end
def self.example_code
[
'notification(subtitle: "Finished Building", message: "Ready to upload...")'
]
end
def self.category
:notifications
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/update_app_identifier.rb | fastlane/lib/fastlane/actions/update_app_identifier.rb | module Fastlane
module Actions
class UpdateAppIdentifierAction < Action
def self.run(params)
require 'plist'
require 'xcodeproj'
info_plist_key = 'INFOPLIST_FILE'
identifier_key = 'PRODUCT_BUNDLE_IDENTIFIER'
# Read existing plist file
info_plist_path = resolve_path(params[:plist_path], params[:xcodeproj])
UI.user_error!("Couldn't find info plist file at path '#{params[:plist_path]}'") unless File.exist?(info_plist_path)
plist = Plist.parse_xml(info_plist_path)
# Check if current app identifier product bundle identifier
app_id_equals_bundle_id = %W($(#{identifier_key}) ${#{identifier_key}}).include?(plist['CFBundleIdentifier'])
if app_id_equals_bundle_id
# Load .xcodeproj
project_path = params[:xcodeproj]
project = Xcodeproj::Project.open(project_path)
# Fetch the build configuration objects
configs = project.objects.select { |obj| obj.isa == 'XCBuildConfiguration' && !obj.build_settings[identifier_key].nil? }
UI.user_error!("Info plist uses #{identifier_key}, but xcodeproj does not") if configs.empty?
configs = configs.select { |obj| resolve_path(obj.build_settings[info_plist_key], params[:xcodeproj]) == info_plist_path }
UI.user_error!("Xcodeproj doesn't have configuration with info plist #{params[:plist_path]}.") if configs.empty?
# For each of the build configurations, set app identifier
configs.each do |c|
c.build_settings[identifier_key] = params[:app_identifier]
end
# Write changes to the file
project.save
UI.success("Updated #{params[:xcodeproj]} 💾.")
else
# Update plist value
plist['CFBundleIdentifier'] = params[:app_identifier]
# Write changes to file
plist_string = Plist::Emit.dump(plist)
File.write(info_plist_path, plist_string)
UI.success("Updated #{params[:plist_path]} 💾.")
end
end
def self.resolve_path(path, xcodeproj_path)
return nil unless path
project_dir = File.dirname(xcodeproj_path)
# SRCROOT, SOURCE_ROOT and PROJECT_DIR are the same
%w{SRCROOT SOURCE_ROOT PROJECT_DIR}.each do |variable_name|
path = path.sub("$(#{variable_name})", project_dir)
end
path = File.absolute_path(path, project_dir)
path
end
#####################################################
# @!group Documentation
#####################################################
def self.is_supported?(platform)
[:ios].include?(platform)
end
def self.description
"Update the project's bundle identifier"
end
def self.details
"Update an app identifier by either setting `CFBundleIdentifier` or `PRODUCT_BUNDLE_IDENTIFIER`, depending on which is already in use."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "FL_UPDATE_APP_IDENTIFIER_PROJECT_PATH",
description: "Path to your Xcode project",
code_gen_sensitive: true,
default_value: Dir['*.xcodeproj'].first,
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Please pass the path to the project, not the workspace") unless value.end_with?(".xcodeproj")
UI.user_error!("Could not find Xcode project") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :plist_path,
env_name: "FL_UPDATE_APP_IDENTIFIER_PLIST_PATH",
description: "Path to info plist, relative to your Xcode project",
verify_block: proc do |value|
UI.user_error!("Invalid plist file") unless value[-6..-1].casecmp(".plist").zero?
end),
FastlaneCore::ConfigItem.new(key: :app_identifier,
env_name: 'FL_UPDATE_APP_IDENTIFIER',
description: 'The app Identifier you want to set',
code_gen_sensitive: true,
default_value: ENV['PRODUCE_APP_IDENTIFIER'] || CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true)
]
end
def self.authors
['squarefrog', 'tobiasstrebitzer']
end
def self.example_code
[
'update_app_identifier(
xcodeproj: "Example.xcodeproj", # Optional path to xcodeproj, will use the first .xcodeproj if not set
plist_path: "Example/Info.plist", # Path to info plist file, relative to xcodeproj
app_identifier: "com.test.example" # The App Identifier
)'
]
end
def self.category
:project
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/chatwork.rb | fastlane/lib/fastlane/actions/chatwork.rb | module Fastlane
module Actions
module SharedValues
end
class ChatworkAction < Action
def self.run(options)
require 'net/http'
require 'uri'
emoticon = (options[:success] ? '(dance)' : ';(')
uri = URI.parse("https://api.chatwork.com/v2/rooms/#{options[:roomid]}/messages")
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
req = Net::HTTP::Post.new(uri.request_uri)
req['X-ChatWorkToken'] = options[:api_token]
req.set_form_data({
'body' => "[info][title]Notification from fastlane[/title]#{emoticon} #{options[:message]}[/info]"
})
response = https.request(req)
case response.code.to_i
when 200..299
UI.success('Successfully sent notification to ChatWork right now 📢')
else
require 'json'
json = JSON.parse(response.body)
UI.user_error!("HTTP Error: #{response.code} #{json['errors']}")
end
end
def self.description
"Send a success/error message to [ChatWork](https://go.chatwork.com/)"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :api_token,
env_name: "CHATWORK_API_TOKEN",
description: "ChatWork API Token",
sensitive: true,
code_gen_sensitive: true,
verify_block: proc do |value|
unless value.to_s.length > 0
UI.error("Please add 'ENV[\"CHATWORK_API_TOKEN\"] = \"your token\"' to your Fastfile's `before_all` section.")
UI.user_error!("No CHATWORK_API_TOKEN given.")
end
end),
FastlaneCore::ConfigItem.new(key: :message,
env_name: "FL_CHATWORK_MESSAGE",
description: "The message to post on ChatWork"),
FastlaneCore::ConfigItem.new(key: :roomid,
env_name: "FL_CHATWORK_ROOMID",
description: "The room ID",
type: Integer),
FastlaneCore::ConfigItem.new(key: :success,
env_name: "FL_CHATWORK_SUCCESS",
description: "Was this build successful? (true/false)",
optional: true,
default_value: true,
type: Boolean)
]
end
def self.author
"astronaughts"
end
def self.is_supported?(platform)
true
end
def self.details
"Information on how to obtain an API token: [http://developer.chatwork.com/ja/authenticate.html](http://developer.chatwork.com/ja/authenticate.html)"
end
def self.example_code
[
'chatwork(
message: "App successfully released!",
roomid: 12345,
success: true,
api_token: "Your Token"
)'
]
end
def self.category
:notifications
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/install_xcode_plugin.rb | fastlane/lib/fastlane/actions/install_xcode_plugin.rb | module Fastlane
module Actions
class InstallXcodePluginAction < Action
def self.run(params)
require 'fileutils'
require 'tmpdir'
if params[:github]
base_api_url = params[:github].sub('https://github.com', 'https://api.github.com/repos')
GithubApiAction.run(
url: File.join(base_api_url, 'releases/latest'),
http_method: 'GET',
error_handlers: {
404 => proc do |result|
UI.error("No latest release found for the specified GitHub repository")
end,
'*' => proc do |result|
UI.error("GitHub responded with #{response[:status]}:#{response[:body]}")
end
}
) do |result|
return nil if result[:json].nil?
params[:url] = result[:json]['assets'][0]['browser_download_url']
end
end
zip_path = File.join(Dir.tmpdir, 'plugin.zip')
Action.sh("curl", "-L", "-s", "-o", zip_path, params[:url])
plugins_path = "#{ENV['HOME']}/Library/Application Support/Developer/Shared/Xcode/Plug-ins"
FileUtils.mkdir_p(plugins_path)
Action.sh("unzip", "-qo", zip_path, "-d", plugins_path)
UI.success("Plugin #{File.basename(params[:url], '.zip')} installed successfully")
UI.message("Please restart Xcode to use the newly installed plugin")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Install an Xcode plugin for the current user"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :url,
env_name: "FL_XCODE_PLUGIN_URL",
description: "URL for Xcode plugin ZIP file",
verify_block: proc do |value|
UI.user_error!("No URL for InstallXcodePluginAction given, pass using `url: 'url'`") if value.to_s.length == 0
UI.user_error!("URL doesn't use HTTPS") unless value.start_with?("https://")
end),
FastlaneCore::ConfigItem.new(key: :github,
env_name: "FL_XCODE_PLUGIN_GITHUB",
description: "GitHub repository URL for Xcode plugin",
optional: true,
verify_block: proc do |value|
UI.user_error!("No GitHub URL for InstallXcodePluginAction given, pass using `github: 'url'`") if value.to_s.length == 0
UI.user_error!("URL doesn't use HTTPS") unless value.start_with?("https://")
end)
]
end
def self.output
end
def self.return_value
end
def self.authors
["NeoNachoSoto", "tommeier"]
end
def self.is_supported?(platform)
[:ios, :mac, :tvos, :watchos, :caros].include?(platform)
end
def self.example_code
[
'install_xcode_plugin(url: "https://example.com/clubmate/plugin.zip")',
'install_xcode_plugin(github: "https://github.com/contentful/ContentfulXcodePlugin")'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/carthage.rb | fastlane/lib/fastlane/actions/carthage.rb | module Fastlane
module Actions
class CarthageAction < Action
# rubocop:disable Metrics/PerceivedComplexity
def self.run(params)
validate(params)
cmd = [params[:executable]]
command_name = params[:command]
cmd << command_name
if command_name == "archive" && params[:frameworks].count > 0
cmd.concat(params[:frameworks])
# "update", "build" and "bootstrap" are the only commands that support "--derived-data" parameter
elsif ["update", "build", "bootstrap"].include?(command_name)
cmd.concat(params[:dependencies]) if params[:dependencies].count > 0
cmd << "--derived-data #{params[:derived_data].shellescape}" if params[:derived_data]
end
cmd << "--output #{params[:output]}" if params[:output]
cmd << "--use-ssh" if params[:use_ssh]
cmd << "--use-submodules" if params[:use_submodules]
cmd << "--use-netrc" if params[:use_netrc]
cmd << "--no-use-binaries" if params[:use_binaries] == false
cmd << "--no-checkout" if params[:no_checkout] == true
cmd << "--no-build" if params[:no_build] == true
cmd << "--no-skip-current" if params[:no_skip_current] == true
cmd << "--verbose" if params[:verbose] == true
cmd << "--platform #{params[:platform]}" if params[:platform]
cmd << "--configuration #{params[:configuration]}" if params[:configuration]
cmd << "--toolchain #{params[:toolchain]}" if params[:toolchain]
cmd << "--project-directory #{params[:project_directory]}" if params[:project_directory]
cmd << "--cache-builds" if params[:cache_builds]
cmd << "--new-resolver" if params[:new_resolver]
cmd << "--log-path #{params[:log_path]}" if params[:log_path]
cmd << "--use-xcframeworks" if params[:use_xcframeworks]
cmd << "--archive" if params[:archive]
Actions.sh(cmd.join(' '))
end
# rubocop:enable Metrics/PerceivedComplexity
def self.validate(params)
command_name = params[:command]
if command_name != "archive" && params[:frameworks].count > 0
UI.user_error!("Frameworks option is available only for 'archive' command.")
end
if command_name != "archive" && params[:output]
UI.user_error!("Output option is available only for 'archive' command.")
end
if params[:log_path] && !%w(build bootstrap update).include?(command_name)
UI.user_error!("Log path option is available only for 'build', 'bootstrap', and 'update' command.")
end
if params[:use_xcframeworks] && !%w(build bootstrap update).include?(command_name)
UI.user_error!("Use XCFrameworks option is available only for 'build', 'bootstrap', and 'update' command.")
end
if command_name != "build" && params[:archive]
UI.user_error!("Archive option is available only for 'build' command.")
end
end
def self.description
"Runs `carthage` for your project"
end
def self.available_commands
%w(build bootstrap update archive)
end
def self.available_platforms
%w(all iOS Mac tvOS watchOS)
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :command,
env_name: "FL_CARTHAGE_COMMAND",
description: "Carthage command (one of: #{available_commands.join(', ')})",
default_value: 'bootstrap',
verify_block: proc do |value|
UI.user_error!("Please pass a valid command. Use one of the following: #{available_commands.join(', ')}") unless available_commands.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :dependencies,
description: "Carthage dependencies to update, build or bootstrap",
default_value: [],
type: Array),
FastlaneCore::ConfigItem.new(key: :use_ssh,
env_name: "FL_CARTHAGE_USE_SSH",
description: "Use SSH for downloading GitHub repositories",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :use_submodules,
env_name: "FL_CARTHAGE_USE_SUBMODULES",
description: "Add dependencies as Git submodules",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :use_netrc,
env_name: "FL_CARTHAGE_USE_NETRC",
description: "Use .netrc for downloading frameworks",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :use_binaries,
env_name: "FL_CARTHAGE_USE_BINARIES",
description: "Check out dependency repositories even when prebuilt frameworks exist",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :no_checkout,
env_name: "FL_CARTHAGE_NO_CHECKOUT",
description: "When bootstrapping Carthage do not checkout",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :no_build,
env_name: "FL_CARTHAGE_NO_BUILD",
description: "When bootstrapping Carthage do not build",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :no_skip_current,
env_name: "FL_CARTHAGE_NO_SKIP_CURRENT",
description: "Don't skip building the Carthage project (in addition to its dependencies)",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :derived_data,
env_name: "FL_CARTHAGE_DERIVED_DATA",
description: "Use derived data folder at path",
optional: true),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: "FL_CARTHAGE_VERBOSE",
description: "Print xcodebuild output inline",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :platform,
env_name: "FL_CARTHAGE_PLATFORM",
description: "Define which platform to build for",
optional: true,
verify_block: proc do |value|
value.split(',').each do |platform|
UI.user_error!("Please pass a valid platform. Use one of the following: #{available_platforms.join(', ')}") unless available_platforms.map(&:downcase).include?(platform.downcase)
end
end),
FastlaneCore::ConfigItem.new(key: :cache_builds,
env_name: "FL_CARTHAGE_CACHE_BUILDS",
description: "By default Carthage will rebuild a dependency regardless of whether it's the same resolved version as before. Passing the --cache-builds will cause carthage to avoid rebuilding a dependency if it can",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :frameworks,
description: "Framework name or names to archive, could be applied only along with the archive command",
default_value: [],
type: Array),
FastlaneCore::ConfigItem.new(key: :output,
description: "Output name for the archive, could be applied only along with the archive command. Use following format *.framework.zip",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass a valid string for output. Use following format *.framework.zip") unless value.end_with?("framework.zip")
end),
FastlaneCore::ConfigItem.new(key: :configuration,
env_name: "FL_CARTHAGE_CONFIGURATION",
description: "Define which build configuration to use when building",
optional: true,
verify_block: proc do |value|
if value.chomp(' ').empty?
UI.user_error!("Please pass a valid build configuration. You can review the list of configurations for this project using the command: xcodebuild -list")
end
end),
FastlaneCore::ConfigItem.new(key: :toolchain,
env_name: "FL_CARTHAGE_TOOLCHAIN",
description: "Define which xcodebuild toolchain to use when building",
optional: true),
FastlaneCore::ConfigItem.new(key: :project_directory,
env_name: "FL_CARTHAGE_PROJECT_DIRECTORY",
description: "Define the directory containing the Carthage project",
optional: true),
FastlaneCore::ConfigItem.new(key: :new_resolver,
env_name: "FL_CARTHAGE_NEW_RESOLVER",
description: "Use new resolver when resolving dependency graph",
optional: true,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :log_path,
env_name: "FL_CARTHAGE_LOG_PATH",
description: "Path to the xcode build output",
optional: true),
FastlaneCore::ConfigItem.new(key: :use_xcframeworks,
env_name: "FL_CARTHAGE_USE_XCFRAMEWORKS",
description: "Create xcframework bundles instead of one framework per platform (requires Xcode 12+)",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :archive,
env_name: "FL_CARTHAGE_ARCHIVE",
description: "Archive built frameworks from the current project",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :executable,
env_name: "FL_CARTHAGE_EXECUTABLE",
description: "Path to the `carthage` executable on your machine",
default_value: 'carthage')
]
end
def self.example_code
[
'carthage',
'carthage(
frameworks: ["MyFramework1", "MyFramework2"], # Specify which frameworks to archive (only for the archive command)
output: "MyFrameworkBundle.framework.zip", # Specify the output archive name (only for the archive command)
command: "bootstrap", # One of: build, bootstrap, update, archive. (default: bootstrap)
dependencies: ["Alamofire", "Notice"], # Specify which dependencies to update or build (only for update, build and bootstrap commands)
use_ssh: false, # Use SSH for downloading GitHub repositories.
use_submodules: false, # Add dependencies as Git submodules.
use_binaries: true, # Check out dependency repositories even when prebuilt frameworks exist
no_build: false, # When bootstrapping Carthage do not build
no_skip_current: false, # Don\'t skip building the current project (only for frameworks)
verbose: false, # Print xcodebuild output inline
platform: "all", # Define which platform to build for (one of ‘all’, ‘Mac’, ‘iOS’, ‘watchOS’, ‘tvOS‘, or comma-separated values of the formers except for ‘all’)
configuration: "Release", # Build configuration to use when building
cache_builds: true, # By default Carthage will rebuild a dependency regardless of whether its the same resolved version as before.
toolchain: "com.apple.dt.toolchain.Swift_2_3", # Specify the xcodebuild toolchain
new_resolver: false, # Use the new resolver to resolve dependency graph
log_path: "carthage.log" # Path to the xcode build output
)'
]
end
def self.category
:building
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.authors
["bassrock", "petester42", "jschmid", "JaviSoto", "uny", "phatblat", "bfcrampton", "antondomashnev", "gbrhaz"]
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/git_add.rb | fastlane/lib/fastlane/actions/git_add.rb | module Fastlane
module Actions
class GitAddAction < Action
def self.run(params)
should_escape = params[:shell_escape]
if params[:pathspec]
paths = params[:pathspec]
success_message = "Successfully added from \"#{paths}\" 💾."
elsif params[:path]
paths = params[:path].map do |p|
shell_escape(p, should_escape)
end.join(' ')
success_message = "Successfully added \"#{paths}\" 💾."
else
paths = "."
success_message = "Successfully added all files 💾."
end
force = params[:force] ? "--force" : nil
command = [
"git",
"add",
force,
paths
].compact
result = Actions.sh(command.join(" "), log: FastlaneCore::Globals.verbose?).chomp
UI.success(success_message)
return result
end
def self.shell_escape(path, should_escape)
path = path.shellescape if should_escape
path
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Directly add the given file or all files"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
description: "The file(s) and path(s) you want to add",
type: Array,
conflicting_options: [:pathspec],
optional: true),
FastlaneCore::ConfigItem.new(key: :shell_escape,
description: "Shell escapes paths (set to false if using wildcards or manually escaping spaces in :path)",
type: Boolean,
default_value: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :force,
description: "Allow adding otherwise ignored files",
type: Boolean,
default_value: false,
optional: true),
# Deprecated
FastlaneCore::ConfigItem.new(key: :pathspec,
description: "The pathspec you want to add files from",
conflicting_options: [:path],
optional: true,
deprecated: "Use `--path` instead")
]
end
def self.return_value
nil
end
def self.authors
["4brunu", "antondomashnev"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'git_add',
'git_add(path: "./version.txt")',
'git_add(path: ["./version.txt", "./changelog.txt"])',
'git_add(path: "./Frameworks/*", shell_escape: false)',
'git_add(path: ["*.h", "*.m"], shell_escape: false)',
'git_add(path: "./Frameworks/*", shell_escape: false)',
'git_add(path: "*.txt", shell_escape: false)',
'git_add(path: "./tmp/.keep", force: true)'
]
end
def self.category
:source_control
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/recreate_schemes.rb | fastlane/lib/fastlane/actions/recreate_schemes.rb | module Fastlane
module Actions
class RecreateSchemesAction < Action
def self.run(params)
require 'xcodeproj'
UI.message("Recreate schemes for project: #{params[:project]}")
project = Xcodeproj::Project.open(params[:project])
project.recreate_user_schemes
end
def self.description
"Recreate not shared Xcode project schemes"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(
key: :project,
env_name: "XCODE_PROJECT",
description: "The Xcode project"
)
]
end
def self.authors
"jerolimov"
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'recreate_schemes(project: "./path/to/MyApp.xcodeproj")'
]
end
def self.category
:project
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/environment_variable.rb | fastlane/lib/fastlane/actions/environment_variable.rb | module Fastlane
module Actions
class EnvironmentVariableAction < Action
def self.run(params)
values_to_set = params[:set]
value_to_get = params[:get]
value_to_remove = params[:remove]
# clear out variables that were removed
ENV[value_to_remove] = nil unless value_to_remove.nil?
# if we have to set variables, do that now
unless values_to_set.nil?
values_to_set.each do |key, value|
ENV[key] = value
end
end
# finally, get the variable we requested
return ENV[value_to_get] unless value_to_get.nil?
# if no variable is requested, just return empty string
return ""
end
def self.author
"taquitos"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :set,
env_name: 'FL_ENVIRONMENT_VARIABLE_SET',
description: 'Set the environment variables named',
optional: true,
type: Hash),
FastlaneCore::ConfigItem.new(key: :get,
env_name: 'FL_ENVIRONMENT_VARIABLE_GET',
description: 'Get the environment variable named',
optional: true),
FastlaneCore::ConfigItem.new(key: :remove,
env_name: 'FL_ENVIRONMENT_VARIABLE_REMOVE',
description: 'Remove the environment variable named',
optional: true)
]
end
def self.description
"Sets/gets env vars for Fastlane.swift. Don't use in ruby, use `ENV[key] = val`"
end
def self.step_text
nil
end
def self.category
:misc
end
def self.return_type
:string
end
def self.is_supported?(platform)
true
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/clear_derived_data.rb | fastlane/lib/fastlane/actions/clear_derived_data.rb | require 'fastlane_core/core_ext/cfpropertylist'
module Fastlane
module Actions
class ClearDerivedDataAction < Action
def self.run(options)
path = File.expand_path(options[:derived_data_path])
UI.message("Derived Data path located at: #{path}")
FileUtils.rm_rf(path) if File.directory?(path)
UI.success("Successfully cleared Derived Data ♻️")
end
# Helper Methods
def self.xcode_preferences
file = File.expand_path("~/Library/Preferences/com.apple.dt.Xcode.plist")
if File.exist?(file)
plist = CFPropertyList::List.new(file: file).value
return CFPropertyList.native_types(plist) unless plist.nil?
end
return nil
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Deletes the Xcode Derived Data"
end
def self.details
"Deletes the Derived Data from path set on Xcode or a supplied path"
end
def self.available_options
path = xcode_preferences ? xcode_preferences['IDECustomDerivedDataLocation'] : nil
path ||= "~/Library/Developer/Xcode/DerivedData"
[
FastlaneCore::ConfigItem.new(key: :derived_data_path,
env_name: "DERIVED_DATA_PATH",
description: "Custom path for derivedData",
default_value_dynamic: true,
default_value: path)
]
end
def self.output
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'clear_derived_data',
'clear_derived_data(derived_data_path: "/custom/")'
]
end
def self.category
:building
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/set_info_plist_value.rb | fastlane/lib/fastlane/actions/set_info_plist_value.rb | module Fastlane
module Actions
module SharedValues
end
class SetInfoPlistValueAction < Action
def self.run(params)
require "plist"
begin
path = File.expand_path(params[:path])
plist = Plist.parse_xml(path)
if params[:subkey]
if plist[params[:key]]
plist[params[:key]][params[:subkey]] = params[:value]
else
UI.message("Key doesn't exist, going to create new one ...")
plist[params[:key]] = { params[:subkey] => params[:value] }
end
else
plist[params[:key]] = params[:value]
end
new_plist = Plist::Emit.dump(plist)
if params[:output_file_name]
output = params[:output_file_name]
FileUtils.mkdir_p(File.expand_path("..", output))
File.write(File.expand_path(output), new_plist)
else
File.write(path, new_plist)
end
return params[:value]
rescue => ex
UI.error(ex)
UI.user_error!("Unable to set value to plist file at '#{path}'")
end
end
def self.description
"Sets value to Info.plist of your project as native Ruby data structures"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :key,
env_name: "FL_SET_INFO_PLIST_PARAM_NAME",
description: "Name of key in plist",
optional: false),
FastlaneCore::ConfigItem.new(key: :subkey,
env_name: "FL_SET_INFO_PLIST_SUBPARAM_NAME",
description: "Name of subkey in plist",
optional: true),
FastlaneCore::ConfigItem.new(key: :value,
env_name: "FL_SET_INFO_PLIST_PARAM_VALUE",
description: "Value to setup",
skip_type_validation: true, # allow String, Hash
optional: false),
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_SET_INFO_PLIST_PATH",
description: "Path to plist file you want to update",
optional: false,
verify_block: proc do |value|
UI.user_error!("Couldn't find plist file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :output_file_name,
env_name: "FL_SET_INFO_PLIST_OUTPUT_FILE_NAME",
description: "Path to the output file you want to generate",
optional: true)
]
end
def self.authors
["kohtenko", "uwehollatz"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'set_info_plist_value(path: "./Info.plist", key: "CFBundleIdentifier", value: "com.krausefx.app.beta")',
'set_info_plist_value(path: "./MyApp-Info.plist", key: "NSAppTransportSecurity", subkey: "NSAllowsArbitraryLoads", value: true, output_file_name: "./Info.plist")'
]
end
def self.category
:project
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/set_changelog.rb | fastlane/lib/fastlane/actions/set_changelog.rb | module Fastlane
module Actions
class SetChangelogAction < Action
def self.run(params)
require 'spaceship'
# Team selection passed though FASTLANE_ITC_TEAM_ID and FASTLANE_ITC_TEAM_NAME environment variables
# Prompts select team if multiple teams and none specified
if (api_token = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path]))
UI.message("Creating authorization token for App Store Connect API")
Spaceship::ConnectAPI.token = api_token
elsif !Spaceship::ConnectAPI.token.nil?
UI.message("Using existing authorization token for App Store Connect API")
else
UI.message("Login to App Store Connect (#{params[:username]})")
Spaceship::ConnectAPI.login(params[:username], use_portal: false, use_tunes: true, tunes_team_id: params[:team_id], team_name: params[:team_name])
UI.message("Login successful")
end
app = Spaceship::ConnectAPI::App.find(params[:app_identifier])
UI.user_error!("Couldn't find app with identifier #{params[:app_identifier]}") if app.nil?
version_number = params[:version]
platform = Spaceship::ConnectAPI::Platform.map(params[:platform])
unless version_number
# Automatically fetch the latest version
UI.message("Fetching the latest version for this app")
edit_version = app.get_edit_app_store_version(platform: platform)
if edit_version
version_number = edit_version.version_string
else
UI.message("You have to specify a new version number: ")
version_number = STDIN.gets.strip
end
end
UI.message("Going to update version #{version_number}")
changelog = params[:changelog]
unless changelog
path = default_changelog_path
UI.message("Looking for changelog in '#{path}'...")
if File.exist?(path)
changelog = File.read(path)
else
UI.error("Couldn't find changelog.txt")
UI.message("Please enter the changelog here:")
changelog = STDIN.gets
end
end
UI.important("Going to update the changelog to:\n\n#{changelog}\n\n")
edit_version = app.get_edit_app_store_version(platform: platform)
if edit_version
if edit_version.version_string != version_number
# Version is already there, make sure it matches the one we want to create
UI.message("Changing existing version number from '#{edit_version.version_string}' to '#{version_number}'")
edit_version = edit_version.update(attributes: {
versionString: version_number
})
else
UI.message("Updating changelog for existing version #{edit_version.version_string}")
end
else
UI.message("Creating the new version: #{version_number}")
attributes = { versionString: version_number, platform: platform }
edit_version = Spaceship::ConnectAPI.post_app_store_version(app_id: app.id, attributes: attributes).first
end
localizations = edit_version.get_app_store_version_localizations
localizations.each do |localization|
UI.message("Updating changelog for the '#{localization.locale}'")
localization.update(attributes: {
whatsNew: changelog
})
end
UI.success("👼 Successfully pushed the new changelog to for #{edit_version.version_string}")
end
def self.default_changelog_path
File.join(FastlaneCore::FastlaneFolder.path.to_s, 'changelog.txt')
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Set the changelog for all languages on App Store Connect"
end
def self.details
[
"This is useful if you have only one changelog for all languages.",
"You can store the changelog in `#{default_changelog_path}` and it will automatically get loaded from there. This integration is useful if you support e.g. 10 languages and want to use the same \"What's new\"-text for all languages.",
"Defining the version is optional. _fastlane_ will try to automatically detect it if you don't provide one."
].join("\n")
end
def self.available_options
user = CredentialsManager::AppfileConfig.try_fetch_value(:itunes_connect_id)
user ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
[
FastlaneCore::ConfigItem.new(key: :api_key_path,
env_names: ["FL_SET_CHANGELOG_API_KEY_PATH", "APP_STORE_CONNECT_API_KEY_PATH"],
description: "Path to your App Store Connect API Key JSON file (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-json-file)",
optional: true,
conflicting_options: [:api_key],
verify_block: proc do |value|
UI.user_error!("Couldn't find API key JSON file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_names: ["FL_SET_CHANGELOG_API_KEY", "APP_STORE_CONNECT_API_KEY"],
description: "Your App Store Connect API Key information (https://docs.fastlane.tools/app-store-connect-api/#using-fastlane-api-key-hash-option)",
type: Hash,
default_value: Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::APP_STORE_CONNECT_API_KEY],
default_value_dynamic: true,
optional: true,
sensitive: true,
conflicting_options: [:api_key_path]),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
env_name: "FASTLANE_APP_IDENTIFIER",
description: "The bundle identifier of your app",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :username,
short_option: "-u",
env_name: "FASTLANE_USERNAME",
description: "Your Apple ID Username",
optional: true,
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :version,
env_name: "FL_SET_CHANGELOG_VERSION",
description: "The version number to create/update",
optional: true),
FastlaneCore::ConfigItem.new(key: :changelog,
env_name: "FL_SET_CHANGELOG_CHANGELOG",
description: "Changelog text that should be uploaded to App Store Connect",
optional: true),
FastlaneCore::ConfigItem.new(key: :team_id,
short_option: "-k",
env_name: "FL_SET_CHANGELOG_TEAM_ID",
description: "The ID of your App Store Connect team if you're in multiple teams",
optional: true,
skip_type_validation: true, # as we also allow integers, which we convert to strings anyway
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_ITC_TEAM_ID"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :team_name,
short_option: "-e",
env_name: "FL_SET_CHANGELOG_TEAM_NAME",
description: "The name of your App Store Connect team if you're in multiple teams",
optional: true,
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_name),
default_value_dynamic: true,
verify_block: proc do |value|
ENV["FASTLANE_ITC_TEAM_NAME"] = value.to_s
end),
FastlaneCore::ConfigItem.new(key: :platform,
env_name: "FL_SET_CHANGELOG_PLATFORM",
description: "The platform of the app (ios, appletvos, xros, mac)",
default_value: "ios",
verify_block: proc do |value|
available = ['ios', 'appletvos', 'xros', 'mac']
UI.user_error!("Invalid platform '#{value}', must be #{available.join(', ')}") unless available.include?(value)
end)
]
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :appletvos, :xros, :mac].include?(platform)
end
def self.example_code
[
'set_changelog(changelog: "Changelog for all Languages")',
'set_changelog(app_identifier: "com.krausefx.app", version: "1.0", changelog: "Changelog for all Languages")'
]
end
def self.category
:app_store_connect
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/build_and_upload_to_appetize.rb | fastlane/lib/fastlane/actions/build_and_upload_to_appetize.rb | module Fastlane
module Actions
class BuildAndUploadToAppetizeAction < Action
def self.run(params)
tmp_path = "/tmp/fastlane_build"
xcodebuild_configs = params[:xcodebuild]
xcodebuild_configs[:sdk] = "iphonesimulator"
xcodebuild_configs[:derivedDataPath] = tmp_path
xcodebuild_configs[:xcargs] = "CONFIGURATION_BUILD_DIR=" + tmp_path
xcodebuild_configs[:scheme] ||= params[:scheme] if params[:scheme].to_s.length > 0
Actions::XcodebuildAction.run(xcodebuild_configs)
app_path = Dir[File.join(tmp_path, "**", "*.app")].last
UI.user_error!("Couldn't find app") unless app_path
zipped_bundle = Actions::ZipAction.run(path: app_path,
output_path: File.join(tmp_path, "Result.zip"))
other_action.appetize(path: zipped_bundle,
api_token: params[:api_token],
public_key: params[:public_key],
note: params[:note],
timeout: params[:timeout])
public_key = Actions.lane_context[SharedValues::APPETIZE_PUBLIC_KEY]
UI.success("Generated Public Key: #{Actions.lane_context[SharedValues::APPETIZE_PUBLIC_KEY]}")
FileUtils.rm_rf(tmp_path)
return public_key
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Generate and upload an ipa file to appetize.io"
end
def self.details
[
"This should be called from danger.",
"More information in the [device_grid guide](https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/device_grid/README.md)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :xcodebuild,
description: "Parameters that are passed to the xcodebuild action",
type: Hash,
default_value: {},
short_option: '-x',
optional: true),
FastlaneCore::ConfigItem.new(key: :scheme,
description: "The scheme to build. Can also be passed using the `xcodebuild` parameter",
type: String,
short_option: '-s',
optional: true),
FastlaneCore::ConfigItem.new(key: :api_token,
env_name: "APPETIZE_API_TOKEN",
description: "Appetize.io API Token",
sensitive: true,
code_gen_sensitive: true),
FastlaneCore::ConfigItem.new(key: :public_key,
description: "If not provided, a new app will be created. If provided, the existing build will be overwritten",
optional: true,
verify_block: proc do |value|
if value.start_with?("private_")
UI.user_error!("You provided a private key to appetize, please provide the public key")
end
end),
FastlaneCore::ConfigItem.new(key: :note,
description: "Notes you wish to add to the uploaded app",
optional: true),
FastlaneCore::ConfigItem.new(key: :timeout,
description: "The number of seconds to wait until automatically ending the session due to user inactivity. Must be 30, 60, 90, 120, 180, 300, 600, 1800, 3600 or 7200. Default is 120",
type: Integer,
optional: true,
verify_block: proc do |value|
UI.user_error!("The value provided doesn't match any of the supported options.") unless [30, 60, 90, 120, 180, 300, 600, 1800, 3600, 7200].include?(value)
end)
]
end
def self.output
end
def self.return_value
""
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
nil
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/cert.rb | fastlane/lib/fastlane/actions/cert.rb | module Fastlane
module Actions
require 'fastlane/actions/get_certificates'
class CertAction < GetCertificatesAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `get_certificates` action"
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/get_certificates.rb | fastlane/lib/fastlane/actions/get_certificates.rb | module Fastlane
module Actions
module SharedValues
CERT_FILE_PATH = :CERT_FILE_PATH
CERT_CERTIFICATE_ID = :CERT_CERTIFICATE_ID
end
class GetCertificatesAction < Action
def self.run(params)
require 'cert'
return if Helper.test?
begin
# Only set :api_key from SharedValues if :api_key_path isn't set (conflicting options)
unless params[:api_key_path]
params[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
end
Cert.config = params # we already have the finished config
Cert::Runner.new.launch
cert_file_path = ENV["CER_FILE_PATH"]
certificate_id = ENV["CER_CERTIFICATE_ID"]
Actions.lane_context[SharedValues::CERT_FILE_PATH] = cert_file_path
Actions.lane_context[SharedValues::CERT_CERTIFICATE_ID] = certificate_id
UI.success("Use signing certificate '#{certificate_id}' from now on!")
ENV["SIGH_CERTIFICATE_ID"] = certificate_id # for further use in the sigh action
end
end
def self.description
"Create new iOS code signing certificates (via _cert_)"
end
def self.details
[
"**Important**: It is recommended to use [match](https://docs.fastlane.tools/actions/match/) according to the [codesigning.guide](https://codesigning.guide) for generating and maintaining your certificates. Use _cert_ directly only if you want full control over what's going on and know more about codesigning.",
"Use this action to download the latest code signing identity."
].join("\n")
end
def self.available_options
require 'cert'
Cert::Options.available_options
end
def self.output
[
['CERT_FILE_PATH', 'The path to the certificate'],
['CERT_CERTIFICATE_ID', 'The id of the certificate']
]
end
def self.author
"KrauseFx"
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'get_certificates',
'cert # alias for "get_certificates"',
'get_certificates(
development: true,
username: "user@email.com"
)'
]
end
def self.category
:code_signing
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/create_keychain.rb | fastlane/lib/fastlane/actions/create_keychain.rb | require 'shellwords'
module Fastlane
module Actions
module SharedValues
ORIGINAL_DEFAULT_KEYCHAIN = :ORIGINAL_DEFAULT_KEYCHAIN
KEYCHAIN_PATH = :KEYCHAIN_PATH
end
class CreateKeychainAction < Action
def self.run(params)
escaped_password = params[:password].shellescape
if params[:name]
escaped_name = params[:name].shellescape
keychain_path = "~/Library/Keychains/#{escaped_name}"
else
keychain_path = params[:path].shellescape
end
if keychain_path.nil?
UI.user_error!("You either have to set :name or :path")
end
commands = []
if !exists?(keychain_path)
commands << Fastlane::Actions.sh("security create-keychain -p #{escaped_password} #{keychain_path}", log: false)
elsif params[:require_create]
UI.abort_with_message!("`require_create` option passed, but found keychain '#{keychain_path}', failing create_keychain action")
else
UI.important("Found keychain '#{keychain_path}', creation skipped")
UI.important("If creating a new Keychain DB is required please set the `require_create` option true to cause the action to fail")
end
Actions.lane_context[Actions::SharedValues::KEYCHAIN_PATH] = keychain_path
if params[:default_keychain]
# if there is no default keychain - setting the original will fail - silent this error
begin
Actions.lane_context[Actions::SharedValues::ORIGINAL_DEFAULT_KEYCHAIN] = Fastlane::Actions.sh("security default-keychain", log: false).strip
rescue
end
commands << Fastlane::Actions.sh("security default-keychain -s #{keychain_path}", log: false)
end
commands << Fastlane::Actions.sh("security unlock-keychain -p #{escaped_password} #{keychain_path}", log: false) if params[:unlock]
command = "security set-keychain-settings"
# https://ss64.com/osx/security-keychain-settings.html
# omitting 'timeout' option to specify "no timeout" if required
command << " -t #{params[:timeout]}" if params[:timeout] > 0
command << " -l" if params[:lock_when_sleeps]
command << " -u" if params[:lock_after_timeout]
command << " #{keychain_path}"
commands << Fastlane::Actions.sh(command, log: false)
if params[:add_to_search_list]
keychains = list_keychains
expanded_path = resolved_keychain_path(keychain_path)
if keychains.include?(expanded_path)
UI.important("Found keychain '#{expanded_path}' in list-keychains, adding to search list skipped")
else
keychains << expanded_path
commands << Fastlane::Actions.sh("security list-keychains -s #{keychains.shelljoin}", log: false)
end
end
commands
end
def self.list_keychains
Action.sh("security list-keychains -d user").shellsplit
end
def self.exists?(keychain_path)
!resolved_keychain_path(keychain_path).nil?
end
# returns the expanded and resolved path for the keychain, or nil if not found
def self.resolved_keychain_path(keychain_path)
keychain_path = File.expand_path(keychain_path)
# Creating Keychains using the security
# CLI appends `-db` to the file name.
["#{keychain_path}-db", keychain_path].each do |path|
return path if File.exist?(path)
end
nil
end
def self.description
"Create a new Keychain"
end
def self.output
[
['ORIGINAL_DEFAULT_KEYCHAIN', 'The path to the default keychain'],
['KEYCHAIN_PATH', 'The path of the keychain']
]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :name,
env_name: "KEYCHAIN_NAME",
description: "Keychain name",
conflicting_options: [:path],
optional: true),
FastlaneCore::ConfigItem.new(key: :path,
env_name: "KEYCHAIN_PATH",
description: "Path to keychain",
conflicting_options: [:name],
optional: true),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "KEYCHAIN_PASSWORD",
description: "Password for the keychain",
sensitive: true,
code_gen_sensitive: true,
optional: false),
FastlaneCore::ConfigItem.new(key: :default_keychain,
description: 'Should the newly created Keychain be the new system default keychain',
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :unlock,
description: 'Unlock keychain after create',
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :timeout,
description: 'timeout interval in seconds. Set `0` if you want to specify "no time-out"',
type: Integer,
default_value: 300),
FastlaneCore::ConfigItem.new(key: :lock_when_sleeps,
description: 'Lock keychain when the system sleeps',
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :lock_after_timeout,
description: 'Lock keychain after timeout interval',
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :add_to_search_list,
description: 'Add keychain to search list',
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :require_create,
description: 'Fail the action if the Keychain already exists',
type: Boolean,
default_value: false)
]
end
def self.authors
["gin0606"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'create_keychain(
name: "KeychainName",
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: true
)'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/update_info_plist.rb | fastlane/lib/fastlane/actions/update_info_plist.rb | module Fastlane
module Actions
module SharedValues
end
class UpdateInfoPlistAction < Action
def self.run(params)
# Check if parameters are set
if params[:app_identifier] || params[:display_name] || params[:block]
if (params[:app_identifier] || params[:display_name]) && params[:block]
UI.important("block parameter cannot be specified with app_identifier or display_name")
return false
end
# Assign folder from parameter or search for xcodeproj file
folder = params[:xcodeproj] || Dir["*.xcodeproj"].first
UI.user_error!("Could not figure out your xcodeproj path. Please specify it using the `xcodeproj` parameter") if folder.nil?
if params[:scheme]
project = Xcodeproj::Project.open(folder)
scheme = project.native_targets.detect { |target| target.name == params[:scheme] }
UI.user_error!("Couldn't find scheme named '#{params[:scheme]}'") unless scheme
params[:plist_path] = scheme.build_configurations.first.build_settings["INFOPLIST_FILE"]
UI.user_error!("Scheme named '#{params[:scheme]}' doesn't have a plist file") unless params[:plist_path]
params[:plist_path] = params[:plist_path].gsub("$(SRCROOT)", ".")
end
if params[:plist_path].nil?
UI.user_error!("You must specify either a plist path or a scheme")
end
# Read existing plist file
info_plist_path = File.join(folder, "..", params[:plist_path])
UI.user_error!("Couldn't find info plist file at path '#{info_plist_path}'") unless File.exist?(info_plist_path)
UpdatePlistAction.run(
plist_path: info_plist_path,
block: proc do |plist|
plist['CFBundleIdentifier'] = params[:app_identifier] if params[:app_identifier]
plist['CFBundleDisplayName'] = params[:display_name] if params[:display_name]
params[:block].call(plist) if params[:block]
end
)
else
UI.important("You haven't specified any parameters to update your plist.")
false
end
end
#####################################################
# @!group Documentation
#####################################################
def self.is_supported?(platform)
[:ios].include?(platform)
end
def self.description
'Update a Info.plist file with bundle identifier and display name'
end
def self.details
"This action allows you to modify your `Info.plist` file before building. This may be useful if you want a separate build for alpha, beta or nightly builds, but don't want a separate target."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "FL_UPDATE_PLIST_PROJECT_PATH",
description: "Path to your Xcode project",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass the path to the project, not the workspace") if value.end_with?(".xcworkspace")
UI.user_error!("Could not find Xcode project") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :plist_path,
env_name: "FL_UPDATE_PLIST_PATH",
description: "Path to info plist",
optional: true,
verify_block: proc do |value|
UI.user_error!("Invalid plist file") unless value.downcase.end_with?(".plist")
end),
FastlaneCore::ConfigItem.new(key: :scheme,
env_name: "FL_UPDATE_PLIST_APP_SCHEME",
description: "Scheme of info plist",
optional: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
env_name: 'FL_UPDATE_PLIST_APP_IDENTIFIER',
description: 'The App Identifier of your app',
code_gen_sensitive: true,
default_value: ENV['PRODUCE_APP_IDENTIFIER'],
default_value_dynamic: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :display_name,
env_name: 'FL_UPDATE_PLIST_DISPLAY_NAME',
description: 'The Display Name of your app',
optional: true),
FastlaneCore::ConfigItem.new(key: :block,
type: :string_callback,
description: 'A block to process plist with custom logic',
optional: true)
]
end
def self.author
'tobiasstrebitzer'
end
def self.example_code
[
'update_info_plist( # update app identifier string
plist_path: "path/to/Info.plist",
app_identifier: "com.example.newappidentifier"
)',
'update_info_plist( # Change the Display Name of your app
plist_path: "path/to/Info.plist",
display_name: "MyApp-Beta"
)',
'update_info_plist( # Target a specific `xcodeproj` rather than finding the first available one
xcodeproj: "path/to/Example.proj",
plist_path: "path/to/Info.plist",
display_name: "MyApp-Beta"
)',
'update_info_plist( # Advanced processing: find URL scheme for particular key and replace value
xcodeproj: "path/to/Example.proj",
plist_path: "path/to/Info.plist",
block: proc do |plist|
urlScheme = plist["CFBundleURLTypes"].find{|scheme| scheme["CFBundleURLName"] == "com.acme.default-url-handler"}
urlScheme[:CFBundleURLSchemes] = ["acme-production"]
end
)'
]
end
def self.category
:project
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb | fastlane/lib/fastlane/actions/get_managed_play_store_publishing_rights.rb | module Fastlane
module Actions
class GetManagedPlayStorePublishingRightsAction < Action
def self.run(params)
unless params[:json_key] || params[:json_key_data]
UI.important("To not be asked about this value, you can specify it using 'json_key'")
json_key_path = UI.input("The service account json file used to authenticate with Google: ")
json_key_path = File.expand_path(json_key_path)
UI.user_error!("Could not find service account json file at path '#{json_key_path}'") unless File.exist?(json_key_path)
params[:json_key] = json_key_path
end
FastlaneCore::PrintTable.print_values(
config: params,
mask_keys: [:json_key_data],
title: "Summary for get_managed_play_store_publishing_rights"
)
if (keyfile = params[:json_key])
json_key_data = File.open(keyfile, 'rb').read
else
json_key_data = params[:json_key_data]
end
# Login
credentials = JSON.parse(json_key_data)
callback_uri = 'https://fastlane.github.io/managed_google_play-callback/callback.html'
require 'addressable/uri'
continueUrl = Addressable::URI.encode(callback_uri)
uri = "https://play.google.com/apps/publish/delegatePrivateApp?service_account=#{credentials['client_email']}&continueUrl=#{continueUrl}"
UI.message("To obtain publishing rights for custom apps on Managed Play Store, open the following URL and log in:")
UI.message("")
UI.important(uri)
UI.message("([Cmd/Ctrl] + [Left click] lets you open this URL in many consoles/terminals/shells)")
UI.message("")
UI.message("After successful login you will be redirected to a page which outputs some information that is required for usage of the `create_app_on_managed_play_store` action.")
return uri
end
def self.description
"Obtain publishing rights for custom apps on Managed Google Play Store"
end
def self.authors
["janpio"]
end
def self.return_value
"An URI to obtain publishing rights for custom apps on Managed Play Store"
end
def self.details
[
'If you haven\'t done so before, start by following the first two steps of Googles ["Get started with custom app publishing"](https://developers.google.com/android/work/play/custom-app-api/get-started) -> ["Preliminary setup"](https://developers.google.com/android/work/play/custom-app-api/get-started#preliminary_setup) instructions:',
'"[Enable the Google Play Custom App Publishing API](https://developers.google.com/android/work/play/custom-app-api/get-started#enable_the_google_play_custom_app_publishing_api)" and "[Create a service account](https://developers.google.com/android/work/play/custom-app-api/get-started#create_a_service_account)".',
'You need the "service account\'s private key file" to continue.',
'Run the action and supply the "private key file" to it as the `json_key` parameter. The command will output a URL to visit. After logging in you are redirected to a page that outputs your "Developer Account ID" - take note of that, you will need it to be able to use [`create_app_on_managed_play_store`](https://docs.fastlane.tools/actions/create_app_on_managed_play_store/).'
].join("\n")
end
def self.example_code
[
'get_managed_play_store_publishing_rights(
json_key: "path/to/your/json/key/file"
)
# it is probably easier to execute this action directly in the command line:
# $ fastlane run get_managed_play_store_publishing_rights'
]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :json_key,
env_name: "SUPPLY_JSON_KEY",
short_option: "-j",
conflicting_options: [:json_key_data],
optional: true, # optional until it is possible specify either json_key OR json_key_data are required
description: "The path to a file containing service account JSON, used to authenticate with Google",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
end),
FastlaneCore::ConfigItem.new(key: :json_key_data,
env_name: "SUPPLY_JSON_KEY_DATA",
short_option: "-c",
conflicting_options: [:json_key],
optional: true,
description: "The raw service account JSON data used to authenticate with Google",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
default_value_dynamic: true,
verify_block: proc do |value|
begin
JSON.parse(value)
rescue JSON::ParserError
UI.user_error!("Could not parse service account json: JSON::ParseError")
end
end)
]
end
def self.is_supported?(platform)
[:android].include?(platform)
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/add_extra_platforms.rb | fastlane/lib/fastlane/actions/add_extra_platforms.rb | module Fastlane
module Actions
class AddExtraPlatformsAction < Action
def self.run(params)
UI.verbose("Before injecting extra platforms: #{Fastlane::SupportedPlatforms.all}")
Fastlane::SupportedPlatforms.extra = params[:platforms]
UI.verbose("After injecting extra platforms (#{params[:platforms]})...: #{Fastlane::SupportedPlatforms.all}")
end
def self.description
"Modify the default list of supported platforms"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :platforms,
optional: false,
type: Array,
default_value: "",
description: "The optional extra platforms to support")
]
end
def self.authors
["lacostej"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'add_extra_platforms(
platforms: [:windows, :neogeo]
)'
]
end
def self.category
:misc
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/danger.rb | fastlane/lib/fastlane/actions/danger.rb | module Fastlane
module Actions
class DangerAction < Action
def self.run(params)
Actions.verify_gem!('danger')
cmd = []
cmd << 'bundle exec' if params[:use_bundle_exec] && shell_out_should_use_bundle_exec?
cmd << 'danger'
cmd << '--verbose' if params[:verbose]
danger_id = params[:danger_id]
dangerfile = params[:dangerfile]
base = params[:base]
head = params[:head]
pr = params[:pr]
cmd << "--danger_id=#{danger_id}" if danger_id
cmd << "--dangerfile=#{dangerfile}" if dangerfile
cmd << "--fail-on-errors=true" if params[:fail_on_errors]
cmd << "--fail-if-no-pr=true" if params[:fail_if_no_pr]
cmd << "--new-comment" if params[:new_comment]
cmd << "--remove-previous-comments" if params[:remove_previous_comments]
cmd << "--base=#{base}" if base
cmd << "--head=#{head}" if head
cmd << "pr #{pr}" if pr
ENV['DANGER_GITHUB_API_TOKEN'] = params[:github_api_token] if params[:github_api_token]
ENV['DANGER_GITHUB_HOST'] = params[:github_enterprise_host] if params[:github_enterprise_host]
ENV['DANGER_GITHUB_API_BASE_URL'] = params[:github_enterprise_api_base_url] if params[:github_enterprise_api_base_url]
Actions.sh(cmd.join(' '))
end
def self.description
"Runs `danger` for the project"
end
def self.details
[
"Formalize your Pull Request etiquette.",
"More information: [https://github.com/danger/danger](https://github.com/danger/danger)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :use_bundle_exec,
env_name: "FL_DANGER_USE_BUNDLE_EXEC",
description: "Use bundle exec when there is a Gemfile presented",
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: "FL_DANGER_VERBOSE",
description: "Show more debugging information",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :danger_id,
env_name: "FL_DANGER_ID",
description: "The identifier of this Danger instance",
optional: true),
FastlaneCore::ConfigItem.new(key: :dangerfile,
env_name: "FL_DANGER_DANGERFILE",
description: "The location of your Dangerfile",
optional: true),
FastlaneCore::ConfigItem.new(key: :github_api_token,
env_name: "FL_DANGER_GITHUB_API_TOKEN",
description: "GitHub API token for danger",
sensitive: true,
code_gen_sensitive: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :github_enterprise_host,
env_name: "FL_DANGER_GITHUB_ENTERPRISE_HOST",
description: "GitHub host URL for GitHub Enterprise",
sensitive: true,
code_gen_sensitive: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :github_enterprise_api_base_url,
env_name: "FL_DANGER_GITHUB_ENTERPRISE_API_BASE_URL",
description: "GitHub API base URL for GitHub Enterprise",
sensitive: true,
code_gen_sensitive: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :fail_on_errors,
env_name: "FL_DANGER_FAIL_ON_ERRORS",
description: "Should always fail the build process, defaults to false",
type: Boolean,
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :new_comment,
env_name: "FL_DANGER_NEW_COMMENT",
description: "Makes Danger post a new comment instead of editing its previous one",
type: Boolean,
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :remove_previous_comments,
env_name: "FL_DANGER_REMOVE_PREVIOUS_COMMENT",
description: "Makes Danger remove all previous comment and create a new one in the end of the list",
type: Boolean,
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :base,
env_name: "FL_DANGER_BASE",
description: "A branch/tag/commit to use as the base of the diff. [master|dev|stable]",
optional: true),
FastlaneCore::ConfigItem.new(key: :head,
env_name: "FL_DANGER_HEAD",
description: "A branch/tag/commit to use as the head. [master|dev|stable]",
optional: true),
FastlaneCore::ConfigItem.new(key: :pr,
env_name: "FL_DANGER_PR",
description: "Run danger on a specific pull request. e.g. \"https://github.com/danger/danger/pull/518\"",
optional: true),
FastlaneCore::ConfigItem.new(key: :fail_if_no_pr,
env_name: "FL_DANGER_FAIL_IF_NO_PR",
description: "Fail Danger execution if no PR is found",
type: Boolean,
default_value: false)
]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'danger',
'danger(
danger_id: "unit-tests",
dangerfile: "tests/MyOtherDangerFile",
github_api_token: ENV["GITHUB_API_TOKEN"],
verbose: true
)'
]
end
def self.category
:misc
end
def self.authors
["KrauseFx"]
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugins.rb | fastlane/lib/fastlane/plugins/plugins.rb | require 'fileutils'
require 'erb'
require 'find'
require 'fastlane/plugins/plugin_info'
require 'fastlane/plugins/plugin_generator'
require 'fastlane/plugins/plugin_generator_ui'
require 'fastlane/plugins/plugin_info_collector'
require 'fastlane/plugins/plugin_manager'
require 'fastlane/plugins/plugin_search'
require 'fastlane/plugins/plugin_fetcher'
require 'fastlane/plugins/plugin_update_manager'
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_info.rb | fastlane/lib/fastlane/plugins/plugin_info.rb | module Fastlane
class PluginInfo
attr_reader :plugin_name
attr_reader :author
attr_reader :gem_name
attr_reader :email
attr_reader :summary
attr_reader :details
def initialize(plugin_name, author, email, summary, details)
@plugin_name = plugin_name
@author = author
@email = email
@summary = summary
@details = details
end
def gem_name
"#{Fastlane::PluginManager::FASTLANE_PLUGIN_PREFIX}#{plugin_name}"
end
def require_path
gem_name.tr('-', '/')
end
def actions_path
File.join(require_path, 'actions')
end
def helper_path
File.join(require_path, 'helper')
end
# Used to expose a local binding for use in ERB templating
#
# rubocop:disable Naming/AccessorMethodName
def get_binding
binding
end
# rubocop:enable Naming/AccessorMethodName
def ==(other)
@plugin_name == other.plugin_name &&
@author == other.author &&
@email == other.email &&
@summary == other.summary
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_manager.rb | fastlane/lib/fastlane/plugins/plugin_manager.rb | require "fastlane/cli_tools_distributor"
module Fastlane
class PluginManager
require "bundler"
PLUGINFILE_NAME = "Pluginfile".freeze
DEFAULT_GEMFILE_PATH = "Gemfile".freeze
AUTOGENERATED_LINE = "# Autogenerated by fastlane\n#\n# Ensure this file is checked in to source control!\n\n"
GEMFILE_SOURCE_LINE = "source \"https://rubygems.org\"\n"
FASTLANE_PLUGIN_PREFIX = "fastlane-plugin-"
TROUBLESHOOTING_URL = "https://docs.fastlane.tools/plugins/plugins-troubleshooting/"
#####################################################
# @!group Reading the files and their paths
#####################################################
def gemfile_path
# This is pretty important, since we don't know what kind of
# Gemfile the user has (e.g. Gemfile, gems.rb, or custom env variable)
Bundler::SharedHelpers.default_gemfile.to_s
rescue Bundler::GemfileNotFound
nil
end
def pluginfile_path
if FastlaneCore::FastlaneFolder.path
return File.join(FastlaneCore::FastlaneFolder.path, PLUGINFILE_NAME)
else
return nil
end
end
def gemfile_content
File.read(gemfile_path) if gemfile_path && File.exist?(gemfile_path)
end
def pluginfile_content
File.read(pluginfile_path) if pluginfile_path && File.exist?(pluginfile_path)
end
#####################################################
# @!group Helpers
#####################################################
def self.plugin_prefix
FASTLANE_PLUGIN_PREFIX
end
def self.to_gem_name(plugin_name)
plugin_name.start_with?(plugin_prefix) ? plugin_name : (plugin_prefix + plugin_name)
end
# Returns an array of gems that are added to the Gemfile or Pluginfile
def available_gems
return [] unless gemfile_path
dsl = Bundler::Dsl.evaluate(gemfile_path, nil, true)
return dsl.dependencies.map(&:name)
end
# Returns an array of fastlane plugins that are added to the Gemfile or Pluginfile
# The returned array contains the string with their prefixes (e.g. fastlane-plugin-xcversion)
def available_plugins
available_gems.keep_if do |current|
current.start_with?(self.class.plugin_prefix)
end
end
# Check if a plugin is added as dependency to either the
# Gemfile or the Pluginfile
def plugin_is_added_as_dependency?(plugin_name)
UI.user_error!("fastlane plugins must start with '#{self.class.plugin_prefix}' string") unless plugin_name.start_with?(self.class.plugin_prefix)
return available_plugins.include?(plugin_name)
end
#####################################################
# @!group Modifying dependencies
#####################################################
def add_dependency(plugin_name)
UI.user_error!("fastlane is not setup for this project, make sure you have a fastlane folder") unless pluginfile_path
plugin_name = self.class.plugin_prefix + plugin_name unless plugin_name.start_with?(self.class.plugin_prefix)
if plugin_name.gsub(self.class.plugin_prefix, '').include?("-")
# e.g. "fastlane-plugin-ya_tu-sabes" (which is invalid)
UI.user_error!("Plugin name must not contain a '-', did you mean '_'?")
end
unless plugin_is_added_as_dependency?(plugin_name)
content = pluginfile_content || AUTOGENERATED_LINE
unless content.end_with?("\n")
content += "\n"
end
line_to_add = "gem '#{plugin_name}'"
line_to_add += gem_dependency_suffix(plugin_name)
UI.verbose("Adding line: #{line_to_add}")
content += "#{line_to_add}\n"
File.write(pluginfile_path, content)
UI.success("Plugin '#{plugin_name}' was added to '#{pluginfile_path}'")
end
# We do this *after* creating the Plugin file
# Since `bundle exec` would be broken if something fails on the way
ensure_plugins_attached!
true
end
# Get a suffix (e.g. `path` or `git` for the gem dependency)
def gem_dependency_suffix(plugin_name)
return "" unless self.class.fetch_gem_info_from_rubygems(plugin_name).nil?
selection_git_url = "Git URL"
selection_path = "Local Path"
selection_rubygems = "RubyGems.org ('#{plugin_name}' seems to not be available there)"
selection_gem_server = "Other Gem Server"
selection = UI.select(
"Seems like the plugin is not available on RubyGems, what do you want to do?",
[selection_git_url, selection_path, selection_rubygems, selection_gem_server]
)
if selection == selection_git_url
git_url = UI.input('Please enter the URL to the plugin, including the protocol (e.g. https:// or git://)')
return ", git: '#{git_url}'"
elsif selection == selection_path
path = UI.input('Please enter the relative path to the plugin you want to use. It has to point to the directory containing the .gemspec file')
return ", path: '#{path}'"
elsif selection == selection_rubygems
return ""
elsif selection == selection_gem_server
source_url = UI.input('Please enter the gem source URL which hosts the plugin you want to use, including the protocol (e.g. https:// or git://)')
return ", source: '#{source_url}'"
else
UI.user_error!("Unknown input #{selection}")
end
end
# Modify the user's Gemfile to load the plugins
def attach_plugins_to_gemfile!(path_to_gemfile)
content = gemfile_content || (AUTOGENERATED_LINE + GEMFILE_SOURCE_LINE)
# We have to make sure fastlane is also added to the Gemfile, since we now use
# bundler to run fastlane
content += "\ngem 'fastlane'\n" unless available_gems.include?('fastlane')
content += "\n#{self.class.code_to_attach}\n"
File.write(path_to_gemfile, content)
end
#####################################################
# @!group Accessing RubyGems
#####################################################
def self.fetch_gem_info_from_rubygems(gem_name)
require 'json'
require 'open-uri'
url = "https://rubygems.org/api/v1/gems/#{gem_name}.json"
begin
JSON.parse(URI.open(url).read)
rescue
nil
end
end
#####################################################
# @!group Installing and updating dependencies
#####################################################
# Warning: This will exec out
# This is necessary since the user might be prompted for their password
def install_dependencies!
# Using puts instead of `UI` to have the same style as the `echo`
puts("Installing plugin dependencies...")
ensure_plugins_attached!
with_clean_bundler_env do
cmd = "bundle install"
cmd << " --quiet" unless FastlaneCore::Globals.verbose?
cmd << " && bundle exec fastlane generate_swift" if FastlaneCore::FastlaneFolder.swift?
cmd << " && echo 'Successfully installed plugins'"
UI.command(cmd) if FastlaneCore::Globals.verbose?
exec(cmd)
end
end
# Warning: This will exec out
# This is necessary since the user might be prompted for their password
def update_dependencies!
puts("Updating plugin dependencies...")
ensure_plugins_attached!
plugins = available_plugins
if plugins.empty?
UI.user_error!("No plugins are installed")
end
with_clean_bundler_env do
cmd = "bundle update"
cmd << " #{plugins.join(' ')}"
cmd << " --quiet" unless FastlaneCore::Globals.verbose?
cmd << " && bundle exec fastlane generate_swift" if FastlaneCore::FastlaneFolder.swift?
cmd << " && echo 'Successfully updated plugins'"
UI.command(cmd) if FastlaneCore::Globals.verbose?
exec(cmd)
end
end
def with_clean_bundler_env
# There is an interesting problem with using exec to call back into Bundler
# The `bundle ________` command that we exec, inherits all of the Bundler
# state we'd already built up during this run. That was causing the command
# to fail, telling us to install the Gem we'd just introduced, even though
# that is exactly what we are trying to do!
#
# Bundler.with_clean_env solves this problem by resetting Bundler state before the
# exec'd call gets merged into this process.
Bundler.with_original_env do
yield if block_given?
end
end
#####################################################
# @!group Initial setup
#####################################################
def setup
UI.important("It looks like fastlane plugins are not yet set up for this project.")
path_to_gemfile = gemfile_path || DEFAULT_GEMFILE_PATH
if gemfile_content.to_s.length > 0
UI.important("fastlane will modify your existing Gemfile at path '#{path_to_gemfile}'")
else
UI.important("fastlane will create a new Gemfile at path '#{path_to_gemfile}'")
end
UI.important("This change is necessary for fastlane plugins to work")
unless UI.confirm("Should fastlane modify the Gemfile at path '#{path_to_gemfile}' for you?")
UI.important("Please add the following code to '#{path_to_gemfile}':")
puts("")
puts(self.class.code_to_attach.magenta) # we use `puts` instead of `UI` to make it easier to copy and paste
UI.user_error!("Please update '#{path_to_gemfile} and run fastlane again")
end
attach_plugins_to_gemfile!(path_to_gemfile)
UI.success("Successfully modified '#{path_to_gemfile}'")
end
# The code required to load the Plugins file
def self.code_to_attach
if FastlaneCore::FastlaneFolder.path
fastlane_folder_name = File.basename(FastlaneCore::FastlaneFolder.path)
else
fastlane_folder_name = "fastlane"
end
"plugins_path = File.join(File.dirname(__FILE__), '#{fastlane_folder_name}', '#{PluginManager::PLUGINFILE_NAME}')\n" \
"eval_gemfile(plugins_path) if File.exist?(plugins_path)"
end
# Makes sure, the user's Gemfile actually loads the Plugins file
def plugins_attached?
gemfile_path && gemfile_content.include?(PluginManager::PLUGINFILE_NAME)
end
def ensure_plugins_attached!
return if plugins_attached?
self.setup
end
#####################################################
# @!group Requiring the plugins
#####################################################
# Iterate over all available plugins
# which follow the naming convention
# fastlane-plugin-[plugin_name]
# This will make sure to load the action
# and all its helpers
def load_plugins(print_table: true)
UI.verbose("Checking if there are any plugins that should be loaded...")
loaded_plugins = false
available_plugins.each do |gem_name|
UI.verbose("Loading '#{gem_name}' plugin")
begin
# BEFORE requiring the gem, we get a list of loaded actions
# This way we can check inside `store_plugin_reference` if
# any actions were overwritten
self.loaded_fastlane_actions.concat(Fastlane::Actions.constants)
FastlaneRequire.install_gem_if_needed(gem_name: gem_name, require_gem: true)
store_plugin_reference(gem_name)
loaded_plugins = true
rescue StandardError, ScriptError => ex # some errors, like ScriptError are not caught unless explicitly
UI.error("Error loading plugin '#{gem_name}': #{ex}")
# We'll still add it to the table, to make the error
# much more visible and obvious
self.plugin_references[gem_name] = {
version_number: Fastlane::ActionCollector.determine_version(gem_name),
actions: []
}
end
end
if !loaded_plugins && self.pluginfile_content.to_s.include?(PluginManager.plugin_prefix)
UI.error("It seems like you wanted to load some plugins, however they couldn't be loaded")
UI.error("Please follow the troubleshooting guide: #{TROUBLESHOOTING_URL}")
end
skip_print_plugin_info = self.plugin_references.empty? || CLIToolsDistributor.running_version_command? || !print_table
# We want to avoid printing output other than the version number if we are running `fastlane -v`
print_plugin_information(self.plugin_references) unless skip_print_plugin_info
end
# Prints a table all the plugins that were loaded
def print_plugin_information(references)
no_action_found = false
rows = references.collect do |current|
if current[1][:actions].empty?
# Something is wrong with this plugin, no available actions
no_action_found = true
[current[0].red, current[1][:version_number], "No actions found".red]
else
[current[0], current[1][:version_number], current[1][:actions].join(", ")]
end
end
require 'terminal-table'
puts(Terminal::Table.new({
rows: FastlaneCore::PrintTable.transform_output(rows),
title: "Used plugins".green,
headings: ["Plugin", "Version", "Action"]
}))
puts("")
if no_action_found
puts("[!] No actions were found while loading one or more plugins".red)
puts(" Please use `bundle exec fastlane` with plugins".red)
puts(" More info - https://docs.fastlane.tools/plugins/using-plugins/#run-with-plugins".red)
puts("")
end
end
#####################################################
# @!group Reference between plugins to actions
#####################################################
# Connection between plugins and their actions
# Example value of plugin_references
# => {"fastlane-plugin-ruby" => {
# version_number: "0.1.0",
# actions: [:rspec, :rubocop]
# }}
def plugin_references
@plugin_references ||= {}
end
# Contains an array of symbols for the action classes
def loaded_fastlane_actions
@fastlane_actions ||= []
end
def store_plugin_reference(gem_name)
module_name = gem_name.gsub(PluginManager.plugin_prefix, '').fastlane_class
# We store a collection of the imported plugins
# This way we can tell which action came from what plugin
# (a plugin may contain any number of actions)
version_number = Fastlane::ActionCollector.determine_version(gem_name)
references = Fastlane.const_get(module_name).all_classes.collect do |path|
next unless File.dirname(path).include?("/actions") # we only want to match actions
File.basename(path).gsub(".rb", "").gsub(/_action$/, '').to_sym # the _action is optional
end
references.compact!
# Check if this overwrites a built-in action and
# show a warning if that's the case
references.each do |current_ref|
# current_ref is a symbol, e.g. :emoji_fetcher
class_name = (current_ref.to_s.fastlane_class + 'Action').to_sym
if self.loaded_fastlane_actions.include?(class_name)
UI.important("Plugin '#{module_name}' overwrites already loaded action '#{current_ref}'")
end
end
self.plugin_references[gem_name] = {
version_number: version_number,
actions: references
}
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_generator.rb | fastlane/lib/fastlane/plugins/plugin_generator.rb | module Fastlane
# Generates a sample plugin by traversing a template directory structure
# and reproducing it in a destination location. At the same time, it runs
# variable replacements on directory names, file names, and runs ERB
# templating on file contents whose names end with '.erb'.
#
# Directory and file name variable replacements are defined like: %gem_name%
# The text between the percent signs will be used to invoke an accessor
# method on the PluginInfo object to get the replacement value.
class PluginGenerator
def initialize(ui: PluginGeneratorUI.new,
info_collector: PluginInfoCollector.new(ui),
template_root: File.join(File.dirname(__FILE__), 'template'),
dest_root: FileUtils.pwd)
@ui = ui
@info_collector = info_collector
@template_root = template_root
@dest_root = dest_root
end
# entry point
def generate(plugin_name = nil)
plugin_info = @info_collector.collect_info(plugin_name)
# Traverse all the files and directories in the template root,
# handling each in turn
Find.find(@template_root) do |template_path|
handle_template_path(template_path, plugin_info)
end
@ui.success("\nYour plugin was successfully generated at #{plugin_info.gem_name}/ 🚀")
@ui.success("\nTo get started with using this plugin, run")
@ui.message("\n fastlane add_plugin #{plugin_info.plugin_name}\n")
@ui.success("\nfrom a fastlane-enabled app project directory and provide the following as the path:")
@ui.message("\n #{File.expand_path(plugin_info.gem_name)}\n\n")
end
def handle_template_path(template_path, plugin_info)
dest_path = derive_dest_path(template_path, plugin_info)
if File.directory?(template_path)
FileUtils.mkdir_p(dest_path)
else
copy_file(template_path, dest_path, plugin_info)
end
end
def derive_dest_path(template_path, plugin_info)
relative_template_path = template_path.gsub(@template_root, '')
replaced_path = replace_path_variables(relative_template_path, plugin_info)
File.join(@dest_root, plugin_info.gem_name, replaced_path)
end
def copy_file(template_path, dest_path, plugin_info)
contents = File.read(template_path)
if dest_path.end_with?('.erb')
contents = ERB.new(contents).result(plugin_info.get_binding)
dest_path = dest_path[0...-4] # Remove the .erb suffix
end
File.write(dest_path, contents)
end
# Path variables can be defined like: %gem_name%
#
# The text between the percent signs will be used to invoke an accessor
# method on the PluginInfo object to be the replacement value.
def replace_path_variables(template_path, plugin_info)
path = template_path.dup
loop do
replacement_variable_regexp = /%([\w\-]*)%/
match = replacement_variable_regexp.match(path)
break unless match
replacement_value = plugin_info.send(match[1].to_sym)
path.gsub!(replacement_variable_regexp, replacement_value)
end
path
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_update_manager.rb | fastlane/lib/fastlane/plugins/plugin_update_manager.rb | module Fastlane
# Alert the user when updates for plugins are available
class PluginUpdateManager
def self.start_looking_for_updates
return if FastlaneCore::Env.truthy?("FASTLANE_SKIP_UPDATE_CHECK")
Thread.new do
self.plugin_references.each do |plugin_name, current_plugin|
begin
self.server_results[plugin_name] = fetch_latest_version(plugin_name)
rescue
end
end
end
end
def self.show_update_status
return if FastlaneCore::Env.truthy?("FASTLANE_SKIP_UPDATE_CHECK")
# We set self.server_results to be nil
# this way the table is not printed twice
# (next to the summary table or when an exception happens)
return unless self.server_results.count > 0
rows = []
self.plugin_references.each do |plugin_name, current_plugin|
latest_version = self.server_results[plugin_name]
next if latest_version.nil?
current_version = Gem::Version.new(current_plugin[:version_number])
next if current_version >= latest_version
rows << [
plugin_name.gsub(PluginManager.plugin_prefix, ''),
current_version.to_s.red,
latest_version.to_s.green
]
end
if rows.empty?
UI.verbose("All plugins are up to date")
return
end
require 'terminal-table'
puts(Terminal::Table.new({
rows: FastlaneCore::PrintTable.transform_output(rows),
title: "Plugin updates available".yellow,
headings: ["Plugin", "Your Version", "Latest Version"]
}))
UI.message("To update all plugins, just run")
UI.command "bundle exec fastlane update_plugins"
puts('')
@server_results = nil
end
def self.plugin_references
Fastlane.plugin_manager.plugin_references
end
def self.fetch_latest_version(gem_name)
Gem::Version.new(PluginManager.fetch_gem_info_from_rubygems(gem_name)["version"])
rescue
nil
end
def self.server_results
@server_results ||= {}
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_info_collector.rb | fastlane/lib/fastlane/plugins/plugin_info_collector.rb | module Fastlane
class PluginInfoCollector
def initialize(ui = PluginGeneratorUI.new)
@ui = ui
end
def collect_info(initial_name = nil)
plugin_name = collect_plugin_name(initial_name)
author = collect_author(detect_author)
email = collect_email(detect_email)
summary = collect_summary
details = collect_details
PluginInfo.new(plugin_name, author, email, summary, details)
end
#
# Plugin name
#
def collect_plugin_name(initial_name = nil)
plugin_name = initial_name
first_try = true
loop do
if !first_try || plugin_name.to_s.empty?
plugin_name = @ui.input("What would you like to be the name of your plugin?")
end
first_try = false
unless plugin_name_valid?(plugin_name)
fixed_name = fix_plugin_name(plugin_name)
if plugin_name_valid?(fixed_name)
plugin_name = fixed_name if @ui.confirm("\nWould '#{fixed_name}' be okay to use for your plugin name?")
end
end
break if plugin_name_valid?(plugin_name)
gem_name = PluginManager.to_gem_name(plugin_name)
if gem_name_taken?(gem_name)
# Gem name is already taken on RubyGems
@ui.message("\nThe gem name '#{gem_name}' is already taken on RubyGems, please choose a different plugin name.")
else
# That's a naming error
@ui.message("\nPlugin names can only contain lowercase letters, numbers, and underscores")
@ui.message("and should not contain 'fastlane' or 'plugin'.")
end
end
plugin_name
end
def plugin_name_valid?(name)
# Only lowercase letters, numbers and underscores allowed
/^[a-z0-9_]+$/ =~ name &&
# Does not contain the words 'fastlane' or 'plugin' since those will become
# part of the gem name
[/fastlane/, /plugin/].none? { |regex| regex =~ name } &&
# Gem name isn't taken on RubyGems yet
!gem_name_taken?(PluginManager.to_gem_name(name))
end
# Checks if the gem name is still free on RubyGems
def gem_name_taken?(name)
require 'json'
require 'open-uri'
url = "https://rubygems.org/api/v1/gems/#{name}.json"
response = JSON.parse(URI.open(url).read)
return !!response['version']
rescue
false
end
# Applies a series of replacement rules to turn the requested plugin name into one
# that is acceptable, returning that suggestion
def fix_plugin_name(name)
name = name.to_s.downcase
fixes = {
/[\- ]/ => '_', # dashes and spaces become underscores
/[^a-z0-9_]/ => '', # anything other than lowercase letters, numbers and underscores is removed
/fastlane[_]?/ => '', # 'fastlane' or 'fastlane_' is removed
/plugin[_]?/ => '' # 'plugin' or 'plugin_' is removed
}
fixes.each do |regex, replacement|
name = name.gsub(regex, replacement)
end
name
end
#
# Author
#
def detect_author
git_name = Helper.backticks('git config --get user.name', print: FastlaneCore::Globals.verbose?).strip
return git_name.empty? ? nil : git_name
end
def collect_author(initial_author = nil)
return initial_author if author_valid?(initial_author)
author = nil
loop do
author = @ui.input("What is the plugin author's name?")
break if author_valid?(author)
@ui.message('An author name is required.')
end
author
end
def author_valid?(author)
!author.to_s.strip.empty?
end
#
# Email
#
def detect_email
git_email = Helper.backticks('git config --get user.email', print: FastlaneCore::Globals.verbose?).strip
return git_email.empty? ? nil : git_email
end
def collect_email(initial_email = nil)
return initial_email || @ui.input("What is the plugin author's email address?")
end
#
# Summary
#
def collect_summary
summary = nil
loop do
summary = @ui.input("Please enter a short summary of this fastlane plugin:")
break if summary_valid?(summary)
@ui.message('A summary is required.')
end
summary
end
def summary_valid?(summary)
!summary.to_s.strip.empty?
end
#
# Summary
#
def collect_details
return @ui.input("Please enter a detailed description of this fastlane plugin:").to_s
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_search.rb | fastlane/lib/fastlane/plugins/plugin_search.rb | module Fastlane
class PluginSearch
require 'terminal-table'
require 'word_wrap'
def self.print_plugins(search_query: nil)
if search_query
UI.message("Looking for fastlane plugins containing '#{search_query}'...")
else
UI.message("Listing all available fastlane plugins")
end
plugins = Fastlane::PluginFetcher.fetch_gems(search_query: search_query)
if plugins.empty?
UI.user_error!("Couldn't find any available fastlane plugins containing '#{search_query}'")
end
rows = plugins.collect do |current|
[
current.name.green,
WordWrap.ww(current.info, 50),
current.downloads
]
end
params = {
rows: FastlaneCore::PrintTable.transform_output(rows),
title: (search_query ? "fastlane plugins '#{search_query}'" : "Available fastlane plugins").green,
headings: ["Name", "Description", "Downloads"]
}
puts("")
puts(Terminal::Table.new(params))
puts("")
if plugins.count == 1
print_plugin_details(plugins.last)
end
end
def self.print_plugin_details(plugin)
UI.message("You can find more information for #{plugin.name} on #{plugin.homepage.green}")
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_generator_ui.rb | fastlane/lib/fastlane/plugins/plugin_generator_ui.rb | module Fastlane
class PluginGeneratorUI
def success(text)
puts(text.green)
end
def message(text)
puts(text)
end
def input(text)
UI.input(text)
end
def confirm(text)
UI.confirm(text)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/plugins/plugin_fetcher.rb | fastlane/lib/fastlane/plugins/plugin_fetcher.rb | module Fastlane
# Use the RubyGems API to get all fastlane plugins
class PluginFetcher
require 'fastlane_core'
require 'fastlane/plugins/plugin_manager'
# Returns an array of FastlanePlugin objects
def self.fetch_gems(search_query: nil)
require 'json'
require 'open-uri'
page = 1
plugins = []
loop do
url = "https://rubygems.org/api/v1/search.json?query=#{PluginManager.plugin_prefix}&page=#{page}"
FastlaneCore::UI.verbose("RubyGems API Request: #{url}")
results = JSON.parse(URI.open(url).read)
break if results.count == 0
plugins += results.collect do |current|
FastlanePlugin.new(current)
end
page += 1
end
return plugins if search_query.to_s.length == 0
plugins.keep_if do |current|
current.full_name.include?(search_query) or current.info.include?(search_query)
end
return plugins
end
end
class FastlanePlugin
attr_accessor :full_name
attr_accessor :name
attr_accessor :downloads
attr_accessor :info
attr_accessor :homepage
def initialize(hash)
self.full_name = hash["name"]
self.name = self.full_name.gsub(PluginManager.plugin_prefix, '')
self.downloads = hash["downloads"]
self.info = hash["info"]
self.homepage = hash["homepage_uri"]
end
def linked_title
return "`#{name}`" if homepage.to_s.length == 0
return "[#{name}](#{homepage})"
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/xcodes_helper.rb | fastlane/lib/fastlane/helper/xcodes_helper.rb | module Fastlane
module Helper
class XcodesHelper
def self.read_xcode_version_file
xcode_version_paths = Dir.glob(".xcode-version")
if xcode_version_paths.first
return File.read(xcode_version_paths.first).strip
end
return nil
end
def self.find_xcodes_binary_path
`which xcodes`.strip
end
module Verify
def self.requirement(req)
UI.user_error!("Version must be specified") if req.nil? || req.to_s.strip.size == 0
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/podspec_helper.rb | fastlane/lib/fastlane/helper/podspec_helper.rb | module Fastlane
module Helper
class PodspecHelper
attr_accessor :path
attr_accessor :podspec_content
attr_accessor :version_regex
attr_accessor :version_match
attr_accessor :version_value
def initialize(path = nil, require_variable_prefix = true)
version_var_name = 'version'
variable_prefix = require_variable_prefix ? /\w\./ : //
@version_regex = /^(?<begin>[^#]*#{variable_prefix}#{version_var_name}\s*=\s*['"])(?<value>(?<major>[0-9]+)(\.(?<minor>[0-9]+))?(\.(?<patch>[0-9]+))?(?<appendix>(\.[0-9]+)*)?(-(?<prerelease>(.+)))?)(?<end>['"])/i
return unless (path || '').length > 0
UI.user_error!("Could not find podspec file at path '#{path}'") unless File.exist?(path)
@path = File.expand_path(path)
podspec_content = File.read(path)
parse(podspec_content)
end
def parse(podspec_content)
@podspec_content = podspec_content
@version_match = @version_regex.match(@podspec_content)
UI.user_error!("Could not find version in podspec content '#{@podspec_content}'") if @version_match.nil?
@version_value = @version_match[:value]
end
def bump_version(bump_type)
UI.user_error!("Do not support bump of 'appendix', please use `update_version_appendix(appendix)` instead") if bump_type == 'appendix'
major = version_match[:major].to_i
minor = version_match[:minor].to_i || 0
patch = version_match[:patch].to_i || 0
case bump_type
when 'patch'
patch += 1
when 'minor'
minor += 1
patch = 0
when 'major'
major += 1
minor = 0
patch = 0
end
@version_value = "#{major}.#{minor}.#{patch}"
end
def update_version_appendix(appendix = nil)
new_appendix = appendix || @version_value[:appendix]
return if new_appendix.nil?
new_appendix = new_appendix.sub(".", "") if new_appendix.start_with?(".")
major = version_match[:major].to_i
minor = version_match[:minor].to_i || 0
patch = version_match[:patch].to_i || 0
@version_value = "#{major}.#{minor}.#{patch}.#{new_appendix}"
end
def update_podspec(version = nil)
new_version = version || @version_value
updated_podspec_content = @podspec_content.gsub(@version_regex, "#{@version_match[:begin]}#{new_version}#{@version_match[:end]}")
File.open(@path, "w") { |file| file.puts(updated_podspec_content) } unless Helper.test?
updated_podspec_content
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/gradle_helper.rb | fastlane/lib/fastlane/helper/gradle_helper.rb | module Fastlane
module Helper
class GradleTask
attr_accessor :title
attr_accessor :description
def initialize(title: nil, description: nil)
self.title = title
self.description = description
end
end
class GradleHelper
# Path to the gradle script
attr_accessor :gradle_path
# Read-only path to the shell-escaped gradle script, suitable for use in shell commands
attr_reader :escaped_gradle_path
# All the available tasks
attr_accessor :tasks
def initialize(gradle_path: nil)
self.gradle_path = gradle_path
end
# Run a certain action
def trigger(task: nil, flags: nil, serial: nil, print_command: true, print_command_output: true)
android_serial = (serial != "") ? "ANDROID_SERIAL=#{serial}" : nil
command = [android_serial, escaped_gradle_path, task, flags].compact.join(" ")
Action.sh(command, print_command: print_command, print_command_output: print_command_output)
end
def task_available?(task)
load_all_tasks
return tasks.collect(&:title).include?(task)
end
def gradle_path=(gradle_path)
@gradle_path = gradle_path
@escaped_gradle_path = gradle_path.shellescape
end
private
def load_all_tasks
self.tasks = []
command = [escaped_gradle_path, "tasks", "--console=plain"].join(" ")
output = Action.sh(command, print_command: false, print_command_output: false)
output.split("\n").each do |line|
if (result = line.match(/(\w+)\s\-\s([\w\s]+)/))
self.tasks << GradleTask.new(title: result[1], description: result[2])
end
end
self.tasks
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/xcodeproj_helper.rb | fastlane/lib/fastlane/helper/xcodeproj_helper.rb | module Fastlane
module Helper
class XcodeprojHelper
DEPENDENCY_MANAGER_DIRS = ['Pods', 'Carthage'].freeze
def self.find(dir)
xcodeproj_paths = Dir[File.expand_path(File.join(dir, '**/*.xcodeproj'))]
xcodeproj_paths.reject { |path| %r{/(#{DEPENDENCY_MANAGER_DIRS.join('|')})/.*.xcodeproj} =~ path }
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/lane_helper.rb | fastlane/lib/fastlane/helper/lane_helper.rb | module Fastlane
module Helper
class LaneHelper
def self.current_platform
return Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::PLATFORM_NAME]
end
def self.current_lane
return Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::LANE_NAME]
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/s3_client_helper.rb | fastlane/lib/fastlane/helper/s3_client_helper.rb | require 'aws-sdk-s3'
module Fastlane
module Helper
class S3ClientHelper
attr_reader :access_key
attr_reader :region
def initialize(access_key: nil, secret_access_key: nil, region: nil, s3_client: nil)
@access_key = access_key
@secret_access_key = secret_access_key
@region = region
@client = s3_client
end
def list_buckets
return client.list_buckets
end
def upload_file(bucket_name, file_name, file_data, acl)
bucket = find_bucket!(bucket_name)
details = {
acl: acl,
key: file_name,
body: file_data
}
obj = bucket.put_object(details)
# When you enable versioning on a S3 bucket,
# writing to an object will create an object version
# instead of replacing the existing object.
# http://docs.aws.amazon.com/AWSRubySDK/latest/AWS/S3/ObjectVersion.html
if obj.kind_of?(Aws::S3::ObjectVersion)
obj = obj.object
end
# Return public url
obj.public_url.to_s
end
def download_file(bucket_name, key, destination_path)
Aws::S3::TransferManager.new(client: client).download_file(destination_path, bucket: bucket_name, key: key)
end
def delete_file(bucket_name, file_name)
bucket = find_bucket!(bucket_name)
file = bucket.object(file_name)
file.delete
end
def find_bucket!(bucket_name)
bucket = Aws::S3::Bucket.new(bucket_name, client: client)
raise "Bucket '#{bucket_name}' not found" unless bucket.exists?
return bucket
end
private
attr_reader :secret_access_key
def client
@client ||= Aws::S3::Client.new(
{
region: region,
credentials: create_credentials
}.compact
)
end
def create_credentials
return nil if access_key.to_s.empty? || secret_access_key.to_s.empty?
Aws::Credentials.new(
access_key,
secret_access_key
)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/git_helper.rb | fastlane/lib/fastlane/helper/git_helper.rb | module Fastlane
module Actions
GIT_MERGE_COMMIT_FILTERING_OPTIONS = [:include_merges, :exclude_merges, :only_include_merges].freeze
module SharedValues
GIT_BRANCH_ENV_VARS = %w(GIT_BRANCH BRANCH_NAME TRAVIS_BRANCH BITRISE_GIT_BRANCH CI_BUILD_REF_NAME CI_COMMIT_REF_NAME WERCKER_GIT_BRANCH BUILDKITE_BRANCH APPCENTER_BRANCH CIRCLE_BRANCH).reject do |branch|
# Removing because tests break on CircleCI
Helper.test? && branch == "CIRCLE_BRANCH"
end.freeze
end
def self.git_log_between(pretty_format, from, to, merge_commit_filtering, date_format = nil, ancestry_path, app_path)
command = %w(git log)
command << "--pretty=#{pretty_format}"
command << "--date=#{date_format}" if date_format
command << '--ancestry-path' if ancestry_path
command << "#{from}...#{to}"
command << git_log_merge_commit_filtering_option(merge_commit_filtering)
command << app_path if app_path
# "*command" syntax expands "command" array into variable arguments, which
# will then be individually shell-escaped by Actions.sh.
Actions.sh(*command.compact, log: false).chomp
rescue
nil
end
def self.git_log_last_commits(pretty_format, commit_count, merge_commit_filtering, date_format = nil, ancestry_path, app_path)
command = %w(git log)
command << "--pretty=#{pretty_format}"
command << "--date=#{date_format}" if date_format
command << '--ancestry-path' if ancestry_path
command << '-n' << commit_count.to_s
command << git_log_merge_commit_filtering_option(merge_commit_filtering)
command << app_path if app_path
Actions.sh(*command.compact, log: false).chomp
rescue
nil
end
def self.last_git_tag_hash(tag_match_pattern = nil)
tag_pattern_param = tag_match_pattern ? "=#{tag_match_pattern}" : ''
Actions.sh('git', 'rev-list', "--tags#{tag_pattern_param}", '--max-count=1').chomp
rescue
nil
end
def self.last_git_tag_name(match_lightweight = true, tag_match_pattern = nil)
hash = last_git_tag_hash(tag_match_pattern)
# If hash is nil (command fails), "git describe" command below will still
# run and provide some output, although it's definitely not going to be
# anything reasonably expected. Bail out early.
return unless hash
command = %w(git describe)
command << '--tags' if match_lightweight
command << hash
command << '--match' if tag_match_pattern
command << tag_match_pattern if tag_match_pattern
Actions.sh(*command.compact, log: false).chomp
rescue
nil
end
def self.last_git_commit_dict
return nil if last_git_commit_formatted_with('%an').nil?
{
author: last_git_commit_formatted_with('%an'),
author_email: last_git_commit_formatted_with('%ae'),
message: last_git_commit_formatted_with('%B'),
commit_hash: last_git_commit_formatted_with('%H'),
abbreviated_commit_hash: last_git_commit_formatted_with('%h')
}
end
# Gets the last git commit information formatted into a String by the provided
# pretty format String. See the git-log documentation for valid format placeholders
def self.last_git_commit_formatted_with(pretty_format, date_format = nil)
command = %w(git log -1)
command << "--pretty=#{pretty_format}"
command << "--date=#{date_format}" if date_format
Actions.sh(*command.compact, log: false).chomp
rescue
nil
end
# @deprecated Use <tt>git_author_email</tt> instead
# Get the author email of the last git commit
# <b>DEPRECATED:</b> Use <tt>git_author_email</tt> instead.
def self.git_author
UI.deprecated('`git_author` is deprecated. Please use `git_author_email` instead.')
git_author_email
end
# Get the author email of the last git commit
def self.git_author_email
s = last_git_commit_formatted_with('%ae')
return s if s.to_s.length > 0
return nil
end
# Returns the unwrapped subject and body of the last commit
# <b>DEPRECATED:</b> Use <tt>last_git_commit_message</tt> instead.
def self.last_git_commit
UI.important('`last_git_commit` is deprecated. Please use `last_git_commit_message` instead.')
last_git_commit_message
end
# Returns the unwrapped subject and body of the last commit
def self.last_git_commit_message
s = (last_git_commit_formatted_with('%B') || "").strip
return s if s.to_s.length > 0
nil
end
# Get the hash of the last commit
def self.last_git_commit_hash(short)
format_specifier = short ? '%h' : '%H'
string = last_git_commit_formatted_with(format_specifier).to_s
return string unless string.empty?
return nil
end
# Returns the current git branch, or "HEAD" if it's not checked out to any branch
# Can be replaced using the environment variable `GIT_BRANCH`
# unless `FL_GIT_BRANCH_DONT_USE_ENV_VARS` is `true`
def self.git_branch
return self.git_branch_name_using_HEAD if FastlaneCore::Env.truthy?('FL_GIT_BRANCH_DONT_USE_ENV_VARS')
env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| FastlaneCore::Env.truthy?(env_var) }
ENV.fetch(env_name.to_s) do
self.git_branch_name_using_HEAD
end
end
# Returns the checked out git branch name or "HEAD" if you're in detached HEAD state
def self.git_branch_name_using_HEAD
# Rescues if not a git repo or no commits in a git repo
Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
rescue => err
UI.verbose("Error getting git branch: #{err.message}")
nil
end
# Returns the default git remote branch name
def self.git_remote_branch_name(remote_name)
# Rescues if not a git repo or no remote repo
if remote_name
Actions.sh("git remote show #{remote_name} | grep 'HEAD branch' | sed 's/.*: //'", log: false).chomp
else
# Query git for the current remote head
Actions.sh("variable=$(git remote) && git remote show $variable | grep 'HEAD branch' | sed 's/.*: //'", log: false).chomp
end
rescue => err
UI.verbose("Error getting git default remote branch: #{err.message}")
nil
end
private_class_method
def self.git_log_merge_commit_filtering_option(merge_commit_filtering)
case merge_commit_filtering
when :exclude_merges
"--no-merges"
when :only_include_merges
"--merges"
when :include_merges
nil
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/xcversion_helper.rb | fastlane/lib/fastlane/helper/xcversion_helper.rb | module Fastlane
module Helper
class XcversionHelper
def self.find_xcode(req)
req = Gem::Requirement.new(req.to_s)
require 'xcode/install'
installer = XcodeInstall::Installer.new
installed = installer.installed_versions.reverse
installed.detect do |xcode|
req.satisfied_by?(Gem::Version.new(xcode.version))
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/adb_helper.rb | fastlane/lib/fastlane/helper/adb_helper.rb | module Fastlane
module Helper
class AdbDevice
attr_accessor :serial
def initialize(serial: nil)
self.serial = serial
end
end
class AdbHelper
# Path to the adb binary
attr_accessor :adb_path
# Path to the adb binary
attr_accessor :adb_host
# All available devices
attr_accessor :devices
def initialize(adb_path: nil, adb_host: nil)
android_home = ENV['ANDROID_HOME'] || ENV['ANDROID_SDK_ROOT'] || ENV['ANDROID_SDK']
if (adb_path.nil? || adb_path == "adb") && android_home
adb_path = File.join(android_home, "platform-tools", "adb")
end
self.adb_path = Helper.get_executable_path(File.expand_path(adb_path))
self.adb_host = adb_host
end
def host_option
return self.adb_host ? "-H #{adb_host}" : nil
end
# Run a certain action
def trigger(command: nil, serial: nil)
android_serial = serial != "" ? "ANDROID_SERIAL=#{serial}" : nil
command = [android_serial, adb_path.shellescape, host_option, command].compact.join(" ").strip
Action.sh(command)
end
def device_avalaible?(serial)
UI.deprecated("Please use `device_available?` instead... This will be removed in a future version of fastlane")
device_available?(serial)
end
def device_available?(serial)
load_all_devices
return devices.map(&:serial).include?(serial)
end
def load_all_devices
self.devices = []
command = [adb_path.shellescape, host_option, "devices -l"].compact.join(" ")
output = Actions.sh(command, log: false)
output.split("\n").each do |line|
if (result = line.match(/^(\S+)(\s+)(device )/))
self.devices << AdbDevice.new(serial: result[1])
end
end
self.devices
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/xcodebuild_formatter_helper.rb | fastlane/lib/fastlane/helper/xcodebuild_formatter_helper.rb | module Fastlane
module Helper
class XcodebuildFormatterHelper
def self.xcbeautify_installed?
return `which xcbeautify`.include?("xcbeautify")
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/sh_helper.rb | fastlane/lib/fastlane/helper/sh_helper.rb | require "open3"
module Fastlane
module Actions
# Execute a shell command
# This method will output the string and execute it
# Just an alias for sh_no_action
# When running this in tests, it will return the actual command instead of executing it
# @param log [Boolean] should fastlane print out the executed command
# @param error_callback [Block] a callback invoked with the command output if there is a non-zero exit status
def self.sh(*command, log: true, error_callback: nil, &b)
sh_control_output(*command, print_command: log, print_command_output: log, error_callback: error_callback, &b)
end
def self.sh_no_action(*command, log: true, error_callback: nil, &b)
sh_control_output(*command, print_command: log, print_command_output: log, error_callback: error_callback, &b)
end
# @param command The command to be executed (variadic)
# @param print_command [Boolean] Should we print the command that's being executed
# @param print_command_output [Boolean] Should we print the command output during execution
# @param error_callback [Block] A block that's called if the command exits with a non-zero status
# @yield [status, result, cmd] The return status of the command, all output from the command and an equivalent shell command
# @yieldparam [Process::Status] status A Process::Status indicating the status of the completed command
# @yieldparam [String] result The complete output to stdout and stderr of the completed command
# @yieldparam [String] cmd A shell command equivalent to the arguments passed
# rubocop: disable Metrics/PerceivedComplexity
def self.sh_control_output(*command, print_command: true, print_command_output: true, error_callback: nil)
print_command = print_command_output = true if $troubleshoot
# Set the encoding first, the user might have set it wrong
previous_encoding = [Encoding.default_external, Encoding.default_internal]
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
# Workaround to support previous Fastlane syntax.
# This has some limitations. For example, it requires the caller to shell escape
# everything because of usages like ["ls -la", "/tmp"] instead of ["ls", "-la", "/tmp"].
command = [command.first.join(" ")] if command.length == 1 && command.first.kind_of?(Array)
shell_command = shell_command_from_args(*command)
UI.command(shell_command) if print_command
result = ''
exit_status = nil
if FastlaneCore::Helper.sh_enabled?
# The argument list is passed directly to Open3.popen2e, which
# handles the variadic argument list in the same way as Kernel#spawn.
# (http://ruby-doc.org/core-2.4.2/Kernel.html#method-i-spawn) or
# Process.spawn (http://ruby-doc.org/core-2.4.2/Process.html#method-c-spawn).
#
# sh "ls -la /Applications/Xcode\ 7.3.1.app"
# sh "ls", "-la", "/Applications/Xcode 7.3.1.app"
# sh({ "FOO" => "Hello" }, "echo $FOO")
Open3.popen2e(*command) do |stdin, io, thread|
io.sync = true
io.each do |line|
UI.command_output(line.strip) if print_command_output
result << line
end
exit_status = thread.value
end
# Checking Process::Status#exitstatus instead of #success? makes for more
# testable code. (Tests mock exitstatus only.) This is also consistent
# with previous implementations of sh and... probably portable to all
# relevant platforms.
if exit_status.exitstatus != 0
message = if print_command
"Exit status of command '#{shell_command}' was #{exit_status.exitstatus} instead of 0."
else
"Shell command exited with exit status #{exit_status.exitstatus} instead of 0."
end
message += "\n#{result}" if print_command_output
if error_callback || block_given?
UI.error(message)
# block notified below, on success or failure
error_callback && error_callback.call(result)
else
UI.shell_error!(message)
end
end
else
result << shell_command # only for the tests
end
if block_given?
# Avoid yielding nil in tests. $? will be meaningless, but calls to
# it will not crash. There is no Process::Status.new. The alternative
# is to move this inside the sh_enabled? check and not yield in tests.
return yield(exit_status || $?, result, shell_command)
end
result
rescue => ex
raise ex
ensure
Encoding.default_external = previous_encoding.first
Encoding.default_internal = previous_encoding.last
end
# rubocop: enable Metrics/PerceivedComplexity
# Used to produce a shell command string from a list of arguments that may
# be passed to methods such as Kernel#system, Kernel#spawn and Open3.popen2e
# in order to print the command to the terminal. The same *args are passed
# directly to a system call (Open3.popen2e). This interpretation is not
# used when executing a command.
#
# @param args Any number of arguments used to construct a command
# @raise [ArgumentError] If no arguments passed
# @return [String] A shell command representing the arguments passed in
def self.shell_command_from_args(*args)
raise ArgumentError, "sh requires at least one argument" unless args.count > 0
command = ""
# Optional initial environment Hash
if args.first.kind_of?(Hash)
command = args.shift.map { |k, v| "#{k}=#{v.shellescape}" }.join(" ") + " "
end
# Support [ "/usr/local/bin/foo", "foo" ], "-x", ...
if args.first.kind_of?(Array)
command += args.shift.first.shellescape + " " + args.shelljoin
command.chomp!(" ")
elsif args.count == 1 && args.first.kind_of?(String)
command += args.first
else
command += args.shelljoin
end
command
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/dotenv_helper.rb | fastlane/lib/fastlane/helper/dotenv_helper.rb | module Fastlane
module Helper
class DotenvHelper
# @param env_cl_param [String] an optional list of dotenv environment names separated by commas, without space
def self.load_dot_env(env_cl_param)
base_path = find_dotenv_directory
return unless base_path
load_dot_envs_from(env_cl_param, base_path)
end
# finds the first directory of [fastlane, its parent] containing dotenv files
def self.find_dotenv_directory
path = FastlaneCore::FastlaneFolder.path
search_paths = [path]
search_paths << path + "/.." unless path.nil?
search_paths.compact!
search_paths.find do |dir|
Dir.glob(File.join(dir, '*.env*'), File::FNM_DOTMATCH).count > 0
end
end
# loads the dotenvs. First the .env and .env.default and
# then override with all specified extra environments
def self.load_dot_envs_from(env_cl_param, base_path)
require 'dotenv'
# Making sure the default '.env' and '.env.default' get loaded
env_file = File.join(base_path, '.env')
env_default_file = File.join(base_path, '.env.default')
Dotenv.load(env_file, env_default_file)
return unless env_cl_param
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::ENVIRONMENT] = env_cl_param
# multiple envs?
envs = env_cl_param.split(",")
# Loads .env file for the environment(s) passed in through options
envs.each do |env|
env_file = File.join(base_path, ".env.#{env}")
UI.success("Loading from '#{env_file}'")
Dotenv.overload(env_file)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/helper/gem_helper.rb | fastlane/lib/fastlane/helper/gem_helper.rb | module Fastlane
module Actions
# will make sure a gem is installed. If it's not an appropriate error message is shown
# this will *not* 'require' the gem
def self.verify_gem!(gem_name)
begin
FastlaneRequire.install_gem_if_needed(gem_name: gem_name, require_gem: false)
# We don't import this by default, as it's not always the same
# also e.g. cocoapods is just required and not imported
rescue Gem::LoadError
UI.error("Could not find gem '#{gem_name}'")
UI.error("")
UI.error("If you installed fastlane using `gem install fastlane` run")
UI.command("gem install #{gem_name}")
UI.error("to install the missing gem")
UI.error("")
UI.error("If you use a Gemfile add this to your Gemfile:")
UI.important(" gem '#{gem_name}'")
UI.error("and run `bundle install`")
UI.user_error!("You have to install the `#{gem_name}` gem on this machine") unless Helper.test?
end
true
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/setup/setup.rb | fastlane/lib/fastlane/setup/setup.rb | require "tty-spinner"
module Fastlane
class Setup
# Is the current `setup` using a swift based configuration file
attr_accessor :is_swift_fastfile
# :ios or :android
attr_accessor :platform
# Path to the xcodeproj or xcworkspace
attr_accessor :project_path
# Used for :manual sometimes
attr_accessor :preferred_setup_method
# remember if there were multiple projects
# if so, we set it as part of the Fastfile
attr_accessor :had_multiple_projects_to_choose_from
# The current content of the generated Fastfile
attr_accessor :fastfile_content
# Appfile
attr_accessor :appfile_content
# For iOS projects that's the Apple ID email
attr_accessor :user
# This is the lane that we tell the user to run to try the new fastlane setup
# This needs to be setup by each setup
attr_accessor :lane_to_mention
# Start the setup process
# rubocop:disable Metrics/BlockNesting
def self.start(user: nil, is_swift_fastfile: false)
if FastlaneCore::FastlaneFolder.setup? && !Helper.test?
# If Fastfile.swift exists, but the swift sources folder does not, rebuild it
setup_swift_support if is_swift_fastfile
require 'fastlane/lane_list'
Fastlane::LaneList.output(FastlaneCore::FastlaneFolder.fastfile_path)
UI.important("------------------")
UI.important("fastlane is already set up at path `#{FastlaneCore::FastlaneFolder.path}`, see the available lanes above")
UI.message("")
setup_ios = self.new
setup_ios.add_or_update_gemfile(update_gemfile_if_needed: false)
setup_ios.suggest_next_steps
return
end
# this is used by e.g. configuration.rb to not show warnings when running produce
ENV["FASTLANE_ONBOARDING_IN_PROCESS"] = 1.to_s
spinner = TTY::Spinner.new("[:spinner] Looking for iOS and Android projects in current directory...", format: :dots)
spinner.auto_spin
ios_projects = Dir["**/*.xcodeproj"] + Dir["**/*.xcworkspace"]
ios_projects.delete_if do |path|
Gem.path.any? { |gem_path| File.expand_path(path).start_with?(gem_path) }
end
ios_projects.delete_if { |path| path.match("fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj") }
android_projects = Dir["**/*.gradle"] + Dir["**/*.gradle.kts"]
spinner.success
FastlaneCore::FastlaneFolder.create_folder!
# Currently we prefer iOS app projects, as the `init` process is
# more intelligent and does more things. The user can easily add
# the `:android` platform to the resulting Fastfile
if ios_projects.count > 0
current_directory = ios_projects.find_all do |current_project_path|
current_project_path.split(File::Separator).count == 1
end
chosen_project = nil
had_multiple_projects_to_choose_from = false
if current_directory.count == 1
chosen_project = current_directory.first
elsif current_directory.count > 1
if current_directory.count == 2
# This is a common case (e.g. with CocoaPods), where the project has an xcodeproj and an xcworkspace file
extensions = [File.extname(current_directory[0]), File.extname(current_directory[1])]
if extensions.sort == [".xcodeproj", ".xcworkspace"].sort
# Yep, that's this kind of setup
chosen_project = current_directory.find { |d| d.end_with?(".xcworkspace") }
end
end
chosen_project ||= UI.select("Multiple iOS projects found in current directory", current_directory)
had_multiple_projects_to_choose_from = true
else
UI.error("It looks like there is no iOS project in the current directory, though we did find one in a sub-directory")
UI.error("Please `cd` into the directory of the intended Xcode project you wish to use.")
UI.user_error!("Please `cd` into the directory of the intended Xcode project you wish to use and run `fastlane init` again")
end
if chosen_project == "Pods.xcodeproj"
unless UI.confirm("Found '#{chosen_project}', which usually isn't normally what you want. Make sure to switch to the directory containing your intended Xcode project. Would you still like to continue with #{chosen_project}?")
UI.user_error!("Make sure to `cd` into the directory containing the Xcode project you intend to use and then use `fastlane init` again")
end
end
UI.message("Detected an iOS/macOS project in the current directory: '#{chosen_project}'")
SetupIos.new(
is_swift_fastfile: is_swift_fastfile,
user: user,
project_path: chosen_project,
had_multiple_projects_to_choose_from: had_multiple_projects_to_choose_from
).setup_ios
elsif android_projects.count > 0
UI.message("Detected an Android project in the current directory...")
SetupAndroid.new.setup_android
else
UI.error("No iOS or Android projects were found in directory '#{Dir.pwd}'")
UI.error("Make sure to `cd` into the directory containing your iOS or Android app")
if UI.confirm("Alternatively, would you like to manually setup a fastlane config in the current directory instead?")
SetupIos.new(
is_swift_fastfile: is_swift_fastfile,
user: user,
project_path: chosen_project,
had_multiple_projects_to_choose_from: had_multiple_projects_to_choose_from,
preferred_setup_method: :ios_manual
).setup_ios
else
UI.user_error!("Make sure to `cd` into the directory containing your project and then use `fastlane init` again")
end
end
end
# rubocop:enable Metrics/BlockNesting
def self.setup_swift_support
runner_source_resources = "#{Fastlane::ROOT}/swift/."
destination_path = File.expand_path('swift', FastlaneCore::FastlaneFolder.path)
# Return early if already setup
return if File.exist?(destination_path)
# Show message if Fastfile.swift exists but missing Swift classes and Xcode project
if FastlaneCore::FastlaneFolder.swift?
UI.important("Restoring Swift classes and FastlaneSwiftRunner.xcodeproj...")
end
FileUtils.cp_r(runner_source_resources, destination_path)
UI.success("Copied Swift fastlane runner project to '#{destination_path}'.")
Fastlane::SwiftLaneManager.first_time_setup
end
def initialize(is_swift_fastfile: nil, user: nil, project_path: nil, had_multiple_projects_to_choose_from: nil, preferred_setup_method: nil)
self.is_swift_fastfile = is_swift_fastfile
self.user = user
self.project_path = project_path
self.had_multiple_projects_to_choose_from = had_multiple_projects_to_choose_from
self.preferred_setup_method = preferred_setup_method
end
# Helpers
def welcome_to_fastlane
UI.header("Welcome to fastlane 🚀")
UI.message("fastlane can help you with all kinds of automation for your mobile app")
UI.message("We recommend automating one task first, and then gradually automating more over time")
end
# Append a lane to the current Fastfile template we're generating
def append_lane(lane)
lane.compact! # remove nil values
new_lines = "\n\n"
if self.is_swift_fastfile
new_lines = "" unless self.fastfile_content.include?("lane() {") # the first lane we don't want new lines
self.fastfile_content.gsub!("[[LANES]]", "#{new_lines}\t#{lane.join("\n\t")}[[LANES]]")
else
new_lines = "" unless self.fastfile_content.include?("lane :") # the first lane we don't want new lines
self.fastfile_content.gsub!("[[LANES]]", "#{new_lines} #{lane.join("\n ")}[[LANES]]")
end
end
# Append a team to the Appfile
def append_team(team)
self.appfile_content.gsub!("[[TEAMS]]", "#{team}\n[[TEAMS]]")
end
def write_fastfile!
# Write the Fastfile
fastfile_file_name = "Fastfile"
fastfile_file_name += ".swift" if self.is_swift_fastfile
fastfile_path = File.join(FastlaneCore::FastlaneFolder.path, fastfile_file_name)
self.fastfile_content.gsub!("[[LANES]]", "") # since we always keep it until writing out
File.write(fastfile_path, self.fastfile_content) # remove trailing spaces before platform ends
appfile_file_name = "Appfile"
appfile_file_name += ".swift" if self.is_swift_fastfile
appfile_path = File.join(FastlaneCore::FastlaneFolder.path, appfile_file_name)
self.appfile_content.gsub!("[[TEAMS]]", "")
File.write(appfile_path, self.appfile_content)
add_or_update_gemfile(update_gemfile_if_needed: true)
UI.header("✅ Successfully generated fastlane configuration")
UI.message("Generated Fastfile at path `#{fastfile_path}`")
UI.message("Generated Appfile at path `#{appfile_path}`")
UI.message("Gemfile and Gemfile.lock at path `#{gemfile_path}`")
UI.message("Please check the newly generated configuration files into git along with your project")
UI.message("This way everyone in your team can benefit from your fastlane setup")
continue_with_enter
end
def gemfile_path
"Gemfile"
end
# Gemfile related code:
def gemfile_exists?
return File.exist?(gemfile_path)
end
def setup_gemfile!
# No Gemfile yet
gemfile_content = []
gemfile_content << "source \"https://rubygems.org\""
gemfile_content << ""
gemfile_content << 'gem "fastlane"'
gemfile_content << ""
File.write(gemfile_path, gemfile_content.join("\n"))
UI.message("Installing dependencies for you...")
FastlaneCore::CommandExecutor.execute(
command: "bundle update",
print_all: FastlaneCore::Globals.verbose?,
print_command: true,
error: proc do |error_output|
UI.error("Something went wrong when running `bundle update` for you")
UI.error("Please take a look at your Gemfile at path `#{gemfile_path}`")
UI.error("and make sure you can run `bundle update` on your machine.")
end
)
end
def ensure_gemfile_valid!(update_gemfile_if_needed: false)
gemfile_content = File.read(gemfile_path)
unless gemfile_content.include?("https://rubygems.org")
UI.error("You have a local Gemfile, but RubyGems isn't defined as source")
UI.error("Please update your Gemfile at path `#{gemfile_path}` to include")
UI.important("")
UI.important("source \"https://rubygems.org\"")
UI.important("")
UI.error("Update your Gemfile, and run `bundle update` afterwards")
end
unless gemfile_content.include?("fastlane")
if update_gemfile_if_needed
gemfile_content << "\n\ngem \"fastlane\""
UI.message("Adding `fastlane` to your existing Gemfile at path '#{gemfile_path}'")
File.write(gemfile_path, gemfile_content)
else
UI.error("You have a local Gemfile, but it doesn't include \"fastlane\" as a dependency")
UI.error("Please add `gem \"fastlane\"` to your Gemfile")
end
end
end
# This method is responsible for ensuring there is a working
# Gemfile, and that `fastlane` is defined as a dependency
# while also having `rubygems` as a gem source
def add_or_update_gemfile(update_gemfile_if_needed: false)
if gemfile_exists?
ensure_gemfile_valid!(update_gemfile_if_needed: update_gemfile_if_needed)
else
if update_gemfile_if_needed || UI.confirm("It is recommended to run fastlane with a Gemfile set up, do you want fastlane to create one for you?")
setup_gemfile!
end
end
return gemfile_path
end
def finish_up
write_fastfile!
self.class.setup_swift_support if is_swift_fastfile
show_analytics_note
explain_concepts
suggest_next_steps
end
def fastfile_template_content
if self.is_swift_fastfile
path = "#{Fastlane::ROOT}/lib/assets/DefaultFastfileTemplate.swift"
else
path = "#{Fastlane::ROOT}/lib/assets/DefaultFastfileTemplate"
end
return File.read(path)
end
def appfile_template_content
if self.platform == :ios
if self.is_swift_fastfile
path = "#{Fastlane::ROOT}/lib/assets/AppfileTemplate.swift"
else
path = "#{Fastlane::ROOT}/lib/assets/AppfileTemplate"
end
else
path = "#{Fastlane::ROOT}/lib/assets/AppfileTemplateAndroid"
end
return File.read(path)
end
def explain_concepts
UI.header("fastlane lanes")
UI.message("fastlane uses a " + "`Fastfile`".yellow + " to store the automation configuration")
UI.message("Within that, you'll see different " + "lanes".yellow + ".")
UI.message("Each is there to automate a different task, like screenshots, code signing, or pushing new releases")
continue_with_enter
UI.header("How to customize your Fastfile")
UI.message("Use a text editor of your choice to open the newly created Fastfile and take a look")
UI.message("You can now edit the available lanes and actions to customize the setup to fit your needs")
UI.message("To get a list of all the available actions, open " + "https://docs.fastlane.tools/actions".cyan)
continue_with_enter
end
def continue_with_enter
UI.input("Continue by pressing Enter ⏎")
end
def suggest_next_steps
UI.header("Where to go from here?")
if self.platform == :android
UI.message("📸 Learn more about how to automatically generate localized Google Play screenshots:")
UI.message("\t\thttps://docs.fastlane.tools/getting-started/android/screenshots/".cyan)
UI.message("👩✈️ Learn more about distribution to beta testing services:")
UI.message("\t\thttps://docs.fastlane.tools/getting-started/android/beta-deployment/".cyan)
UI.message("🚀 Learn more about how to automate the Google Play release process:")
UI.message("\t\thttps://docs.fastlane.tools/getting-started/android/release-deployment/".cyan)
else
UI.message("📸 Learn more about how to automatically generate localized App Store screenshots:")
UI.message("\t\thttps://docs.fastlane.tools/getting-started/ios/screenshots/".cyan)
UI.message("👩✈️ Learn more about distribution to beta testing services:")
UI.message("\t\thttps://docs.fastlane.tools/getting-started/ios/beta-deployment/".cyan)
UI.message("🚀 Learn more about how to automate the App Store release process:")
UI.message("\t\thttps://docs.fastlane.tools/getting-started/ios/appstore-deployment/".cyan)
UI.message("👩⚕️ Learn more about how to setup code signing with fastlane")
UI.message("\t\thttps://docs.fastlane.tools/codesigning/getting-started/".cyan)
end
# we crash here, so that this never happens when a new setup method is added
return if self.lane_to_mention.to_s.length == 0
UI.message("")
UI.message("To try your new fastlane setup, just enter and run")
UI.command("fastlane #{self.lane_to_mention}")
end
def show_analytics_note
UI.message("fastlane will collect the number of errors for each action to detect integration issues")
UI.message("No sensitive/private information will be uploaded, more information: " + "https://docs.fastlane.tools/#metrics".cyan)
end
end
end
require 'fastlane/setup/setup_ios'
require 'fastlane/setup/setup_android'
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/setup/setup_ios.rb | fastlane/lib/fastlane/setup/setup_ios.rb | module Fastlane
# rubocop:disable Metrics/ClassLength
class SetupIos < Setup
# Reference to the iOS project `project.rb`
attr_accessor :project
# App Identifier of the current app
attr_accessor :app_identifier
# Scheme of the Xcode project
attr_accessor :scheme
# If the current setup requires a login, this is where we'll store the team ID
attr_accessor :itc_team_id
attr_accessor :adp_team_id
attr_accessor :app_exists_on_itc
attr_accessor :automatic_versioning_enabled
def setup_ios
require 'spaceship'
self.platform = :ios
welcome_to_fastlane
self.fastfile_content = fastfile_template_content
self.appfile_content = appfile_template_content
if preferred_setup_method
self.send(preferred_setup_method)
return
end
options = {
"📸 Automate screenshots" => :ios_screenshots,
"👩✈️ Automate beta distribution to TestFlight" => :ios_testflight,
"🚀 Automate App Store distribution" => :ios_app_store,
"🛠 Manual setup - manually setup your project to automate your tasks" => :ios_manual
}
selected = UI.select("What would you like to use fastlane for?", options.keys)
@method_to_use = options[selected]
begin
self.send(@method_to_use)
rescue => ex
# If it's already manual, and it has failed
# we need to re-raise the exception, as something definitely is wrong
raise ex if @method_to_use == :ios_manual
# If we're here, that means something else failed. We now show the
# error message and fallback to `:ios_manual`
UI.error("--------------------")
UI.error("fastlane init failed")
UI.error("--------------------")
UI.verbose(ex.backtrace.join("\n"))
if ex.kind_of?(Spaceship::Client::BasicPreferredInfoError) || ex.kind_of?(Spaceship::Client::UnexpectedResponse)
UI.error(ex.preferred_error_info)
else
UI.error(ex.to_s)
end
UI.important("Something failed while running `fastlane init`")
UI.important("Tried using Apple ID with email '#{self.user}'")
UI.important("You can either retry, or fallback to manual setup which will create a basic Fastfile")
if UI.confirm("Would you like to fallback to a manual Fastfile?")
self.ios_manual
else
self.send(@method_to_use)
end
# the second time, we're just failing, and don't use a `begin` `rescue` block any more
end
end
# Different iOS flows
def ios_testflight
UI.header("Setting up fastlane for iOS TestFlight distribution")
find_and_setup_xcode_project
apple_xcode_project_versioning_enabled
ask_for_credentials(adp: true, itc: true)
verify_app_exists_adp!
verify_app_exists_itc!
if self.is_swift_fastfile
lane = ["func betaLane() {",
"desc(\"Push a new beta build to TestFlight\")",
increment_build_number_if_applicable,
"\tbuildApp(#{project_prefix}scheme: \"#{self.scheme}\")",
"\tuploadToTestflight(username: \"#{self.user}\")",
"}"]
else
lane = ["desc \"Push a new beta build to TestFlight\"",
"lane :beta do",
increment_build_number_if_applicable,
" build_app(#{project_prefix}scheme: \"#{self.scheme}\")",
" upload_to_testflight",
"end"]
end
self.append_lane(lane)
self.lane_to_mention = "beta"
finish_up
end
def ios_app_store
UI.header("Setting up fastlane for iOS App Store distribution")
find_and_setup_xcode_project
apple_xcode_project_versioning_enabled
ask_for_credentials(adp: true, itc: true)
verify_app_exists_adp!
verify_app_exists_itc!
if self.app_exists_on_itc
UI.header("Manage app metadata?")
UI.message("Would you like to have fastlane manage your app's metadata?")
UI.message("If you enable this feature, fastlane will download your existing metadata and screenshots.")
UI.message("This way, you'll be able to edit your app's metadata in local `.txt` files.")
UI.message("After editing the local `.txt` files, just run fastlane and all changes will be pushed up.")
UI.message("If you don't want to use this feature, you can still use fastlane to upload and distribute new builds to the App Store")
include_metadata = UI.confirm("Would you like fastlane to manage your app's metadata?")
if include_metadata
require 'deliver'
require 'deliver/setup'
deliver_options = FastlaneCore::Configuration.create(
Deliver::Options.available_options,
{
run_precheck_before_submit: false, # precheck doesn't need to run during init
username: self.user,
app_identifier: self.app_identifier,
team_id: self.itc_team_id
}
)
Deliver::DetectValues.new.run!(deliver_options, {}) # needed to fetch the app details
Deliver::Setup.new.run(deliver_options, is_swift: self.is_swift_fastfile)
end
end
if self.is_swift_fastfile
lane = ["func releaseLane() {",
"desc(\"Push a new release build to the App Store\")",
increment_build_number_if_applicable,
"\tbuildApp(#{project_prefix}scheme: \"#{self.scheme}\")"]
if include_metadata
lane << "\tuploadToAppStore(username: \"#{self.user}\", appIdentifier: \"#{self.app_identifier}\")"
else
lane << "\tuploadToAppStore(username: \"#{self.user}\", appIdentifier: \"#{self.app_identifier}\", skipScreenshots: true, skipMetadata: true)"
end
lane << "}"
else
lane = ["desc \"Push a new release build to the App Store\"",
"lane :release do",
increment_build_number_if_applicable,
" build_app(#{project_prefix}scheme: \"#{self.scheme}\")"]
if include_metadata
lane << " upload_to_app_store"
else
lane << " upload_to_app_store(skip_metadata: true, skip_screenshots: true)"
end
lane << "end"
end
append_lane(lane)
self.lane_to_mention = "release"
finish_up
end
def ios_screenshots
UI.header("Setting up fastlane to automate iOS screenshots")
UI.message("fastlane uses UI Tests to automate generating localized screenshots of your iOS app")
UI.message("fastlane will now create 2 helper files that are needed to get the setup running")
UI.message("For more information on how this works and best practices, check out")
UI.message("\thttps://docs.fastlane.tools/getting-started/ios/screenshots/".cyan)
continue_with_enter
begin
find_and_setup_xcode_project(ask_for_scheme: false) # to get the bundle identifier
rescue => ex
# If this fails, it's no big deal, since we really just want the bundle identifier
# so instead, we'll just ask the user
UI.verbose(ex.to_s)
end
require 'snapshot'
require 'snapshot/setup'
Snapshot::Setup.create(
FastlaneCore::FastlaneFolder.path,
is_swift_fastfile: self.is_swift_fastfile,
print_instructions_on_failure: true
)
UI.message("If you want more details on how to setup automatic screenshots, check out")
UI.message("\thttps://docs.fastlane.tools/getting-started/ios/screenshots/#setting-up-snapshot".cyan)
continue_with_enter
available_schemes = self.project.schemes
ui_testing_scheme = UI.select("Which is your UI Testing scheme? If you can't find it in this list, make sure it's marked as `Shared` in the Xcode scheme list", available_schemes)
UI.header("Automatically upload to iTC?")
UI.message("Would you like fastlane to automatically upload all generated screenshots to App Store Connect")
UI.message("after generating them?")
UI.message("If you enable this feature you'll need to provide your App Store Connect credentials so fastlane can upload the screenshots to App Store Connect")
automatic_upload = UI.confirm("Enable automatic upload of localized screenshots to App Store Connect?")
if automatic_upload
ask_for_credentials(adp: true, itc: true)
verify_app_exists_itc!
end
if self.is_swift_fastfile
lane = ["func screenshotsLane() {",
"desc(\"Generate new localized screenshots\")",
"\tcaptureScreenshots(#{project_prefix}scheme: \"#{ui_testing_scheme}\")"]
if automatic_upload
lane << "\tuploadToAppStore(username: \"#{self.user}\", appIdentifier: \"#{self.app_identifier}\", skipBinaryUpload: true, skipMetadata: true)"
end
lane << "}"
else
lane = ["desc \"Generate new localized screenshots\"",
"lane :screenshots do",
" capture_screenshots(#{project_prefix}scheme: \"#{ui_testing_scheme}\")"]
if automatic_upload
lane << " upload_to_app_store(skip_binary_upload: true, skip_metadata: true)"
end
lane << "end"
end
append_lane(lane)
self.lane_to_mention = "screenshots"
finish_up
end
def ios_manual
UI.header("Setting up fastlane so you can manually configure it")
if self.is_swift_fastfile
append_lane(["func customLane() {",
"desc(\"Description of what the lane does\")",
"\t// add actions here: https://docs.fastlane.tools/actions",
"}"])
self.lane_to_mention = "custom" # lane is part of the notation
else
append_lane(["desc \"Description of what the lane does\"",
"lane :custom_lane do",
" # add actions here: https://docs.fastlane.tools/actions",
"end"])
self.lane_to_mention = "custom_lane"
end
finish_up
end
# Helpers
# Every installation setup that needs an Xcode project should
# call this method
def find_and_setup_xcode_project(ask_for_scheme: true)
UI.message("Parsing your local Xcode project to find the available schemes and the app identifier")
config = {} # this is needed as the first method call will store information in there
if self.project_path.end_with?("xcworkspace")
config[:workspace] = self.project_path
else
config[:project] = self.project_path
end
FastlaneCore::Project.detect_projects(config)
self.project = FastlaneCore::Project.new(config)
if ask_for_scheme
self.scheme = self.project.select_scheme(preferred_to_include: self.project.project_name)
end
self.app_identifier = self.project.default_app_identifier # These two vars need to be accessed in order to be set
if self.app_identifier.to_s.length == 0
ask_for_bundle_identifier
end
end
def ask_for_bundle_identifier
loop do
return if self.app_identifier.to_s.length > 0
self.app_identifier = UI.input("Bundle identifier of your app: ")
end
end
def ask_for_credentials(itc: true, adp: false)
UI.header("Login with your Apple ID")
UI.message("To use App Store Connect and Apple Developer Portal features as part of fastlane,")
UI.message("we will ask you for your Apple ID username and password")
UI.message("This is necessary for certain fastlane features, for example:")
UI.message("")
UI.message("- Create and manage your provisioning profiles on the Developer Portal")
UI.message("- Upload and manage TestFlight and App Store builds on App Store Connect")
UI.message("- Manage your App Store Connect app metadata and screenshots")
UI.message("")
UI.message("Your Apple ID credentials will only be stored in your Keychain, on your local machine")
UI.message("For more information, check out")
UI.message("\thttps://github.com/fastlane/fastlane/tree/master/credentials_manager".cyan)
UI.message("")
if self.user.to_s.length == 0
UI.important("Please enter your Apple ID developer credentials")
self.user = UI.input("Apple ID Username:")
end
UI.message("Logging in...")
# Disable the warning texts and information that's not relevant during onboarding
ENV["FASTLANE_HIDE_LOGIN_INFORMATION"] = 1.to_s
ENV["FASTLANE_HIDE_TEAM_INFORMATION"] = 1.to_s
if itc
Spaceship::Tunes.login(self.user)
Spaceship::Tunes.select_team
self.itc_team_id = Spaceship::Tunes.client.team_id
if self.is_swift_fastfile
self.append_team("var itcTeam: String? { return \"#{self.itc_team_id}\" } // App Store Connect Team ID")
else
self.append_team("itc_team_id(\"#{self.itc_team_id}\") # App Store Connect Team ID")
end
end
if adp
Spaceship::Portal.login(self.user)
Spaceship::Portal.select_team
self.adp_team_id = Spaceship::Portal.client.team_id
if self.is_swift_fastfile
self.append_team("var teamID: String { return \"#{self.adp_team_id}\" } // Apple Developer Portal Team ID")
else
self.append_team("team_id(\"#{self.adp_team_id}\") # Developer Portal Team ID")
end
end
UI.success("✅ Logging in with your Apple ID was successful")
end
def apple_xcode_project_versioning_enabled
self.automatic_versioning_enabled = false
paths = self.project.project_paths
return false if paths.count == 0
result = Fastlane::Actions::GetBuildNumberAction.run({
project: paths.first, # most of the times, there will only be one project in there
hide_error_when_versioning_disabled: true
})
if result.kind_of?(String) && result.to_f > 0
self.automatic_versioning_enabled = true
end
return self.automatic_versioning_enabled
end
def show_information_about_version_bumps
UI.important("It looks like your project isn't set up to do automatic version incrementing")
UI.important("To enable fastlane to handle automatic version incrementing for you, please follow this guide:")
UI.message("\thttps://developer.apple.com/library/content/qa/qa1827/_index.html".cyan)
UI.important("Afterwards check out the fastlane docs on how to set up automatic build increments")
UI.message("\thttps://docs.fastlane.tools/getting-started/ios/beta-deployment/#best-practices".cyan)
end
def verify_app_exists_adp!
UI.user_error!("No app identifier provided") if self.app_identifier.to_s.length == 0
UI.message("Checking if the app '#{self.app_identifier}' exists in your Apple Developer Portal...")
app = Spaceship::Portal::App.find(self.app_identifier)
if app.nil?
UI.error("It looks like the app '#{self.app_identifier}' isn't available on the #{'Apple Developer Portal'.bold.underline}")
UI.error("for the team ID '#{self.adp_team_id}' on Apple ID '#{self.user}'")
if UI.confirm("Do you want fastlane to create the App ID for you on the Apple Developer Portal?")
create_app_online!(mode: :adp)
else
UI.important("Alright, we won't create the app for you. Be aware, the build is probably going to fail when you try it")
end
else
UI.success("✅ Your app '#{self.app_identifier}' is available in your Apple Developer Portal")
end
end
def verify_app_exists_itc!
UI.user_error!("No app identifier provided") if self.app_identifier.to_s.length == 0
UI.message("Checking if the app '#{self.app_identifier}' exists on App Store Connect...")
app = Spaceship::ConnectAPI::App.find(self.app_identifier)
if app.nil?
UI.error("Looks like the app '#{self.app_identifier}' isn't available on #{'App Store Connect'.bold.underline}")
UI.error("for the team ID '#{self.itc_team_id}' on Apple ID '#{self.user}'")
if UI.confirm("Would you like fastlane to create the App on App Store Connect for you?")
create_app_online!(mode: :itc)
self.app_exists_on_itc = true
else
UI.important("Alright, we won't create the app for you. Be aware, the build is probably going to fail when you try it")
end
else
UI.success("✅ Your app '#{self.app_identifier}' is available on App Store Connect")
self.app_exists_on_itc = true
end
end
def finish_up
# iOS specific things first
if self.app_identifier
self.appfile_content.gsub!("# app_identifier", "app_identifier")
self.appfile_content.gsub!("[[APP_IDENTIFIER]]", self.app_identifier)
end
if self.user
self.appfile_content.gsub!("# apple_id", "apple_id")
self.appfile_content.gsub!("[[APPLE_ID]]", self.user)
end
if !self.automatic_versioning_enabled && @method_to_use != :ios_manual
self.show_information_about_version_bumps
end
super
end
# Returns the `workspace` or `project` key/value pair for
# gym and snapshot, but only if necessary
# (when there are multiple projects in the current directory)
# it's a prefix, and not a suffix, as Swift cares about the order of parameters
def project_prefix
return "" unless self.had_multiple_projects_to_choose_from
if self.project_path.end_with?(".xcworkspace")
return "workspace: \"#{self.project_path}\", "
else
return "project: \"#{self.project_path}\", "
end
end
def increment_build_number_if_applicable
return nil unless self.automatic_versioning_enabled
return nil if self.project.project_paths.first.to_s.length == 0
project_path = self.project.project_paths.first
# Convert the absolute path to a relative path
project_path_name = Pathname.new(project_path)
current_path_name = Pathname.new(File.expand_path("."))
relative_project_path = project_path_name.relative_path_from(current_path_name)
if self.is_swift_fastfile
return "\tincrementBuildNumber(xcodeproj: \"#{relative_project_path}\")"
else
return " increment_build_number(xcodeproj: \"#{relative_project_path}\")"
end
end
def create_app_online!(mode: nil)
# mode is either :adp or :itc
require 'produce'
produce_options = {
username: self.user,
team_id: self.adp_team_id,
itc_team_id: self.itc_team_id,
platform: "ios",
app_identifier: self.app_identifier
}
if mode == :adp
produce_options[:skip_itc] = true
else
produce_options[:skip_devcenter] = true
end
# The retrying system allows people to correct invalid inputs
# e.g. the app's name is already taken
loop do
# Creating config in the loop so user will be reprompted
# for app name if app name is taken or too long
Produce.config = FastlaneCore::Configuration.create(
Produce::Options.available_options,
produce_options
)
begin
Produce::Manager.start_producing
UI.success("✅ Successfully created app")
return # success
rescue => ex
# show the user facing error, and inform them of what went wrong
if ex.kind_of?(Spaceship::Client::BasicPreferredInfoError) || ex.kind_of?(Spaceship::Client::UnexpectedResponse)
UI.error(ex.preferred_error_info)
else
UI.error(ex.to_s)
end
UI.error(ex.backtrace.join("\n")) if FastlaneCore::Globals.verbose?
UI.important("It looks like something went wrong when we tried to create your app on the Apple Developer Portal")
unless UI.confirm("Would you like to try again (y)? If you enter (n), fastlane will fall back to the manual setup")
raise ex
end
end
end
end
end
# rubocop:enable Metrics/ClassLength
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/setup/setup_android.rb | fastlane/lib/fastlane/setup/setup_android.rb | module Fastlane
class SetupAndroid < Setup
attr_accessor :json_key_file
attr_accessor :package_name
def setup_android
self.platform = :android
self.is_swift_fastfile = false
welcome_to_fastlane
self.fastfile_content = fastfile_template_content
self.appfile_content = appfile_template_content
fetch_information_for_appfile
FastlaneCore::FastlaneFolder.create_folder!
init_supply
self.append_lane([
"desc \"Runs all the tests\"",
"lane :test do",
" gradle(task: \"test\")",
"end"
])
self.append_lane([
"desc \"Submit a new Beta Build to Crashlytics Beta\"",
"lane :beta do",
" gradle(task: \"clean assembleRelease\")",
" crashlytics",
"",
" # sh \"your_script.sh\"",
" # You can also use other beta testing services here",
"end"
])
self.append_lane([
"desc \"Deploy a new version to the Google Play\"",
"lane :deploy do",
" gradle(task: \"clean assembleRelease\")",
" upload_to_play_store",
"end"
])
self.lane_to_mention = "test"
finish_up
end
def fetch_information_for_appfile
UI.message('')
UI.message("To avoid re-entering your package name and issuer every time you run fastlane, we'll store those in a so-called Appfile.")
self.package_name = UI.input("Package Name (com.krausefx.app): ")
puts("")
puts("To automatically upload builds and metadata to Google Play, fastlane needs a service account json secret file".yellow)
puts("Follow the Setup Guide on how to get the Json file: https://docs.fastlane.tools/actions/supply/".yellow)
puts("Feel free to press Enter at any time in order to skip providing pieces of information when asked")
self.json_key_file = UI.input("Path to the json secret file: ")
self.appfile_content.gsub!("[[JSON_KEY_FILE]]", self.json_key_file)
self.appfile_content.gsub!("[[PACKAGE_NAME]]", self.package_name)
end
def init_supply
UI.message("")
question = "Do you plan on uploading metadata, screenshots, and builds to Google Play using fastlane?".yellow
UI.message(question)
UI.message("We will now download your existing metadata and screenshots into the `fastlane` folder so fastlane can manage it")
if UI.confirm("Download existing metadata and setup metadata management?")
begin
require 'supply'
require 'supply/setup'
supply_config = {
json_key: self.json_key_file,
package_name: self.package_name
}
Supply.config = FastlaneCore::Configuration.create(Supply::Options.available_options, supply_config)
Supply::Setup.new.perform_download
rescue => ex
UI.error(ex.to_s)
UI.error("Setting up `supply` (metadata management action) failed, but don't worry, you can try setting it up again using `fastlane supply init` whenever you want.")
end
else
UI.success("You can run `fastlane supply init` to set up metadata management at a later point.")
end
end
def finish_up
self.fastfile_content.gsub!(":ios", ":android")
super
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/action_command_return.rb | fastlane/lib/fastlane/server/action_command_return.rb | module Fastlane
# Encapsulates the result and description of a return object returned by an executed fastlane action
class ActionCommandReturn
attr_reader :return_value
attr_reader :return_value_type
attr_reader :closure_argument_value
def initialize(return_value: nil, return_value_type: nil, closure_argument_value: nil)
@return_value = return_value
@closure_argument_value = closure_argument_value
@return_value_type = return_value_type
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/command_executor.rb | fastlane/lib/fastlane/server/command_executor.rb | module Fastlane
class CommandExecutor
def execute(command: nil, target_object: nil)
not_implemented(__method__)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/action_command.rb | fastlane/lib/fastlane/server/action_command.rb | module Fastlane
# Represents an argument to the ActionCommand
class Argument
def initialize(json: nil)
@name = json['name']
@value = json['value']
@value_type = json['value_type']
end
def is_named
return @name.to_s.length > 0
end
def inspect
if is_named
return "named argument: #{name}, value: #{value}, type: #{value_type}"
else
return "unnamed argument value: #{value}, type: #{value_type}"
end
end
attr_reader :name
attr_reader :value
attr_reader :value_type
end
# Represents a command that is meant to execute an Action on the client's behalf
class ActionCommand
attr_reader :command_id # always present
attr_reader :args # always present
attr_reader :method_name # always present
attr_reader :class_name # only present when executing a class-method
def initialize(json: nil)
@method_name = json['methodName']
@class_name = json['className']
@command_id = json['commandID']
args_json = json['args'] ||= []
@args = args_json.map do |arg|
Argument.new(json: arg)
end
end
def cancel_signal?
return @command_id == "cancelFastlaneRun"
end
def target_class
unless class_name
return nil
end
return Fastlane::Actions.const_get(class_name)
end
def is_class_method_command
return class_name.to_s.length > 0
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/socket_server_action_command_executor.rb | fastlane/lib/fastlane/server/socket_server_action_command_executor.rb | require 'fastlane/server/action_command_return.rb'
require 'fastlane/server/command_parser.rb'
require 'fastlane/server/command_executor.rb'
module Fastlane
# Handles receiving commands from the socket server, finding the Action to be invoked,
# invoking it, and returning any return values
class SocketServerActionCommandExecutor < CommandExecutor
attr_accessor :runner
attr_accessor :actions_requiring_special_handling
def initialize
Fastlane.load_actions
@runner = Runner.new
@actions_requiring_special_handling = ["sh"].to_set
end
def execute(command: nil, target_object: nil)
action_name = command.method_name
action_class_ref = class_ref_for_action(named: action_name)
parameter_map = {}
closure_argument_value = nil
command.args.each do |arg|
arg_value = arg.value
if arg.value_type.to_s.to_sym == :string_closure
closure = proc { |string_value| closure_argument_value = string_value }
arg_value = closure
end
parameter_map[arg.name.to_sym] = arg_value
end
if @actions_requiring_special_handling.include?(action_name)
command_return = run_action_requiring_special_handling(
command: command,
parameter_map: parameter_map,
action_return_type: action_class_ref.return_type
)
return command_return
end
action_return = run(
action_named: action_name,
action_class_ref: action_class_ref,
parameter_map: parameter_map
)
command_return = ActionCommandReturn.new(
return_value: action_return,
return_value_type: action_class_ref.return_type,
closure_argument_value: closure_argument_value
)
return command_return
end
def class_ref_for_action(named: nil)
class_ref = Actions.action_class_ref(named)
unless class_ref
if Fastlane::Actions.formerly_bundled_actions.include?(action)
# This was a formerly bundled action which is now a plugin.
UI.verbose(caller.join("\n"))
UI.user_error!("The action '#{action}' is no longer bundled with fastlane. You can install it using `fastlane add_plugin #{action}`")
else
Fastlane::ActionsList.print_suggestions(action)
UI.user_error!("Action '#{action}' not available, run `fastlane actions` to get a full list")
end
end
return class_ref
end
def run(action_named: nil, action_class_ref: nil, parameter_map: nil)
action_return = runner.execute_action(action_named, action_class_ref, [parameter_map], custom_dir: '.')
return action_return
end
# Some actions have special handling in fast_file.rb, that means we can't directly call the action
# but we have to use the same logic that is in fast_file.rb instead.
# That's where this switch statement comes into play
def run_action_requiring_special_handling(command: nil, parameter_map: nil, action_return_type: nil)
action_return = nil
closure_argument_value = nil # only used if the action uses it
case command.method_name
when "sh"
error_callback = proc { |string_value| closure_argument_value = string_value } if parameter_map[:error_callback]
command_param = parameter_map[:command]
log_param = parameter_map[:log]
action_return = Fastlane::FastFile.sh(command_param, log: log_param, error_callback: error_callback)
end
command_return = ActionCommandReturn.new(
return_value: action_return,
return_value_type: action_return_type,
closure_argument_value: closure_argument_value
)
return command_return
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/socket_server.rb | fastlane/lib/fastlane/server/socket_server.rb | require 'fastlane/server/command_executor.rb'
require 'fastlane/server/command_parser.rb'
require 'fastlane/server/json_return_value_processor.rb'
require 'socket'
require 'json'
module Fastlane
class SocketServer
COMMAND_EXECUTION_STATE = {
ready: :ready,
already_shutdown: :already_shutdown,
error: :error
}
attr_accessor :command_executor
attr_accessor :return_value_processor
def initialize(
command_executor: nil,
return_value_processor: nil,
connection_timeout: 5,
stay_alive: false,
port: 2000
)
if return_value_processor.nil?
return_value_processor = JSONReturnValueProcessor.new
end
@command_executor = command_executor
@return_value_processor = return_value_processor
@connection_timeout = connection_timeout.to_i
@stay_alive = stay_alive
@port = port.to_i
end
# this is the public API, don't call anything else
def start
listen
while @stay_alive
UI.important("stay_alive is set to true, restarting server")
listen
end
end
private
def receive_and_process_commands
loop do # no idea how many commands are coming, so we loop until an error or the done command is sent
execution_state = COMMAND_EXECUTION_STATE[:ready]
command_string = nil
begin
command_string = @client.recv(1_048_576) # 1024 * 1024
rescue Errno::ECONNRESET => e
UI.verbose(e)
execution_state = COMMAND_EXECUTION_STATE[:error]
end
if execution_state == COMMAND_EXECUTION_STATE[:ready]
# Ok, all is good, let's see what command we have
execution_state = parse_and_execute_command(command_string: command_string)
end
case execution_state
when COMMAND_EXECUTION_STATE[:ready]
# command executed successfully, let's setup for the next command
next
when COMMAND_EXECUTION_STATE[:already_shutdown]
# we shutdown in response to a command, nothing left to do but exit
break
when COMMAND_EXECUTION_STATE[:error]
# we got an error somewhere, let's shutdown and exit
handle_disconnect(error: true, exit_reason: :error)
break
end
end
end
def parse_and_execute_command(command_string: nil)
command = CommandParser.parse(json: command_string)
case command
when ControlCommand
return handle_control_command(command)
when ActionCommand
return handle_action_command(command)
end
# catch all
raise "Command #{command} not supported"
end
# we got a server control command from the client to do something like shutdown
def handle_control_command(command)
exit_reason = nil
if command.cancel_signal?
UI.verbose("received cancel signal shutting down, reason: #{command.reason}")
# send an ack to the client to let it know we're shutting down
cancel_response = '{"payload":{"status":"cancelled"}}'
send_response(cancel_response)
exit_reason = :cancelled
elsif command.done_signal?
UI.verbose("received done signal shutting down")
# client is already in the process of shutting down, no need to ack
exit_reason = :done
end
# if the command came in with a user-facing message, display it
if command.user_message
UI.important(command.user_message)
end
# currently all control commands should trigger a disconnect and shutdown
handle_disconnect(error: false, exit_reason: exit_reason)
return COMMAND_EXECUTION_STATE[:already_shutdown]
end
# execute and send back response to client
def handle_action_command(command)
response_json = process_action_command(command: command)
return send_response(response_json)
end
# send json back to client
def send_response(json)
UI.verbose("sending #{json}")
begin
@client.puts(json) # Send some json to the client
rescue Errno::EPIPE => e
UI.verbose(e)
return COMMAND_EXECUTION_STATE[:error]
end
return COMMAND_EXECUTION_STATE[:ready]
end
def listen
@server = TCPServer.open('localhost', @port) # Socket to listen on port 2000
UI.verbose("Waiting for #{@connection_timeout} seconds for a connection from FastlaneRunner")
# set thread local to ready so we can check it
Thread.current[:ready] = true
@client = nil
begin
Timeout.timeout(@connection_timeout) do
@client = @server.accept # Wait for a client to connect
end
rescue Timeout::Error
UI.user_error!("fastlane failed to receive a connection from the FastlaneRunner binary after #{@connection_timeout} seconds, shutting down")
rescue StandardError => e
UI.user_error!("Something went wrong while waiting for a connection from the FastlaneRunner binary, shutting down\n#{e}")
end
UI.verbose("Client connected")
# this loops forever
receive_and_process_commands
end
def handle_disconnect(error: false, exit_reason: :error)
Thread.current[:exit_reason] = exit_reason
UI.important("Client disconnected, a pipe broke, or received malformed data") if exit_reason == :error
# clean up
@client.close
@client = nil
@server.close
@server = nil
end
# record fastlane action command and then execute it
def process_action_command(command: nil)
UI.verbose("received command:#{command.inspect}")
return execute_action_command(command: command)
end
# execute fastlane action command
def execute_action_command(command: nil)
command_return = @command_executor.execute(command: command, target_object: nil)
## probably need to just return Strings, or ready_for_next with object isn't String
return_object = command_return.return_value
return_value_type = command_return.return_value_type
closure_arg = command_return.closure_argument_value
return_object = return_value_processor.prepare_object(
return_value: return_object,
return_value_type: return_value_type
)
if closure_arg.nil?
closure_arg = closure_arg.to_s
else
closure_arg = return_value_processor.prepare_object(
return_value: closure_arg,
return_value_type: :string # always assume string for closure error_callback
)
end
Thread.current[:exception] = nil
payload = {
payload: {
status: "ready_for_next",
return_object: return_object,
closure_argument_value: closure_arg
}
}
return JSON.generate(payload)
rescue StandardError => e
Thread.current[:exception] = e
exception_array = []
exception_array << "#{e.class}:"
exception_array << e.backtrace
ec = e.class
em = e.message
while e.respond_to?("cause") && (e = e.cause)
exception_array << "cause: #{e.class}"
exception_array << e.backtrace
end
payload = {
payload: {
status: "failure",
failure_information: exception_array.flatten,
failure_class: ec,
failure_message: em
}
}
return JSON.generate(payload)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/json_return_value_processor.rb | fastlane/lib/fastlane/server/json_return_value_processor.rb | require 'json'
module Fastlane
class JSONReturnValueProcessor
def prepare_object(return_value: nil, return_value_type: nil)
case return_value_type
when nil
UI.verbose("return_value_type is nil value: #{return_value}")
return process_value_as_string(return_value: return_value)
when :string
return process_value_as_string(return_value: return_value)
when :int
return process_value_as_int(return_value: return_value)
when :bool
return process_value_as_bool(return_value: return_value)
when :array_of_strings
return process_value_as_array_of_strings(return_value: return_value)
when :hash_of_strings
return process_value_as_hash_of_strings(return_value: return_value)
when :hash
return process_value_as_hash_of_strings(return_value: return_value)
else
UI.verbose("Unknown return type defined: #{return_value_type} for value: #{return_value}")
return process_value_as_string(return_value: return_value)
end
end
def process_value_as_string(return_value: nil)
if return_value.nil?
return_value = ""
end
return_value
end
def process_value_as_array_of_strings(return_value: nil)
if return_value.nil?
return_value = []
end
# quirks_mode shouldn't be required for real objects
return JSON.generate(return_value)
end
def process_value_as_hash_of_strings(return_value: nil)
if return_value.nil?
return_value = {}
end
# quirks_mode shouldn't be required for real objects
return JSON.generate(return_value)
end
def process_value_as_bool(return_value: nil)
if return_value.nil?
return_value = false
end
# quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
return JSON.generate(return_value.to_s, quirks_mode: true)
end
def process_value_as_int(return_value: nil)
if return_value.nil?
return_value = 0
end
# quirks_mode because sometimes the built-in library is used for some folks and that needs quirks_mode: true
return JSON.generate(return_value.to_s, quirks_mode: true)
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/command_parser.rb | fastlane/lib/fastlane/server/command_parser.rb | require 'fastlane/server/action_command.rb'
require 'fastlane/server/control_command.rb'
require 'json'
module Fastlane
class CommandParser
def self.parse(json: nil)
if json.strip == "done"
return intercept_old_done_command
end
command_json = JSON.parse(json)
command_type_json = command_json['commandType']
if command_type_json.nil?
# Old Swift style (needs upgrade)
return handle_old_style_action_command(command_json: command_json)
else
# New Swift command style
return handle_new_style_commands(command_json: command_json)
end
end
def self.handle_new_style_commands(command_json: nil)
command_type = command_json['commandType'].to_sym
command = command_json['command']
case command_type
when :action
return ActionCommand.new(json: command)
when :control
return ControlCommand.new(json: command)
end
end
def self.handle_old_style_action_command(command_json: nil)
return ActionCommand.new(json: command_json)
end
def self.intercept_old_done_command
return ControlCommand.new(json: '{"command":"done"}')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/server/control_command.rb | fastlane/lib/fastlane/server/control_command.rb | module Fastlane
# Represents a command that is meant to signal the server to do something on the client's behalf
# Examples are: :cancelFastlaneRune, and :done
class ControlCommand
attr_reader :command
attr_reader :user_message
attr_reader :reason
def initialize(json: nil)
@command = json['command'].to_sym
@user_message = json['userMessage']
@reason = json['reason'].to_sym if json['reason']
end
def cancel_signal?
return @command == :cancelFastlaneRun
end
def done_signal?
return @command == :done
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/documentation/actions_list.rb | fastlane/lib/fastlane/documentation/actions_list.rb | module Fastlane
class ActionsList
def self.run(filter: nil, platform: nil)
require 'terminal-table'
if filter
show_details(filter: filter)
else
print_all(platform: platform)
end
end
def self.print_all(platform: nil)
rows = []
all_actions(platform) do |action, name|
current = []
if Fastlane::Actions.is_deprecated?(action)
current << "#{name} (DEPRECATED)".deprecated
else
current << name.yellow
end
if action < Action
current << action.description.to_s.remove_markdown if action.description
authors = Array(action.author || action.authors)
current << authors.first.green if authors.count == 1
current << "Multiple".green if authors.count > 1
else
UI.error(action_subclass_error(name))
current << "Please update action file".red
current << ' '
end
rows << current
end
puts(Terminal::Table.new(
title: "Available fastlane actions".green,
headings: ['Action', 'Description', 'Author'],
rows: FastlaneCore::PrintTable.transform_output(rows)
))
puts(" Platform filter: #{platform}".magenta) if platform
puts(" Total of #{rows.count} actions")
puts("\nGet more information for one specific action using `fastlane action [name]`\n".green)
end
def self.show_details(filter: nil)
puts("Loading documentation for #{filter}:".green)
puts("")
action = find_action_named(filter)
if action
unless action < Action
UI.user_error!(action_subclass_error(filter))
end
print_summary(action, filter)
print_options(action, filter)
print_output_variables(action, filter)
print_return_value(action, filter)
if Fastlane::Actions.is_deprecated?(action)
puts("==========================================".deprecated)
puts("This action (#{filter}) is deprecated".deprecated)
puts(action.deprecated_notes.to_s.remove_markdown.deprecated) if action.deprecated_notes
puts("==========================================\n".deprecated)
end
puts("More information can be found on https://docs.fastlane.tools/actions/#{filter}")
puts("")
else
puts("Couldn't find action for the given filter.".red)
puts("==========================================\n".red)
print_all # show all available actions instead
print_suggestions(filter)
end
end
def self.print_suggestions(filter)
if !filter.nil? && filter.length > 1
action_names = []
all_actions(nil) do |action_ref, action_name|
action_names << action_name
end
corrections = []
if defined?(DidYouMean::SpellChecker)
spell_checker = DidYouMean::SpellChecker.new(dictionary: action_names)
corrections << spell_checker.correct(filter).compact
end
corrections << action_names.select { |name| name.include?(filter) }
puts("Did you mean: #{corrections.flatten.uniq.join(', ')}?".green) unless corrections.flatten.empty?
end
end
def self.action_subclass_error(name)
"Please update your action '#{name}' to be a subclass of `Action` by adding ` < Action` after your class name."
end
def self.print_summary(action, name)
rows = []
if action.description
description = action.description.to_s.remove_markdown
rows << [description]
rows << [' ']
end
if action.details
details = action.details.to_s.remove_markdown
details.split("\n").each do |detail|
row = detail.empty? ? ' ' : detail
rows << [row]
end
rows << [' ']
end
authors = Array(action.author || action.authors)
rows << ["Created by #{authors.join(', ').green}"] unless authors.empty?
puts(Terminal::Table.new(title: name.green, rows: FastlaneCore::PrintTable.transform_output(rows)))
puts("")
end
def self.print_options(action, name)
options = parse_options(action.available_options) if action.available_options
if options
puts(Terminal::Table.new(
title: "#{name} Options".green,
headings: ['Key', 'Description', 'Env Var(s)', 'Default'],
rows: FastlaneCore::PrintTable.transform_output(options)
))
else
puts("No available options".yellow)
end
puts("* = default value is dependent on the user's system")
puts("")
end
def self.print_output_variables(action, name)
output = action.output
return if output.nil? || output.empty?
puts(Terminal::Table.new(
title: "#{name} Output Variables".green,
headings: ['Key', 'Description'],
rows: FastlaneCore::PrintTable.transform_output(output.map { |key, desc| [key.yellow, desc] })
))
puts("Access the output values using `lane_context[SharedValues::VARIABLE_NAME]`")
puts("")
end
def self.print_return_value(action, name)
return unless action.return_value
puts(Terminal::Table.new(title: "#{name} Return Value".green,
rows: FastlaneCore::PrintTable.transform_output([[action.return_value]])))
puts("")
end
# Iterates through all available actions and yields from there
def self.all_actions(platform = nil)
action_symbols = Fastlane::Actions.constants.select { |c| Fastlane::Actions.const_get(c).kind_of?(Class) && c != :TestSampleCodeAction }
action_symbols.sort.each do |symbol|
action = Fastlane::Actions.const_get(symbol)
# We allow classes that don't respond to is_supported? to come through because we want to list
# them as broken actions in the table, regardless of platform specification
next if platform && action.respond_to?(:is_supported?) && !action.is_supported?(platform.to_sym)
name = symbol.to_s.gsub(/Action$/, '').fastlane_underscore
yield(action, name)
end
end
def self.find_action_named(name)
all_actions do |action, action_name|
return action if action_name == name
end
nil
end
# Helper:
def self.parse_options(options, fill_all = true)
rows = []
rows << [options] if options.kind_of?(String)
if options.kind_of?(Array)
options.each do |current|
if current.kind_of?(FastlaneCore::ConfigItem)
rows << [current.key.to_s.yellow, current.deprecated ? current.description.red : current.description, current.env_names.join(", "), current.help_default_value]
elsif current.kind_of?(Array)
# Legacy actions that don't use the new config manager
UI.user_error!("Invalid number of elements in this row: #{current}. Must be 2 or 3") unless [2, 3].include?(current.count)
rows << current
rows.last[0] = rows.last.first.yellow # color it yellow :)
rows.last << nil while fill_all && rows.last.count < 4 # to have a nice border in the table
end
end
end
rows
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/documentation/markdown_docs_generator.rb | fastlane/lib/fastlane/documentation/markdown_docs_generator.rb | module Fastlane
class MarkdownDocsGenerator
attr_accessor :categories
def initialize
require 'fastlane'
require 'fastlane/documentation/actions_list'
Fastlane.load_actions
self.work
end
def work
fill_built_in_actions
end
def fill_built_in_actions
self.categories = {}
Fastlane::Action::AVAILABLE_CATEGORIES.each { |a| self.categories[readable_category_name(a)] = {} }
# Fill categories with all built-in actions
ActionsList.all_actions do |action|
readable = readable_category_name(action.category)
if self.categories[readable].kind_of?(Hash)
self.categories[readable][number_of_launches_for_action(action.action_name)] = action
else
UI.error("Action '#{action.name}' doesn't contain category information... skipping")
end
end
end
def number_of_launches_for_action(action_name)
found = all_actions_from_enhancer.find { |c| c['action'] == action_name.to_s }
return found["index"] if found
return 10_000 + rand # new actions that we've never tracked before will be shown at the bottom of the page, need `rand` to not overwrite them
end
def all_actions_from_enhancer
require 'json'
@_launches ||= JSON.parse(File.read(File.join(Fastlane::ROOT, "assets/action_ranking.json"))) # root because we're in a temporary directory here
end
def actions_path
"lib/fastlane/actions/"
end
def where_is(klass)
# Gets all source files for action
methods = klass.methods(false).map { |m| klass.method(m) }
source_files = methods
.map(&:source_location)
.compact
.map { |(file, line)| file }
.uniq
# Return file or error if multiples
if source_files.size == 1
return source_files.first
else
UI.crash!("Multiple source files were found for action `#{klass}`")
end
end
def filename_for_action(action)
absolute_path = where_is(action)
filename = File.basename(absolute_path)
path = File.join(Fastlane::ROOT, actions_path, filename)
unless File.exist?(path)
UI.error("Action '#{action.name}' not found in root fastlane project... skipping")
UI.verbose("Action '#{action.name}' found at #{path}")
return nil
end
filename
end
def custom_action_docs_path
"lib/fastlane/actions/docs/"
end
def load_custom_action_md(action)
# check if there is a custom detail view in markdown available in the fastlane code base
custom_file_location = File.join(Fastlane::ROOT, custom_action_docs_path, "#{action.action_name}.md")
if File.exist?(custom_file_location)
UI.verbose("Using custom md file for action #{action.action_name}")
return File.read(custom_file_location)
end
return load_custom_action_md_erb(action)
end
def load_custom_action_md_erb(action)
# check if there is a custom detail view as markdown ERB available in the fastlane code base
custom_file_location = File.join(Fastlane::ROOT, custom_action_docs_path, "#{action.action_name}.md.erb")
if File.exist?(custom_file_location)
UI.verbose("Using custom md.erb file for action #{action.action_name}")
result = ERB.new(File.read(custom_file_location), trim_mode: '-').result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
return result
end
return nil
end
def actions_md_contents
action_mds = {}
ActionsList.all_actions do |action|
@action = action
@action_filename = filename_for_action(action)
unless @action_filename
next
end
@custom_content = load_custom_action_md(action)
if action.superclass != Fastlane::Action
@custom_content ||= load_custom_action_md(action.superclass)
end
template = File.join(Fastlane::ROOT, "lib/assets/ActionDetails.md.erb")
result = ERB.new(File.read(template), trim_mode: '-').result(binding)
action_mds[action.action_name] = result
end
return action_mds
end
def generate!(target_path: nil)
require 'yaml'
FileUtils.mkdir_p(target_path)
docs_dir = File.join(target_path, "docs")
generated_actions_dir = File.join("generated", "actions")
FileUtils.mkdir_p(File.join(docs_dir, generated_actions_dir))
# Generate actions.md
template = File.join(Fastlane::ROOT, "lib/assets/Actions.md.erb")
result = ERB.new(File.read(template), trim_mode: '-').result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
File.write(File.join(docs_dir, "generated", "actions.md"), result)
# Generate actions sub pages (e.g. generated/actions/slather.md, generated/actions/scan.md)
all_actions_ref_yml = []
FileUtils.mkdir_p(File.join(docs_dir, generated_actions_dir))
ActionsList.all_actions do |action|
@action = action # to provide a reference in the .html.erb template
@action_filename = filename_for_action(action)
unless @action_filename
next
end
# Make sure to always assign `@custom_content`, as we're in a loop and `@` is needed for the `erb`
@custom_content = load_custom_action_md(action)
if action.superclass != Fastlane::Action
# This means, the current method is an alias
# meaning we're gonna look if the parent class
# has a custom md file.
# e.g. `DeliverAction`'s superclass is `UploadToAppStoreAction`
@custom_content ||= load_custom_action_md(action.superclass)
end
template = File.join(Fastlane::ROOT, "lib/assets/ActionDetails.md.erb")
result = ERB.new(File.read(template), trim_mode: '-').result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
# Actions get placed in "generated/actions" directory
file_name = File.join(generated_actions_dir, "#{action.action_name}.md")
File.write(File.join(docs_dir, file_name), result)
# The action pages when published get moved to the "actions" directory
# The mkdocs.yml file needs to reference the "actions" directory (not the "generated/actions" directory)
published_file_name = File.join("actions", "#{action.action_name}.md")
all_actions_ref_yml << { action.action_name => published_file_name }
end
# Modify the mkdocs.yml to list all the actions
mkdocs_yml_path = File.join(target_path, "mkdocs.yml")
raise "Could not find mkdocs.yml in #{target_path}, make sure to point to the fastlane/docs repo" unless File.exist?(mkdocs_yml_path)
mkdocs_yml = YAML.load_file(mkdocs_yml_path)
hidden_actions_array = mkdocs_yml["nav"].find { |p| !p["_Actions"].nil? }
hidden_actions_array["_Actions"] = all_actions_ref_yml
File.write(mkdocs_yml_path, mkdocs_yml.to_yaml)
# Copy over the assets from the `actions/docs/assets` directory
Dir[File.join(custom_action_docs_path, "assets", "*")].each do |current_asset_path|
UI.message("Copying asset #{current_asset_path}")
FileUtils.cp(current_asset_path, File.join(docs_dir, "img", "actions", File.basename(current_asset_path)))
end
UI.success("Generated new docs on path #{target_path}")
end
private
def readable_category_name(category_symbol)
case category_symbol
when :misc
"Misc"
when :source_control
"Source Control"
when :notifications
"Notifications"
when :code_signing
"Code Signing"
when :documentation
"Documentation"
when :testing
"Testing"
when :building
"Building"
when :push
"Push"
when :screenshots
"Screenshots"
when :project
"Project"
when :beta
"Beta"
when :production
"Releasing your app"
when :app_store_connect
"App Store Connect"
when :deprecated
"Deprecated"
else
category_symbol.to_s.capitalize
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/documentation/docs_generator.rb | fastlane/lib/fastlane/documentation/docs_generator.rb | module Fastlane
class DocsGenerator
def self.run(ff, output_path = nil)
output_path ||= File.join(FastlaneCore::FastlaneFolder.path || '.', 'README.md')
output = ["fastlane documentation"]
output << "----"
output << ""
output << "# Installation"
output << ""
output << "Make sure you have the latest version of the Xcode command line tools installed:"
output << ""
output << "```sh"
output << "xcode-select --install"
output << "```"
output << ""
output << "For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)"
output << ""
output << "# Available Actions"
all_keys = ff.runner.lanes.keys.reject(&:nil?)
all_keys.unshift(nil) # because we want root elements on top. always! They have key nil
all_keys.each do |platform|
lanes = ff.runner.lanes[platform]
if lanes.nil? || lanes.empty? || lanes.all? { |_, lane| lane.is_private }
next
end
if platform
output << ""
output << "## #{formatted_platform(platform)}"
end
lanes.each do |lane_name, lane|
next if lane.is_private
output << render(platform, lane_name, lane.description.join("\n\n"))
end
output << ""
output << "----"
output << ""
end
output << "This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run."
output << ""
output << "More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools)."
output << ""
output << "The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools)."
output << ""
begin
File.write(output_path, output.join("\n"))
UI.success("Successfully generated documentation at path '#{File.expand_path(output_path)}'") if FastlaneCore::Globals.verbose?
rescue => ex
UI.error(ex)
UI.error("Couldn't save fastlane documentation at path '#{File.expand_path(output_path)}', make sure you have write access to the containing directory.")
end
end
#####################################################
# @!group Helper
#####################################################
def self.formatted_platform(pl)
pl = pl.to_s
return "iOS" if pl == 'ios'
return "Mac" if pl == 'mac'
return "Android" if pl == 'android'
return pl
end
# @param platform [String]
# @param lane [Fastlane::Lane]
# @param description [String]
def self.render(platform, lane, description)
full_name = [platform, lane].reject(&:nil?).join(' ')
output = []
output << ""
output << "### #{full_name}"
output << ""
output << "```sh"
output << "[bundle exec] fastlane #{full_name}"
output << "```"
output << ""
output << description
output
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/spec/commands_generator_spec.rb | supply/spec/commands_generator_spec.rb | require 'supply/commands_generator'
require 'supply/setup'
describe Supply::CommandsGenerator do
def expect_uploader_perform_upload
fake_uploader = "uploader"
expect(Supply::Uploader).to receive(:new).and_return(fake_uploader)
expect(fake_uploader).to receive(:perform_upload)
end
def expect_setup_perform_download
fake_setup = "setup"
expect(Supply::Setup).to receive(:new).and_return(fake_setup)
expect(fake_setup).to receive(:perform_download)
end
describe ":run options handling" do
it "can use the skip_upload_metadata flag from tool options" do
# leaving out the command name defaults to 'run'
stub_commander_runner_args(['--skip_upload_metadata'])
expect_uploader_perform_upload
Supply::CommandsGenerator.start
expect(Supply.config[:skip_upload_metadata]).to be(true)
end
end
describe ":init options handling" do
it "can use the package_name short flag from tool options" do
stub_commander_runner_args(['init', '-p', 'com.test.package'])
expect_setup_perform_download
Supply::CommandsGenerator.start
expect(Supply.config[:package_name]).to eq('com.test.package')
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/spec/client_spec.rb | supply/spec/client_spec.rb | describe Supply do
describe Supply::Client do
let(:service_account_file) { File.read(fixture_file("sample-service-account.json")) }
let(:external_account_file) { File.read(fixture_file("sample-external-account.json")) }
before do
stub_request(:post, "https://www.googleapis.com/oauth2/v4/token").
to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://androidpublisher.googleapis.com/androidpublisher/v3/applications/test-app/edits").
to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
end
describe "initialize client" do
it "with external account credentials" do
stub_request(:get, "https://credential-source.example.com/token").
to_return(status: 200, body: '{"value": "access-token"}', headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://sts.googleapis.com/v1/token").
to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/fastlane@fastlane-tools.iam.gserviceaccount.com:generateAccessToken").
to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
Supply::Client.new(service_account_json: StringIO.new(external_account_file), params: { timeout: 1 })
end
it "with external account credentials from file" do
stub_request(:get, "https://credential-source.example.com/token").
to_return(status: 200, body: '{"value": "access-token"}', headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://sts.googleapis.com/v1/token").
to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
stub_request(:post, "https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/fastlane@fastlane-tools.iam.gserviceaccount.com:generateAccessToken").
to_return(status: 200, body: '{}', headers: { 'Content-Type' => 'application/json' })
file_path = fixture_file("sample-external-account.json")
Supply::Client.make_from_config(params: { json_key: file_path, timeout: 1 })
end
end
describe "displays error messages from the API" do
it "with no retries" do
stub_request(:post, "https://androidpublisher.googleapis.com/upload/androidpublisher/v3/applications/test-app/edits/1/listings/en-US/icon").
to_return(status: 403, body: '{"error":{"message":"Ensure project settings are enabled."}}', headers: { 'Content-Type' => 'application/json' })
current_edit = double
allow(current_edit).to receive(:id).and_return(1)
client = Supply::Client.new(service_account_json: StringIO.new(service_account_file), params: { timeout: 1 })
allow(client).to receive(:ensure_active_edit!)
allow(client).to receive(:current_edit).and_return(current_edit)
client.begin_edit(package_name: 'test-app')
expect {
client.upload_image(image_path: fixture_file("playstore-icon.png"),
image_type: "icon",
language: "en-US")
}.to raise_error(FastlaneCore::Interface::FastlaneError, "Google Api Error: Invalid request - Ensure project settings are enabled.")
end
it "displays error messages for invalid json" do
expect {
Supply::Client.new(service_account_json: StringIO.new("{/asdf"), params: { timeout: 1 })
}.to raise_error(FastlaneCore::Interface::FastlaneError, "Invalid Google Credentials file provided - unable to parse json.")
end
it "displays error messages for missing credential type" do
expect {
Supply::Client.new(service_account_json: StringIO.new("{}"), params: { timeout: 1 })
}.to raise_error(FastlaneCore::Interface::FastlaneError, "Invalid Google Credentials file provided - no credential type found.")
end
it "with 5 retries" do
stub_const("ENV", { 'SUPPLY_UPLOAD_MAX_RETRIES' => 5 })
stub_request(:post, "https://androidpublisher.googleapis.com/upload/androidpublisher/v3/applications/test-app/edits/1/listings/en-US/icon").
to_return(status: 403, body: '{"error":{"message":"Ensure project settings are enabled."}}', headers: { 'Content-Type' => 'application/json' })
expect(UI).to receive(:error).with("Google Api Error: Invalid request - Ensure project settings are enabled. - Retrying...").exactly(5).times
current_edit = double
allow(current_edit).to receive(:id).and_return(1)
client = Supply::Client.new(service_account_json: StringIO.new(service_account_file), params: { timeout: 1 })
allow(client).to receive(:ensure_active_edit!)
allow(client).to receive(:current_edit).and_return(current_edit)
client.begin_edit(package_name: 'test-app')
expect {
client.upload_image(image_path: fixture_file("playstore-icon.png"),
image_type: "icon",
language: "en-US")
}.to raise_error(FastlaneCore::Interface::FastlaneError, "Google Api Error: Invalid request - Ensure project settings are enabled.")
end
end
describe "AndroidPublisher" do
let(:subject) { AndroidPublisher::AndroidPublisherService.new }
# Verify that the Google API client has all the expected methods we use.
it "has all the expected Google API methods" do
expect(subject.class.method_defined?(:insert_edit)).to eq(true)
expect(subject.class.method_defined?(:delete_edit)).to eq(true)
expect(subject.class.method_defined?(:validate_edit)).to eq(true)
expect(subject.class.method_defined?(:commit_edit)).to eq(true)
expect(subject.class.method_defined?(:list_edit_listings)).to eq(true)
expect(subject.class.method_defined?(:get_edit_listing)).to eq(true)
expect(subject.class.method_defined?(:list_edit_apks)).to eq(true)
expect(subject.class.method_defined?(:list_edit_bundles)).to eq(true)
expect(subject.class.method_defined?(:list_generatedapks)).to eq(true)
expect(subject.class.method_defined?(:download_generatedapk)).to eq(true)
expect(subject.class.method_defined?(:update_edit_listing)).to eq(true)
expect(subject.class.method_defined?(:upload_edit_apk)).to eq(true)
expect(subject.class.method_defined?(:upload_edit_deobfuscationfile)).to eq(true)
expect(subject.class.method_defined?(:upload_edit_bundle)).to eq(true)
expect(subject.class.method_defined?(:list_edit_tracks)).to eq(true)
expect(subject.class.method_defined?(:update_edit_track)).to eq(true)
expect(subject.class.method_defined?(:get_edit_track)).to eq(true)
expect(subject.class.method_defined?(:update_edit_track)).to eq(true)
expect(subject.class.method_defined?(:update_edit_expansionfile)).to eq(true)
expect(subject.class.method_defined?(:list_edit_images)).to eq(true)
expect(subject.class.method_defined?(:upload_edit_image)).to eq(true)
expect(subject.class.method_defined?(:deleteall_edit_image)).to eq(true)
expect(subject.class.method_defined?(:delete_edit_image)).to eq(true)
expect(subject.class.method_defined?(:upload_edit_expansionfile)).to eq(true)
expect(subject.class.method_defined?(:uploadapk_internalappsharingartifact)).to eq(true)
expect(subject.class.method_defined?(:uploadbundle_internalappsharingartifact)).to eq(true)
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/spec/uploader_spec.rb | supply/spec/uploader_spec.rb | require 'fileutils'
describe Supply do
describe Supply::Uploader do
describe "#verify_config!" do
let(:subject) { Supply::Uploader.new }
it "raises error if empty config" do
Supply.config = {}
expect do
subject.verify_config!
end.to raise_error("No local metadata, apks, aab, or track to promote were found, make sure to run `fastlane supply init` to setup supply")
end
it "raises error if only track" do
Supply.config = {
track: 'alpha'
}
expect do
subject.verify_config!
end.to raise_error("No local metadata, apks, aab, or track to promote were found, make sure to run `fastlane supply init` to setup supply")
end
it "raises error if only track_promote_to" do
Supply.config = {
track_promote_to: 'beta'
}
expect do
subject.verify_config!
end.to raise_error("No local metadata, apks, aab, or track to promote were found, make sure to run `fastlane supply init` to setup supply")
end
it "does not raise error if only metadata" do
Supply.config = {
metadata_path: 'some/path'
}
subject.verify_config!
end
it "does not raise error if only apk" do
Supply.config = {
apk: 'some/path/app.apk'
}
subject.verify_config!
end
it "does not raise error if only apk_paths" do
Supply.config = {
apk_paths: ['some/path/app1.apk', 'some/path/app2.apk']
}
subject.verify_config!
end
it "does not raise error if only aab" do
Supply.config = {
aab: 'some/path/app1.aab'
}
subject.verify_config!
end
it "does not raise error if only aab_paths" do
Supply.config = {
aab_paths: ['some/path/app1.aab', 'some/path/app2.aab']
}
subject.verify_config!
end
it "does not raise error if only track and track_promote_to" do
Supply.config = {
track: 'alpha',
track_promote_to: 'beta'
}
subject.verify_config!
end
end
describe "#find_obbs" do
let(:subject) { Supply::Uploader.new }
before(:all) do
@obb_dir = Dir.mktmpdir('supply')
@apk_path = File.join(@obb_dir, 'my.apk')
# Makes Supply::Uploader.new.all_languages public for testing reasons
Supply::Uploader.send(:public, *Supply::Uploader.private_instance_methods)
end
def create_obb(name)
path = "#{@obb_dir}/#{name}"
FileUtils.touch(path)
path
end
before do
FileUtils.rm_rf(Dir.glob("#{@obb_dir}/*.obb"))
end
def find_obbs
subject.send(:find_obbs, @apk_path)
end
it "finds no obb when there's none to find" do
expect(find_obbs.count).to eq(0)
end
it "skips unrecognized obbs" do
main_obb = create_obb('unknown.obb')
expect(find_obbs.count).to eq(0)
end
it "finds one match and one patch obb" do
main_obb = create_obb('main.obb')
patch_obb = create_obb('patch.obb')
obbs = find_obbs
expect(obbs.count).to eq(2)
expect(obbs).to eq({ 'main' => main_obb, 'patch' => patch_obb })
end
it "finds zero obb if too main mains" do
create_obb('main.obb')
create_obb('other.main.obb')
obbs = find_obbs
expect(obbs.count).to eq(0)
end
it "finds zero obb if too many patches" do
create_obb('patch.obb')
create_obb('patch.other.obb')
obbs = find_obbs
expect(obbs.count).to eq(0)
end
end
describe 'metadata encoding' do
it 'prints a user friendly error message if metadata is not UTF-8 encoded' do
fake_config = 'fake config'
allow(fake_config).to receive(:[]).and_return('fake config value')
Supply.config = fake_config
allow(File).to receive(:exist?).and_return(true)
allow(File).to receive(:read).and_return("fake content")
fake_listing = "listing"
Supply::AVAILABLE_METADATA_FIELDS.each do |field|
allow(fake_listing).to receive("#{field}=".to_sym)
end
expect(fake_listing).to receive(:save).and_raise(Encoding::InvalidByteSequenceError)
expect(FastlaneCore::UI).to receive(:user_error!).with(/Metadata must be UTF-8 encoded./)
Supply::Uploader.new.upload_metadata('en-US', fake_listing)
end
end
describe 'all_languages' do
it 'only grabs directories' do
Supply.config = {
metadata_path: 'supply/spec/fixtures/metadata/android'
}
only_directories = Supply::Uploader.new.all_languages
expect(only_directories).to eq(['en-US', 'fr-FR', 'ja-JP'])
end
end
describe 'promote_track' do
subject { Supply::Uploader.new.promote_track }
let(:client) { double('client') }
let(:version_codes) { [1, 2, 3] }
let(:config) {
{
release_status: Supply::ReleaseStatus::COMPLETED,
track_promote_release_status: Supply::ReleaseStatus::COMPLETED,
track: 'alpha',
track_promote_to: 'beta'
}
}
let(:track) { double('alpha') }
let(:release) { double('release1') }
before do
Supply.config = config
allow(Supply::Client).to receive(:make_from_config).and_return(client)
allow(client).to receive(:tracks).and_return([track])
allow(track).to receive(:releases).and_return([release])
allow(track).to receive(:releases=)
allow(client).to receive(:track_version_codes).and_return(version_codes)
allow(client).to receive(:update_track).with(config[:track], 0.1, nil)
allow(client).to receive(:update_track).with(config[:track_promote_to], 0.1, version_codes)
allow(release).to receive(:status).and_return(Supply::ReleaseStatus::COMPLETED)
end
it 'should only update track once' do
expect(release).to receive(:status=).with(Supply::ReleaseStatus::COMPLETED)
expect(release).to receive(:user_fraction=).with(nil)
expect(client).not_to(receive(:update_track).with(config[:track], anything))
expect(client).to receive(:update_track).with(config[:track_promote_to], track).once
subject
end
end
# add basic == functionality to LocalizedText class for testing purpose
class AndroidPublisher::LocalizedText
def ==(other)
self.language == other.language && self.text == other.text
end
end
shared_examples 'run supply to upload metadata' do |version_codes:, with_explicit_changelogs:|
let(:languages) { ['en-US', 'fr-FR', 'ja-JP'] }
subject(:release) { double('release', version_codes: version_codes) }
let(:client) { double('client') }
let(:config) { { apk_paths: version_codes.map { |v_code| "some/path/app-v#{v_code}.apk" }, metadata_path: 'supply/spec/fixtures/metadata/android', track: 'track-name' } }
before do
Supply.config = config
allow(Supply::Client).to receive(:make_from_config).and_return(client)
version_codes.each do |version_code|
allow(client).to receive(:upload_apk).with("some/path/app-v#{version_code}.apk").and_return(version_code) # newly uploaded version code
end
allow(client).to receive(:upload_changelogs).and_return(nil)
allow(client).to receive(:tracks).with('track-name').and_return([double('tracks', releases: [ release ])])
languages.each do |lang|
allow(client).to receive(:listing_for_language).with(lang).and_return(Supply::Listing.new(client, lang))
end
allow(client).to receive(:begin_edit).and_return(nil)
allow(client).to receive(:commit_current_edit!).and_return(nil)
end
it 'should update track with correct version codes and optional changelog' do
uploader = Supply::Uploader.new
expect(uploader).to receive(:update_track).with(version_codes).once
version_codes.each do |version_code|
expected_notes = languages.map do |lang|
AndroidPublisher::LocalizedText.new(
language: lang,
text: "#{lang} changelog #{with_explicit_changelogs ? version_code : -1}"
)
end.uniq
# check if at least one of the assignments of release_notes is what we expect
expect(release).to receive(:release_notes=).with(match_array(expected_notes))
# check if the listings are updated for each language with text data from disk
languages.each do |lang|
expect(client).to receive(:update_listing_for_language).with({ language: lang, full_description: "#{lang} full description", short_description: "#{lang} short description", title: "#{lang} title", video: "#{lang} video" })
end
end
uploader.perform_upload
end
end
describe '#perform_upload with metadata' do
it_behaves_like 'run supply to upload metadata', version_codes: [1, 2], with_explicit_changelogs: true
it_behaves_like 'run supply to upload metadata', version_codes: [3], with_explicit_changelogs: false
end
context 'when sync_image_upload is set' do
let(:client) { double('client') }
let(:language) { 'pt-BR' }
let(:config) { { metadata_path: 'spec_metadata', sync_image_upload: true } }
before do
Supply.config = config
allow(Supply::Client).to receive(:make_from_config).and_return(client)
expect(client).not_to receive(:clear_screenshots)
end
describe '#upload_images' do
it 'should upload and replace image if sha256 does not match remote image' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "sha256-of-#{file}") }
allow(Dir).to receive(:glob).and_return(['image.png'])
remote_images = [Supply::ImageListing.new('id123', '_unused_', 'different-remote-sha256', '_unused_')]
Supply::IMAGES_TYPES.each do |image_type|
allow(client).to receive(:fetch_images).with(image_type: image_type, language: language).and_return(remote_images)
expect(client).to receive(:upload_image).with(image_path: File.expand_path('image.png'), image_type: image_type, language: language)
end
uploader = Supply::Uploader.new
uploader.upload_images(language)
end
it 'should skip image upload if sha256 matches remote image' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "sha256-of-#{file}") }
allow(Dir).to receive(:glob).and_return(['image.png'])
remote_images = [Supply::ImageListing.new('id123', '_unused_', 'sha256-of-image.png', '_unused_')]
Supply::IMAGES_TYPES.each do |image_type|
allow(client).to receive(:fetch_images).with(image_type: image_type, language: language).and_return(remote_images)
expect(client).not_to receive(:upload_image).with(image_path: File.expand_path('image.png'), image_type: image_type, language: language)
end
uploader = Supply::Uploader.new
uploader.upload_images(language)
end
end
describe '#upload_screenshots' do
it 'should upload and replace all screenshots if no sha256 matches any remote screenshot' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "local-sha256-of-#{file}") }
local_images = %w[image1.png image2.png image3.png]
allow(Dir).to receive(:glob).and_return(local_images)
remote_images = [1, 2, 3].map do |idx|
Supply::ImageListing.new("id_#{idx}", '_unused_', "remote-sha256-#{idx}", '_unused_')
end
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
allow(client).to receive(:fetch_images).with(image_type: screenshot_type, language: language).and_return(remote_images)
remote_images.each do |image|
expect(client).to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: image.id)
end
local_images.each do |path|
expect(client).to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
end
uploader = Supply::Uploader.new
uploader.upload_screenshots(language)
end
it 'should skip all screenshots if all sha256 matches the remote screenshots' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "common-sha256-of-#{file}") }
local_images = %w[image1.png image2.png image3.png]
allow(Dir).to receive(:glob).and_return(local_images)
remote_images = local_images.map do |path|
Supply::ImageListing.new("id_#{path}", '_unused_', "common-sha256-of-#{path}", '_unused_')
end
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
allow(client).to receive(:fetch_images).with(image_type: screenshot_type, language: language).and_return(remote_images)
remote_images.each do |image|
expect(client).not_to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: image.id)
end
local_images.each do |path|
expect(client).not_to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
end
uploader = Supply::Uploader.new
uploader.upload_screenshots(language)
end
it 'should delete and re-upload screenshots that changed locally, as long as start of list is in order' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "sha256-of-#{file}") }
local_images = %w[image0.png image1.png new-image2.png new-image3.png]
allow(Dir).to receive(:glob).and_return(local_images)
remote_images = %w[image0.png image1.png old-image2.png old-image3.png].map.with_index do |path, idx|
Supply::ImageListing.new("id_#{idx}", '_unused_', "sha256-of-#{path}", '_unused_')
end
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
allow(client).to receive(:fetch_images).with(image_type: screenshot_type, language: language).and_return(remote_images)
local_images[0..1].each_with_index do |path, idx|
expect(client).not_to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: "id_#{idx}")
expect(client).not_to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
local_images[2..3].each_with_index do |path, idx|
expect(client).to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: "id_#{idx + 2}")
expect(client).to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
end
uploader = Supply::Uploader.new
uploader.upload_screenshots(language)
end
it 'should delete remote screenshots that are no longer present locally' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "common-sha256-of-#{file}") }
local_images = %w[image1.png image2.png image3.png]
allow(Dir).to receive(:glob).and_return(local_images)
same_remote_images = local_images.map do |path|
Supply::ImageListing.new("id_#{path}", '_unused_', "common-sha256-of-#{path}", '_unused_')
end
extra_remote_image = Supply::ImageListing.new("id_extra", '_unused_', "common-sha256-of-extra-image", '_unused_')
remote_images = [same_remote_images[0], extra_remote_image, same_remote_images[1], same_remote_images[2]]
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
allow(client).to receive(:fetch_images).with(image_type: screenshot_type, language: language).and_return(remote_images)
same_remote_images.each do |image|
expect(client).not_to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: image.id)
end
expect(client).to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: extra_remote_image.id)
local_images.each do |path|
expect(client).not_to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
end
uploader = Supply::Uploader.new
uploader.upload_screenshots(language)
end
it 'should delete screenshots that are out of order and re-upload them in the correct order' do
allow(Digest::SHA256).to receive(:file) { |file| instance_double(Digest::SHA256, hexdigest: "sha256-of-#{file}") }
local_images = %w[image0.png image1.png image2.png image4.png image3.png image5.png image6.png] # those will be sorted after Dir.glob
allow(Dir).to receive(:glob).and_return(local_images)
# Record the mocked deletions and uploads in list of remote images to check the final state at the end
final_remote_images_ids = {}
allow(client).to receive(:clear_screenshot) do |**args|
image_type = args[:image_id].split('_')[1]
final_remote_images_ids[image_type].delete(args[:image_id])
end
allow(client).to receive(:upload_image) do |**args|
path = File.basename(args[:image_path])
image_type = args[:image_type]
final_remote_images_ids[image_type] << "new-id_#{image_type}_#{path}"
end
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
remote_images = local_images.map do |path|
Supply::ImageListing.new("id_#{screenshot_type}_#{path}", '_unused_', "sha256-of-#{path}", '_unused_')
end # remote images will be in order 0124356 though
allow(client).to receive(:fetch_images).with(image_type: screenshot_type, language: language).and_return(remote_images)
final_remote_images_ids[screenshot_type] = remote_images.map(&:id)
# We should skip image0, image1, image2 from remote as they are the same as the first local images,
# But also skip image3 (which was after image4 in remote listing, but is still present in local images)
# While deleting image4 (because it was in-between image2 and image3 in the `remote_images`, so out of order)
# And finally deleting image5 and image6, before re-uploading image4, image5 and image6 in the right order
local_images.sort[0..3].each do |path|
expect(client).not_to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: "id_#{screenshot_type}_#{path}")
expect(client).not_to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
local_images.sort[4..6].each do |path|
expect(client).to receive(:clear_screenshot).with(image_type: screenshot_type, language: language, image_id: "id_#{screenshot_type}_#{path}")
expect(client).to receive(:upload_image).with(image_path: File.expand_path(path), image_type: screenshot_type, language: language)
end
end
uploader = Supply::Uploader.new
uploader.upload_screenshots(language)
# Check the final order of the remote images after the whole skip/delete/upload dance
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
expected_final_images_ids = %W[
id_#{screenshot_type}_image0.png
id_#{screenshot_type}_image1.png
id_#{screenshot_type}_image2.png
id_#{screenshot_type}_image3.png
new-id_#{screenshot_type}_image4.png
new-id_#{screenshot_type}_image5.png
new-id_#{screenshot_type}_image6.png
]
expect(final_remote_images_ids[screenshot_type]).to eq(expected_final_images_ids)
end
end
end
end
describe '#update_rollout' do
let(:subject) { Supply::Uploader.new }
let(:client) { double('client') }
let(:version_code) { 123 }
let(:config) { { track: 'alpha' } }
let(:release) { AndroidPublisher::TrackRelease.new }
let(:track) { AndroidPublisher::Track.new }
before do
Supply.config = config
allow(Supply::Client).to receive(:make_from_config).and_return(client)
allow(client).to receive(:tracks).with('alpha').and_return([track])
allow(release).to receive(:version_codes).and_return([version_code])
allow(client).to receive(:update_track)
end
shared_examples 'updates track with correct status and rollout' do |rollout:, release_status:, expected_status:, expected_user_fraction:|
before do
release.status = Supply::ReleaseStatus::IN_PROGRESS
track.releases = [release]
config[:rollout] = rollout
config[:release_status] = release_status
end
it "sets status to #{expected_status} and user_fraction to #{expected_user_fraction.inspect}" do
expect(client).to receive(:update_track).with('alpha', track) do |_, track_param|
expect(track_param.releases).to eq([release])
expect(track_param.releases.first.status).to eq(expected_status)
expect(track_param.releases.first.user_fraction).to eq(expected_user_fraction)
end
subject.update_rollout
end
end
shared_examples 'raises error for invalid rollout' do |rollout:, release_status:, expected_error:|
before do
release.status = Supply::ReleaseStatus::IN_PROGRESS
track.releases = [release]
config[:rollout] = rollout
config[:release_status] = release_status
end
it 'raises an error' do
expect { subject.update_rollout }.to raise_error(expected_error)
end
end
context 'when rollout is nil' do
context 'when release_status is DRAFT' do
include_examples 'updates track with correct status and rollout',
rollout: nil,
release_status: Supply::ReleaseStatus::DRAFT,
expected_status: Supply::ReleaseStatus::DRAFT,
expected_user_fraction: nil
end
context 'when release_status is IN_PROGRESS' do
include_examples 'raises error for invalid rollout',
rollout: nil,
release_status: Supply::ReleaseStatus::IN_PROGRESS,
expected_error: /You need to provide a rollout value when release_status is set to 'inProgress'/
end
context 'when release_status is COMPLETED' do
include_examples 'updates track with correct status and rollout',
rollout: nil,
release_status: Supply::ReleaseStatus::COMPLETED,
expected_status: Supply::ReleaseStatus::COMPLETED,
expected_user_fraction: nil
end
end
context 'when rollout is 0.5' do
context 'when release_status is DRAFT' do
include_examples 'updates track with correct status and rollout',
rollout: 0.5,
release_status: Supply::ReleaseStatus::DRAFT,
expected_status: Supply::ReleaseStatus::DRAFT,
expected_user_fraction: nil # user_fraction is only valid for IN_PROGRESS or HALTED status
end
context 'when release_status is IN_PROGRESS' do
include_examples 'updates track with correct status and rollout',
rollout: 0.5,
release_status: Supply::ReleaseStatus::IN_PROGRESS,
expected_status: Supply::ReleaseStatus::IN_PROGRESS,
expected_user_fraction: 0.5
end
context 'when release_status is COMPLETED' do
include_examples 'updates track with correct status and rollout',
rollout: 0.5,
release_status: Supply::ReleaseStatus::COMPLETED,
# We want to ensure the implementation forces status of IN_PROGRESS when explicit rollout < 1.0 is provided
expected_status: Supply::ReleaseStatus::IN_PROGRESS,
expected_user_fraction: 0.5
end
end
context 'when rollout is 1.0' do
context 'when release_status is DRAFT' do
include_examples 'updates track with correct status and rollout',
rollout: 1.0,
release_status: Supply::ReleaseStatus::DRAFT,
expected_status: Supply::ReleaseStatus::DRAFT,
expected_user_fraction: nil # user_fraction is only valid for IN_PROGRESS or HALTED status
end
context 'when release_status is IN_PROGRESS' do
include_examples 'updates track with correct status and rollout',
rollout: 1.0,
release_status: Supply::ReleaseStatus::IN_PROGRESS,
# We want to ensure the implementation forces status of COMPLETED when explicit rollout = 1.0 is provided
expected_status: Supply::ReleaseStatus::COMPLETED,
expected_user_fraction: nil
end
context 'when release_status is COMPLETED' do
include_examples 'updates track with correct status and rollout',
rollout: 1.0,
release_status: Supply::ReleaseStatus::COMPLETED,
expected_status: Supply::ReleaseStatus::COMPLETED,
expected_user_fraction: nil
end
end
context 'when track is not found' do
before do
allow(client).to receive(:tracks).with('alpha').and_return([])
end
it 'raises an error' do
expect { subject.update_rollout }.to raise_error(/Unable to find the requested track/)
end
end
context 'when release is not found' do
before do
allow(track).to receive(:releases).and_return([])
end
it 'raises an error' do
expect { subject.update_rollout }.to raise_error(/Unable to find the requested release on track/)
end
end
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/spec/spec_helper.rb | supply/spec/spec_helper.rb | def fixture_file(path)
File.join(File.dirname(__FILE__), "fixtures", path)
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply.rb | supply/lib/supply.rb | require 'json'
require 'supply/options'
require 'supply/client'
require 'supply/listing'
require 'supply/apk_listing'
require 'supply/image_listing'
require 'supply/generated_universal_apk'
require 'supply/release_listing'
require 'supply/uploader'
require 'supply/languages'
require 'fastlane_core'
module Supply
# Use this to just setup the configuration attribute and set it later somewhere else
class << self
attr_accessor :config
end
AVAILABLE_METADATA_FIELDS = %w(title short_description full_description video)
IMAGES_TYPES = %w(featureGraphic icon tvBanner) # https://developers.google.com/android-publisher/api-ref/rest/v3/AppImageType
SCREENSHOT_TYPES = %w(phoneScreenshots sevenInchScreenshots tenInchScreenshots tvScreenshots wearScreenshots)
IMAGES_FOLDER_NAME = "images"
IMAGE_FILE_EXTENSIONS = "{png,jpg,jpeg}"
CHANGELOGS_FOLDER_NAME = "changelogs"
# https://developers.google.com/android-publisher/#publishing
module Tracks
PRODUCTION = "production"
BETA = "beta"
ALPHA = "alpha"
INTERNAL = "internal"
DEFAULTS = [PRODUCTION, BETA, ALPHA, INTERNAL]
DEFAULT = PRODUCTION
end
# https://developers.google.com/android-publisher/api-ref/edits/tracks
module ReleaseStatus
COMPLETED = "completed"
DRAFT = "draft"
HALTED = "halted"
IN_PROGRESS = "inProgress"
ALL = [COMPLETED, DRAFT, HALTED, IN_PROGRESS]
end
Helper = FastlaneCore::Helper # you gotta love Ruby: Helper.* should use the Helper class contained in FastlaneCore
UI = FastlaneCore::UI
Boolean = Fastlane::Boolean
ROOT = Pathname.new(File.expand_path('../..', __FILE__))
DESCRIPTION = "Command line tool for updating Android apps and their metadata on the Google Play Store".freeze
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply/release_listing.rb | supply/lib/supply/release_listing.rb | module Supply
class ReleaseListing
attr_accessor :track
attr_accessor :version
attr_accessor :versioncodes
attr_accessor :language
attr_accessor :release_notes
# Initializes the release listing with the current listing if available
def initialize(track, version, versioncodes, language, text)
self.track = track
self.version = version
self.versioncodes = versioncodes
self.language = language
self.release_notes = text
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply/setup.rb | supply/lib/supply/setup.rb | module Supply
class Setup
def perform_download
UI.message("🕗 Downloading metadata, images, screenshots...")
if File.exist?(metadata_path)
UI.important("Metadata already exists at path '#{metadata_path}'")
return
end
client.begin_edit(package_name: Supply.config[:package_name])
client.listings.each do |listing|
store_metadata(listing)
download_images(listing)
end
if Supply.config[:version_name].to_s == ""
latest_version = client.latest_version(Supply.config[:track])
if latest_version
Supply.config[:version_name] = latest_version.name
else
UI.user_error!("Could not find the latest version to download metadata, images, and screenshots from")
end
end
client.release_listings(Supply.config[:version_name]).each do |release_listing|
store_release_listing(release_listing)
end
client.abort_current_edit
UI.success("✅ Successfully stored metadata in '#{metadata_path}'")
end
def store_metadata(listing)
UI.message("📝 Downloading metadata (#{listing.language})")
containing = File.join(metadata_path, listing.language)
FileUtils.mkdir_p(containing)
Supply::AVAILABLE_METADATA_FIELDS.each do |key|
path = File.join(containing, "#{key}.txt")
UI.message("Writing to #{path}...")
File.open(path, 'w:UTF-8') { |file| file.write(listing.send(key)) }
end
end
def download_images(listing)
UI.message("🖼️ Downloading images (#{listing.language})")
require 'net/http'
allowed_imagetypes = [Supply::IMAGES_TYPES, Supply::SCREENSHOT_TYPES].flatten
allowed_imagetypes.each do |image_type|
begin
path = File.join(metadata_path, listing.language, IMAGES_FOLDER_NAME, image_type)
p = Pathname.new(path)
if IMAGES_TYPES.include?(image_type) # IMAGE_TYPES are stored in locale/images location
FileUtils.mkdir_p(p.dirname.to_s)
else # SCREENSHOT_TYPES go under their respective folders.
FileUtils.mkdir_p(p.to_s)
end
UI.message("Downloading `#{image_type}` for #{listing.language}...")
urls = client.fetch_images(image_type: image_type, language: listing.language).map(&:url)
next if urls.nil? || urls.empty?
image_counter = 1 # Used to prefix the downloaded files, so order is preserved.
urls.each do |url|
if IMAGES_TYPES.include?(image_type) # IMAGE_TYPES are stored in locale/images
file_path = "#{path}.#{FastImage.type(url)}"
else # SCREENSHOT_TYPES are stored in locale/images/<screenshot_types>
file_path = File.join(path, "#{image_counter}_#{listing.language}.#{FastImage.type(url)}")
end
File.binwrite(file_path, Net::HTTP.get(URI.parse(url)))
UI.message("\tDownloaded - #{file_path}")
image_counter += 1
end
rescue => ex
UI.error(ex.to_s)
UI.error("Error downloading '#{image_type}' for #{listing.language}...")
end
end
end
def store_release_listing(release_listing)
UI.message("🔨 Downloading changelogs (#{release_listing.language}, #{release_listing.version})")
containing = File.join(metadata_path, release_listing.language, CHANGELOGS_FOLDER_NAME)
unless File.exist?(containing)
FileUtils.mkdir_p(containing)
end
release_listing.versioncodes.each do |versioncode|
path = File.join(containing, "#{versioncode}.txt")
UI.message("Writing to #{path}...")
File.write(path, release_listing.release_notes)
end
end
private
def metadata_path
@metadata_path ||= Supply.config[:metadata_path]
@metadata_path ||= "fastlane/metadata/android" if Helper.fastlane_enabled?
@metadata_path ||= "metadata" unless Helper.fastlane_enabled?
return @metadata_path
end
def client
@client ||= Client.make_from_config
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply/generated_universal_apk.rb | supply/lib/supply/generated_universal_apk.rb | module Supply
# A model representing the returned values from a call to Client#list_generated_universal_apks
class GeneratedUniversalApk
attr_accessor :package_name
attr_accessor :version_code
attr_accessor :certificate_sha256_hash
attr_accessor :download_id
# Initializes the Generated Universal APK model
def initialize(package_name, version_code, certificate_sha256_hash, download_id)
self.package_name = package_name
self.version_code = version_code
self.certificate_sha256_hash = certificate_sha256_hash
self.download_id = download_id
end
def ==(other)
self.package_name == other.package_name \
&& self.version_code == other.version_code \
&& self.certificate_sha256_hash == other.certificate_sha256_hash \
&& self.download_id == other.download_id
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply/options.rb | supply/lib/supply/options.rb | # rubocop:disable Metrics/ClassLength
require 'fastlane_core/configuration/config_item'
require 'credentials_manager/appfile_config'
module Supply
class Options
# rubocop:disable Metrics/PerceivedComplexity
def self.available_options
@options ||= [
FastlaneCore::ConfigItem.new(key: :package_name,
env_name: "SUPPLY_PACKAGE_NAME",
short_option: "-p",
description: "The package name of the application to use",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:package_name),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :version_name,
env_name: "SUPPLY_VERSION_NAME",
short_option: "-n",
optional: true,
description: "Version name (used when uploading new apks/aabs) - defaults to 'versionName' in build.gradle or AndroidManifest.xml",
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:version_name),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :version_code,
env_name: "SUPPLY_VERSION_CODE",
short_option: "-C",
optional: true,
type: Integer,
description: "Version code (used when updating rollout or promoting specific versions)",
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:version_code),
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :release_status,
env_name: "SUPPLY_RELEASE_STATUS",
short_option: "-e",
optional: true,
description: "Release status (used when uploading new apks/aabs) - valid values are #{Supply::ReleaseStatus::ALL.join(', ')}",
default_value: Supply::ReleaseStatus::COMPLETED,
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Value must be one of '#{Supply::RELEASE_STATUS}'") unless Supply::ReleaseStatus::ALL.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :track,
short_option: "-a",
env_name: "SUPPLY_TRACK",
description: "The track of the application to use. The default available tracks are: #{Supply::Tracks::DEFAULTS.join(', ')}",
default_value: Supply::Tracks::DEFAULT,
type: String,
verify_block: proc do |value|
UI.user_error!("'rollout' is no longer a valid track name - please use 'production' instead") if value.casecmp('rollout').zero?
end),
FastlaneCore::ConfigItem.new(key: :rollout,
short_option: "-r",
description: "The percentage of the user fraction when uploading to the rollout track (setting to 1 will complete the rollout)",
optional: true,
verify_block: proc do |value|
min = 0.0
max = 1.0
UI.user_error!("Invalid value '#{value}', must be greater than #{min} and less than #{max}") unless value.to_f > min && value.to_f <= max
end),
FastlaneCore::ConfigItem.new(key: :metadata_path,
env_name: "SUPPLY_METADATA_PATH",
short_option: "-m",
optional: true,
description: "Path to the directory containing the metadata files",
default_value: (Dir["./fastlane/metadata/android"] + Dir["./metadata"]).first,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :key,
env_name: "SUPPLY_KEY",
short_option: "-k",
conflicting_options: [:json_key],
deprecated: 'Use `--json_key` instead',
description: "The p12 File used to authenticate with Google",
code_gen_sensitive: true,
default_value: Dir["*.p12"].first || CredentialsManager::AppfileConfig.try_fetch_value(:keyfile),
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Could not find p12 file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
end),
FastlaneCore::ConfigItem.new(key: :issuer,
env_name: "SUPPLY_ISSUER",
short_option: "-i",
conflicting_options: [:json_key],
deprecated: 'Use `--json_key` instead',
description: "The issuer of the p12 file (email address of the service account)",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:issuer),
default_value_dynamic: true,
verify_block: proc do |value|
UI.important("DEPRECATED --issuer OPTION. Use --json_key instead")
end),
FastlaneCore::ConfigItem.new(key: :json_key,
env_name: "SUPPLY_JSON_KEY",
short_option: "-j",
conflicting_options: [:issuer, :key, :json_key_data],
optional: true, # this shouldn't be optional but is until --key and --issuer are completely removed
description: "The path to a file containing service account JSON, used to authenticate with Google",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_file),
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Could not find service account json file at path '#{File.expand_path(value)}'") unless File.exist?(File.expand_path(value))
UI.user_error!("'#{value}' doesn't seem to be a JSON file") unless FastlaneCore::Helper.json_file?(File.expand_path(value))
end),
FastlaneCore::ConfigItem.new(key: :json_key_data,
env_name: "SUPPLY_JSON_KEY_DATA",
short_option: "-c",
conflicting_options: [:issuer, :key, :json_key],
optional: true,
description: "The raw service account JSON data used to authenticate with Google",
code_gen_sensitive: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:json_key_data_raw),
default_value_dynamic: true,
verify_block: proc do |value|
begin
JSON.parse(value)
rescue JSON::ParserError
UI.user_error!("Could not parse service account json JSON::ParseError")
end
end),
FastlaneCore::ConfigItem.new(key: :apk,
env_name: "SUPPLY_APK",
description: "Path to the APK file to upload",
short_option: "-b",
conflicting_options: [:apk_paths, :aab, :aab_paths],
code_gen_sensitive: true,
default_value: Dir["*.apk"].last || Dir[File.join("app", "build", "outputs", "apk", "app-Release.apk")].last,
default_value_dynamic: true,
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not find apk file at path '#{value}'") unless File.exist?(value)
UI.user_error!("apk file is not an apk") unless value.end_with?('.apk')
end),
FastlaneCore::ConfigItem.new(key: :apk_paths,
env_name: "SUPPLY_APK_PATHS",
conflicting_options: [:apk, :aab, :aab_paths],
code_gen_sensitive: true,
optional: true,
type: Array,
description: "An array of paths to APK files to upload",
short_option: "-u",
verify_block: proc do |value|
UI.user_error!("Could not evaluate array from '#{value}'") unless value.kind_of?(Array)
value.each do |path|
UI.user_error!("Could not find apk file at path '#{path}'") unless File.exist?(path)
UI.user_error!("file at path '#{path}' is not an apk") unless path.end_with?('.apk')
end
end),
FastlaneCore::ConfigItem.new(key: :aab,
env_name: "SUPPLY_AAB",
description: "Path to the AAB file to upload",
short_option: "-f",
conflicting_options: [:apk, :apk_paths, :aab_paths],
code_gen_sensitive: true,
default_value: Dir["*.aab"].last || Dir[File.join("app", "build", "outputs", "bundle", "release", "bundle.aab")].last,
default_value_dynamic: true,
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not find aab file at path '#{value}'") unless File.exist?(value)
UI.user_error!("aab file is not an aab") unless value.end_with?('.aab')
end),
FastlaneCore::ConfigItem.new(key: :aab_paths,
env_name: "SUPPLY_AAB_PATHS",
conflicting_options: [:apk, :apk_paths, :aab],
code_gen_sensitive: true,
optional: true,
type: Array,
description: "An array of paths to AAB files to upload",
short_option: "-z",
verify_block: proc do |value|
UI.user_error!("Could not evaluate array from '#{value}'") unless value.kind_of?(Array)
value.each do |path|
UI.user_error!("Could not find aab file at path '#{path}'") unless File.exist?(path)
UI.user_error!("file at path '#{path}' is not an aab") unless path.end_with?('.aab')
end
end),
FastlaneCore::ConfigItem.new(key: :skip_upload_apk,
env_name: "SUPPLY_SKIP_UPLOAD_APK",
optional: true,
description: "Whether to skip uploading APK",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_upload_aab,
env_name: "SUPPLY_SKIP_UPLOAD_AAB",
optional: true,
description: "Whether to skip uploading AAB",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_upload_metadata,
env_name: "SUPPLY_SKIP_UPLOAD_METADATA",
optional: true,
description: "Whether to skip uploading metadata, changelogs not included",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_upload_changelogs,
env_name: "SUPPLY_SKIP_UPLOAD_CHANGELOGS",
optional: true,
description: "Whether to skip uploading changelogs",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_upload_images,
env_name: "SUPPLY_SKIP_UPLOAD_IMAGES",
optional: true,
description: "Whether to skip uploading images, screenshots not included",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_upload_screenshots,
env_name: "SUPPLY_SKIP_UPLOAD_SCREENSHOTS",
optional: true,
description: "Whether to skip uploading SCREENSHOTS",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :sync_image_upload,
env_name: "SUPPLY_SYNC_IMAGE_UPLOAD",
description: "Whether to use sha256 comparison to skip upload of images and screenshots that are already in Play Store",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :track_promote_to,
env_name: "SUPPLY_TRACK_PROMOTE_TO",
optional: true,
description: "The track to promote to. The default available tracks are: #{Supply::Tracks::DEFAULTS.join(', ')}",
verify_block: proc do |value|
UI.user_error!("'rollout' is no longer a valid track name - please use 'production' instead") if value.casecmp('rollout').zero?
end),
FastlaneCore::ConfigItem.new(key: :track_promote_release_status,
env_name: "SUPPLY_TRACK_PROMOTE_RELEASE_STATUS",
optional: true,
description: "Promoted track release status (used when promoting a track) - valid values are #{Supply::ReleaseStatus::ALL.join(', ')}",
default_value: Supply::ReleaseStatus::COMPLETED,
verify_block: proc do |value|
UI.user_error!("Value must be one of '#{Supply::RELEASE_STATUS}'") unless Supply::ReleaseStatus::ALL.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :validate_only,
env_name: "SUPPLY_VALIDATE_ONLY",
optional: true,
description: "Only validate changes with Google Play rather than actually publish",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :mapping,
env_name: "SUPPLY_MAPPING",
description: "Path to the mapping file to upload (mapping.txt or native-debug-symbols.zip alike)",
short_option: "-d",
conflicting_options: [:mapping_paths],
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not find mapping file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :mapping_paths,
env_name: "SUPPLY_MAPPING_PATHS",
conflicting_options: [:mapping],
optional: true,
type: Array,
description: "An array of paths to mapping files to upload (mapping.txt or native-debug-symbols.zip alike)",
short_option: "-s",
verify_block: proc do |value|
UI.user_error!("Could not evaluate array from '#{value}'") unless value.kind_of?(Array)
value.each do |path|
UI.user_error!("Could not find mapping file at path '#{path}'") unless File.exist?(path)
end
end),
FastlaneCore::ConfigItem.new(key: :root_url,
env_name: "SUPPLY_ROOT_URL",
description: "Root URL for the Google Play API. The provided URL will be used for API calls in place of https://www.googleapis.com/",
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not parse URL '#{value}'") unless value =~ URI.regexp
end),
FastlaneCore::ConfigItem.new(key: :check_superseded_tracks,
env_name: "SUPPLY_CHECK_SUPERSEDED_TRACKS",
optional: true,
description: "Check the other tracks for superseded versions and disable them",
deprecated: "Google Play does this automatically now",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :timeout,
env_name: "SUPPLY_TIMEOUT",
optional: true,
description: "Timeout for read, open, and send (in seconds)",
type: Integer,
default_value: 300),
FastlaneCore::ConfigItem.new(key: :deactivate_on_promote,
env_name: "SUPPLY_DEACTIVATE_ON_PROMOTE",
optional: true,
description: "When promoting to a new track, deactivate the binary in the origin track",
deprecated: "Google Play does this automatically now",
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :version_codes_to_retain,
optional: true,
type: Array,
description: "An array of version codes to retain when publishing a new APK",
verify_block: proc do |version_codes|
version_codes = version_codes.map(&:to_i)
UI.user_error!("Could not evaluate array from '#{version_codes}'") unless version_codes.kind_of?(Array)
version_codes.each do |version_code|
UI.user_error!("Version code '#{version_code}' is not an integer") if version_code == 0
end
end),
FastlaneCore::ConfigItem.new(key: :changes_not_sent_for_review,
env_name: "SUPPLY_CHANGES_NOT_SENT_FOR_REVIEW",
description: "Indicates that the changes in this edit will not be reviewed until they are explicitly sent for review from the Google Play Console UI",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :rescue_changes_not_sent_for_review,
env_name: "SUPPLY_RESCUE_CHANGES_NOT_SENT_FOR_REVIEW",
description: "Catches changes_not_sent_for_review errors when an edit is committed and retries with the configuration that the error message recommended",
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :in_app_update_priority,
env_name: "SUPPLY_IN_APP_UPDATE_PRIORITY",
optional: true,
type: Integer,
description: "In-app update priority for all the newly added apks in the release. Can take values between [0,5]",
verify_block: proc do |in_app_update_priority|
in_app_update_priority = in_app_update_priority.to_i
UI.user_error!("Invalid in_app_update_priority value '#{in_app_update_priority}'. Values must be between [0,5]") unless (0..5).member?(in_app_update_priority)
end),
FastlaneCore::ConfigItem.new(key: :obb_main_references_version,
env_name: "SUPPLY_OBB_MAIN_REFERENCES_VERSION",
description: "References version of 'main' expansion file",
optional: true,
type: Numeric),
FastlaneCore::ConfigItem.new(key: :obb_main_file_size,
env_name: "SUPPLY_OBB_MAIN_FILE SIZE",
description: "Size of 'main' expansion file in bytes",
optional: true,
type: Numeric),
FastlaneCore::ConfigItem.new(key: :obb_patch_references_version,
env_name: "SUPPLY_OBB_PATCH_REFERENCES_VERSION",
description: "References version of 'patch' expansion file",
optional: true,
type: Numeric),
FastlaneCore::ConfigItem.new(key: :obb_patch_file_size,
env_name: "SUPPLY_OBB_PATCH_FILE SIZE",
description: "Size of 'patch' expansion file in bytes",
optional: true,
type: Numeric),
FastlaneCore::ConfigItem.new(key: :ack_bundle_installation_warning,
env_name: "ACK_BUNDLE_INSTALLATION_WARNING",
description: "Must be set to true if the bundle installation may trigger a warning on user devices (e.g can only be downloaded over wifi). Typically this is required for bundles over 150MB",
optional: true,
type: Boolean,
default_value: false)
]
end
# rubocop:enable Metrics/PerceivedComplexity
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply/uploader.rb | supply/lib/supply/uploader.rb | require 'fastlane_core'
module Supply
# rubocop:disable Metrics/ClassLength
class Uploader
UploadJob = Struct.new(:language, :version_code, :release_notes_queue)
def perform_upload
FastlaneCore::PrintTable.print_values(config: Supply.config, hide_keys: [:issuer], mask_keys: [:json_key_data], title: "Summary for supply #{Fastlane::VERSION}")
client.begin_edit(package_name: Supply.config[:package_name])
verify_config!
apk_version_codes = []
apk_version_codes.concat(upload_apks) unless Supply.config[:skip_upload_apk]
apk_version_codes.concat(upload_bundles) unless Supply.config[:skip_upload_aab]
upload_mapping(apk_version_codes)
track_to_update = Supply.config[:track]
apk_version_codes.concat(Supply.config[:version_codes_to_retain]) if Supply.config[:version_codes_to_retain]
if !apk_version_codes.empty?
# Only update tracks if we have version codes
# update_track handle setting rollout if needed
# Updating a track with empty version codes can completely clear out a track
update_track(apk_version_codes)
else
# Only promote or rollout if we don't have version codes
if Supply.config[:track_promote_to]
track_to_update = Supply.config[:track_promote_to]
promote_track
elsif !Supply.config[:rollout].nil? && Supply.config[:track].to_s != ""
update_rollout
end
end
perform_upload_meta(apk_version_codes, track_to_update)
if Supply.config[:validate_only]
UI.message("Validating all changes with Google Play...")
client.validate_current_edit!
UI.success("Successfully validated the upload to Google Play")
else
UI.message("Uploading all changes to Google Play...")
client.commit_current_edit!
UI.success("Successfully finished the upload to Google Play")
end
end
def perform_upload_to_internal_app_sharing
download_urls = []
package_name = Supply.config[:package_name]
apk_paths = [Supply.config[:apk]] unless (apk_paths = Supply.config[:apk_paths])
apk_paths.compact!
apk_paths.each do |apk_path|
download_url = client.upload_apk_to_internal_app_sharing(package_name, apk_path)
download_urls << download_url
UI.success("Successfully uploaded APK to Internal App Sharing URL: #{download_url}")
end
aab_paths = [Supply.config[:aab]] unless (aab_paths = Supply.config[:aab_paths])
aab_paths.compact!
aab_paths.each do |aab_path|
download_url = client.upload_bundle_to_internal_app_sharing(package_name, aab_path)
download_urls << download_url
UI.success("Successfully uploaded AAB to Internal App Sharing URL: #{download_url}")
end
if download_urls.count == 1
return download_urls.first
else
return download_urls
end
end
def perform_upload_meta(version_codes, track_name)
if (!Supply.config[:skip_upload_metadata] || !Supply.config[:skip_upload_images] || !Supply.config[:skip_upload_changelogs] || !Supply.config[:skip_upload_screenshots]) && metadata_path
# Use version code from config if version codes is empty and no nil or empty string
version_codes = [Supply.config[:version_code]] if version_codes.empty?
version_codes = version_codes.reject do |version_code|
version_codes.to_s == ""
end
version_codes.each do |version_code|
UI.user_error!("Could not find folder #{metadata_path}") unless File.directory?(metadata_path)
track, release = fetch_track_and_release!(track_name, version_code)
UI.user_error!("Unable to find the requested track - '#{Supply.config[:track]}'") unless track
UI.user_error!("Could not find release for version code '#{version_code}' to update changelog") unless release
release_notes_queue = Queue.new
upload_worker = create_meta_upload_worker
upload_worker.batch_enqueue(
# skip . or .. or hidden folders
all_languages.reject { |lang| lang.start_with?('.') }.map { |lang| UploadJob.new(lang, version_code, release_notes_queue) }
)
upload_worker.start
release_notes = Array.new(release_notes_queue.size) { release_notes_queue.pop } # Queue to Array
upload_changelogs(release_notes, release, track, track_name) unless release_notes.empty?
end
end
end
def fetch_track_and_release!(track, version_code, statuses = nil)
tracks = client.tracks(track)
return nil, nil if tracks.empty?
track = tracks.first
releases = track.releases
releases = releases.select { |r| statuses.include?(r.status) } unless statuses.nil? || statuses.empty?
releases = releases.select { |r| (r.version_codes || []).map(&:to_s).include?(version_code.to_s) } if version_code
if releases.size > 1
UI.user_error!("More than one release found in this track. Please specify with the :version_code option to select a release.")
end
return track, releases.first
end
def update_rollout
track, release = fetch_track_and_release!(Supply.config[:track], Supply.config[:version_code], [Supply::ReleaseStatus::IN_PROGRESS, Supply::ReleaseStatus::DRAFT])
UI.user_error!("Unable to find the requested track - '#{Supply.config[:track]}'") unless track
UI.user_error!("Unable to find the requested release on track - '#{Supply.config[:track]}'") unless release
version_code = release.version_codes.max
UI.message("Updating #{version_code}'s rollout to '#{Supply.config[:rollout]}' on track '#{Supply.config[:track]}'...")
if track && release
rollout = Supply.config[:rollout]
status = Supply.config[:release_status]
# If release_status not provided explicitly (and thus defaults to 'completed'), but rollout is provided with a value < 1.0, then set to 'inProgress' instead
status = Supply::ReleaseStatus::IN_PROGRESS if status == Supply::ReleaseStatus::COMPLETED && !rollout.nil? && rollout.to_f < 1
# If release_status is set to 'inProgress' but rollout is provided with a value = 1.0, then set to 'completed' instead
status = Supply::ReleaseStatus::COMPLETED if status == Supply::ReleaseStatus::IN_PROGRESS && rollout.to_f == 1
# If release_status is set to 'inProgress' but no rollout value is provided, error out
UI.user_error!("You need to provide a rollout value when release_status is set to 'inProgress'") if status == Supply::ReleaseStatus::IN_PROGRESS && rollout.nil?
release.status = status
# user_fraction is only valid for IN_PROGRESS or HALTED status
# https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/AndroidpublisherV3/TrackRelease.html#user_fraction-instance_method
release.user_fraction = [Supply::ReleaseStatus::IN_PROGRESS, Supply::ReleaseStatus::HALTED].include?(release.status) ? rollout : nil
# It's okay to set releases to an array containing the newest release
# Google Play will keep previous releases there untouched
track.releases = [release]
else
UI.user_error!("Unable to find version to rollout in track '#{Supply.config[:track]}'")
end
client.update_track(Supply.config[:track], track)
end
def verify_config!
unless metadata_path || Supply.config[:apk] || Supply.config[:apk_paths] || Supply.config[:aab] || Supply.config[:aab_paths] || (Supply.config[:track] && Supply.config[:track_promote_to]) || (Supply.config[:track] && Supply.config[:rollout])
UI.user_error!("No local metadata, apks, aab, or track to promote were found, make sure to run `fastlane supply init` to setup supply")
end
# Can't upload both at apk and aab at same time
# Need to error out users when there both apks and aabs are detected
apk_paths = [Supply.config[:apk], Supply.config[:apk_paths]].flatten.compact
could_upload_apk = !apk_paths.empty? && !Supply.config[:skip_upload_apk]
could_upload_aab = Supply.config[:aab] && !Supply.config[:skip_upload_aab]
if could_upload_apk && could_upload_aab
UI.user_error!("Cannot provide both apk(s) and aab - use `skip_upload_apk`, `skip_upload_aab`, or make sure to remove any existing .apk or .aab files that are no longer needed")
end
if Supply.config[:release_status] == Supply::ReleaseStatus::DRAFT && Supply.config[:rollout]
UI.user_error!(%(Cannot specify rollout percentage when the release status is set to 'draft'))
end
if Supply.config[:track_promote_release_status] == Supply::ReleaseStatus::DRAFT && Supply.config[:rollout]
UI.user_error!(%(Cannot specify rollout percentage when the track promote release status is set to 'draft'))
end
unless Supply.config[:version_codes_to_retain].nil?
Supply.config[:version_codes_to_retain] = Supply.config[:version_codes_to_retain].map(&:to_i)
end
end
def promote_track
track_from = client.tracks(Supply.config[:track]).first
unless track_from
UI.user_error!("Cannot promote from track '#{Supply.config[:track]}' - track doesn't exist")
end
releases = track_from.releases
if Supply.config[:version_code].to_s != ""
releases = releases.select do |release|
release.version_codes.include?(Supply.config[:version_code].to_s)
end
else
releases = releases.select do |release|
release.status == Supply.config[:release_status]
end
end
if releases.size == 0
UI.user_error!("Track '#{Supply.config[:track]}' doesn't have any releases")
elsif releases.size > 1
UI.user_error!("Track '#{Supply.config[:track]}' has more than one release - use :version_code to filter the release to promote")
end
release = releases.first
track_to = client.tracks(Supply.config[:track_promote_to]).first
rollout = (Supply.config[:rollout] || 0).to_f
if rollout > 0 && rollout < 1
release.status = Supply::ReleaseStatus::IN_PROGRESS
release.user_fraction = rollout
else
release.status = Supply.config[:track_promote_release_status]
release.user_fraction = nil
end
if track_to
# It's okay to set releases to an array containing the newest release
# Google Play will keep previous releases there this release is a partial rollout
track_to.releases = [release]
else
track_to = AndroidPublisher::Track.new(
track: Supply.config[:track_promote_to],
releases: [release]
)
end
client.update_track(Supply.config[:track_promote_to], track_to)
end
def upload_changelog(language, version_code)
UI.user_error!("Cannot find changelog because no version code given - please specify :version_code") unless version_code
path = File.join(Supply.config[:metadata_path], language, Supply::CHANGELOGS_FOLDER_NAME, "#{version_code}.txt")
changelog_text = ''
if File.exist?(path)
UI.message("Updating changelog for '#{version_code}' and language '#{language}'...")
changelog_text = File.read(path, encoding: 'UTF-8')
else
default_changelog_path = File.join(Supply.config[:metadata_path], language, Supply::CHANGELOGS_FOLDER_NAME, "default.txt")
if File.exist?(default_changelog_path)
UI.message("Updating changelog for '#{version_code}' and language '#{language}' to default changelog...")
changelog_text = File.read(default_changelog_path, encoding: 'UTF-8')
else
UI.message("Could not find changelog for '#{version_code}' and language '#{language}' at path #{path}...")
end
end
AndroidPublisher::LocalizedText.new(
language: language,
text: changelog_text
)
end
def upload_changelogs(release_notes, release, track, track_name)
release.release_notes = release_notes
client.upload_changelogs(track, track_name)
end
def upload_metadata(language, listing)
Supply::AVAILABLE_METADATA_FIELDS.each do |key|
path = File.join(metadata_path, language, "#{key}.txt")
listing.send("#{key}=".to_sym, File.read(path, encoding: 'UTF-8')) if File.exist?(path)
end
begin
listing.save
rescue Encoding::InvalidByteSequenceError => ex
message = (ex.message || '').capitalize
UI.user_error!("Metadata must be UTF-8 encoded. #{message}")
end
end
def upload_images(language)
Supply::IMAGES_TYPES.each do |image_type|
search = File.join(metadata_path, language, Supply::IMAGES_FOLDER_NAME, image_type) + ".#{IMAGE_FILE_EXTENSIONS}"
path = Dir.glob(search, File::FNM_CASEFOLD).last
next unless path
if Supply.config[:sync_image_upload]
UI.message("🔍 Checking #{image_type} checksum...")
existing_images = client.fetch_images(image_type: image_type, language: language)
sha256 = Digest::SHA256.file(path).hexdigest
if existing_images.map(&:sha256).include?(sha256)
UI.message("🟰 Skipping upload of screenshot #{path} as remote sha256 matches.")
next
end
end
UI.message("⬆️ Uploading image file #{path}...")
client.upload_image(image_path: File.expand_path(path),
image_type: image_type,
language: language)
end
end
def upload_screenshots(language)
Supply::SCREENSHOT_TYPES.each do |screenshot_type|
search = File.join(metadata_path, language, Supply::IMAGES_FOLDER_NAME, screenshot_type, "*.#{IMAGE_FILE_EXTENSIONS}")
paths = Dir.glob(search, File::FNM_CASEFOLD).sort
next unless paths.count > 0
if Supply.config[:sync_image_upload]
UI.message("🔍 Checking #{screenshot_type} checksums...")
existing_images = client.fetch_images(image_type: screenshot_type, language: language)
# Don't keep images that either don't exist locally, or that are out of order compared to the `paths` to upload
first_path_checksum = Digest::SHA256.file(paths.first).hexdigest
existing_images.each do |image|
if image.sha256 == first_path_checksum
UI.message("🟰 Skipping upload of screenshot #{paths.first} as remote sha256 matches.")
paths.shift # Remove first path from the list of paths to be uploaded
first_path_checksum = paths.empty? ? nil : Digest::SHA256.file(paths.first).hexdigest
else
UI.message("🚮 Deleting #{language} screenshot id ##{image.id} as it does not exist locally or is out of order...")
client.clear_screenshot(image_type: screenshot_type, language: language, image_id: image.id)
end
end
else
client.clear_screenshots(image_type: screenshot_type, language: language)
end
paths.each do |path|
UI.message("⬆️ Uploading screenshot #{path}...")
client.upload_image(image_path: File.expand_path(path),
image_type: screenshot_type,
language: language)
end
end
end
def upload_apks
apk_paths = [Supply.config[:apk]] unless (apk_paths = Supply.config[:apk_paths])
apk_paths.compact!
apk_version_codes = []
apk_paths.each do |apk_path|
apk_version_codes.push(upload_binary_data(apk_path))
end
return apk_version_codes
end
def upload_mapping(apk_version_codes)
mapping_paths = [Supply.config[:mapping]] unless (mapping_paths = Supply.config[:mapping_paths])
mapping_paths.product(apk_version_codes).each do |mapping_path, version_code|
if mapping_path
UI.message("Preparing mapping at path '#{mapping_path}', version code #{version_code} for upload...")
client.upload_mapping(mapping_path, version_code)
end
end
end
def upload_bundles
aab_paths = [Supply.config[:aab]] unless (aab_paths = Supply.config[:aab_paths])
return [] unless aab_paths
aab_paths.compact!
aab_version_codes = []
aab_paths.each do |aab_path|
UI.message("Preparing aab at path '#{aab_path}' for upload...")
bundle_version_code = client.upload_bundle(aab_path)
aab_version_codes.push(bundle_version_code)
end
return aab_version_codes
end
private
##
# Upload binary apk and obb and corresponding change logs with client
#
# @param [String] apk_path
# Path of the apk file to upload.
#
# @return [Integer] The apk version code returned after uploading, or nil if there was a problem
def upload_binary_data(apk_path)
apk_version_code = nil
if apk_path
UI.message("Preparing apk at path '#{apk_path}' for upload...")
apk_version_code = client.upload_apk(apk_path)
UI.user_error!("Could not upload #{apk_path}") unless apk_version_code
if Supply.config[:obb_main_references_version] && Supply.config[:obb_main_file_size]
update_obb(apk_version_code,
'main',
Supply.config[:obb_main_references_version],
Supply.config[:obb_main_file_size])
end
if Supply.config[:obb_patch_references_version] && Supply.config[:obb_patch_file_size]
update_obb(apk_version_code,
'patch',
Supply.config[:obb_patch_references_version],
Supply.config[:obb_patch_file_size])
end
upload_obbs(apk_path, apk_version_code)
else
UI.message("No apk file found, you can pass the path to your apk using the `apk` option")
end
UI.message("\tVersion Code: #{apk_version_code}")
apk_version_code
end
def update_obb(apk_version_code, expansion_file_type, references_version, file_size)
UI.message("Updating '#{expansion_file_type}' expansion file from version '#{references_version}'...")
client.update_obb(apk_version_code,
expansion_file_type,
references_version,
file_size)
end
def update_track(apk_version_codes)
return if apk_version_codes.empty?
UI.message("Updating track '#{Supply.config[:track]}'...")
track_release = AndroidPublisher::TrackRelease.new(
name: Supply.config[:version_name],
status: Supply.config[:release_status],
version_codes: apk_version_codes
)
if Supply.config[:rollout]
rollout = Supply.config[:rollout].to_f
if rollout > 0 && rollout < 1
track_release.status = Supply::ReleaseStatus::IN_PROGRESS
track_release.user_fraction = rollout
end
end
if Supply.config[:in_app_update_priority]
track_release.in_app_update_priority = Supply.config[:in_app_update_priority].to_i
end
tracks = client.tracks(Supply.config[:track])
track = tracks.first
if track
# It's okay to set releases to an array containing the newest release
# Google Play will keep previous releases there this release is a partial rollout
track.releases = [track_release]
else
track = AndroidPublisher::Track.new(
track: Supply.config[:track],
releases: [track_release]
)
end
client.update_track(Supply.config[:track], track)
end
# returns only language directories from metadata_path
def all_languages
Dir.entries(metadata_path)
.select { |f| File.directory?(File.join(metadata_path, f)) }
.reject { |f| f.start_with?('.') }
.sort { |x, y| x <=> y }
end
def client
@client ||= Client.make_from_config
end
def metadata_path
Supply.config[:metadata_path]
end
# searches for obbs in the directory where the apk is located and
# upload at most one main and one patch file. Do nothing if it finds
# more than one of either of them.
def upload_obbs(apk_path, apk_version_code)
expansion_paths = find_obbs(apk_path)
['main', 'patch'].each do |type|
if expansion_paths[type]
upload_obb(expansion_paths[type], type, apk_version_code)
end
end
end
# @return a map of the obb paths for that apk
# keyed by their detected expansion file type
# E.g.
# { 'main' => 'path/to/main.obb', 'patch' => 'path/to/patch.obb' }
def find_obbs(apk_path)
search = File.join(File.dirname(apk_path), '*.obb')
paths = Dir.glob(search, File::FNM_CASEFOLD)
expansion_paths = {}
paths.each do |path|
type = obb_expansion_file_type(path)
next unless type
if expansion_paths[type]
UI.important("Can only upload one '#{type}' apk expansion. Skipping obb upload entirely.")
UI.important("If you'd like this to work differently, please submit an issue.")
return {}
end
expansion_paths[type] = path
end
expansion_paths
end
def upload_obb(obb_path, expansion_file_type, apk_version_code)
UI.message("Uploading obb file #{obb_path}...")
client.upload_obb(obb_file_path: obb_path,
apk_version_code: apk_version_code,
expansion_file_type: expansion_file_type)
end
def obb_expansion_file_type(obb_file_path)
filename = File.basename(obb_file_path, ".obb")
if filename.include?('main')
'main'
elsif filename.include?('patch')
'patch'
end
end
def create_meta_upload_worker
FastlaneCore::QueueWorker.new do |job|
UI.message("Preparing uploads for language '#{job.language}'...")
start_time = Time.now
listing = client.listing_for_language(job.language)
upload_metadata(job.language, listing) unless Supply.config[:skip_upload_metadata]
upload_images(job.language) unless Supply.config[:skip_upload_images]
upload_screenshots(job.language) unless Supply.config[:skip_upload_screenshots]
job.release_notes_queue << upload_changelog(job.language, job.version_code) unless Supply.config[:skip_upload_changelogs]
UI.message("Uploaded all items for language '#{job.language}'... (#{Time.now - start_time} secs)")
rescue => error
UI.abort_with_message!("#{job.language} - #{error}")
end
end
end
# rubocop:enable Metrics/ClassLength
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/supply/lib/supply/reader.rb | supply/lib/supply/reader.rb | module Supply
class Reader
def track_version_codes
track = Supply.config[:track]
client.begin_edit(package_name: Supply.config[:package_name])
version_codes = client.track_version_codes(track)
client.abort_current_edit
if version_codes.empty?
UI.important("No version codes found in track '#{track}'")
else
UI.success("Found '#{version_codes.join(', ')}' version codes in track '#{track}'")
end
version_codes
end
def track_release_names
track = Supply.config[:track]
client.begin_edit(package_name: Supply.config[:package_name])
release_names = client.track_releases(track).map(&:name)
client.abort_current_edit
if release_names.empty?
UI.important("No release names found in track '#{track}'")
else
UI.success("Found '#{release_names.join(', ')}' release names in track '#{track}'")
end
release_names
end
private
def client
@client ||= Client.make_from_config
end
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.