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/junit_generator.rb | fastlane/lib/fastlane/junit_generator.rb | module Fastlane
class JUnitGenerator
def self.generate(results)
# JUnit file documentation: http://llg.cubic.org/docs/junit/
# And http://nelsonwells.net/2012/09/how-jenkins-ci-parses-and-displays-junit-output/
# And http://windyroad.com.au/dl/Open%20Source/JUnit.xsd
containing_folder = ENV['FL_REPORT_PATH'] || FastlaneCore::FastlaneFolder.path || Dir.pwd
path = File.join(containing_folder, 'report.xml')
@steps = results
xml_path = File.join(Fastlane::ROOT, "lib/assets/report_template.xml.erb")
xml = ERB.new(File.read(xml_path)).result(binding) # https://web.archive.org/web/20160430190141/www.rrn.dk/rubys-erb-templating-system
xml = xml.gsub('system_', 'system-').delete("\e") # Jenkins cannot parse 'ESC' symbol
begin
File.write(path, xml)
rescue => ex
UI.error(ex)
UI.error("Couldn't save report.xml at path '#{File.expand_path(path)}', make sure you have write access to the containing directory.")
end
return 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/configuration_helper.rb | fastlane/lib/fastlane/configuration_helper.rb | module Fastlane
class ConfigurationHelper
def self.parse(action, params)
first_element = (action.available_options || []).first
if first_element && first_element.kind_of?(FastlaneCore::ConfigItem)
# default use case
return FastlaneCore::Configuration.create(action.available_options, params)
elsif first_element
UI.error("Old configuration format for action '#{action}'") if Helper.test?
return params
else
# No parameters... we still need the configuration object array
FastlaneCore::Configuration.create(action.available_options, {})
end
rescue => ex
if action.respond_to?(:action_name)
UI.error("You passed invalid parameters to '#{action.action_name}'.")
UI.error("Check out the error below and available options by running `fastlane action #{action.action_name}`")
end
raise ex
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/boolean.rb | fastlane/lib/fastlane/boolean.rb | module Fastlane
class Boolean
# Used in config item generation
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/cli_tools_distributor.rb | fastlane/lib/fastlane/cli_tools_distributor.rb | module Fastlane
# This class is responsible for checking the ARGV
# to see if the user wants to launch another fastlane
# tool or fastlane itself
class CLIToolsDistributor
class << self
def running_version_command?
ARGV.include?('-v') || ARGV.include?('--version')
end
def running_help_command?
ARGV.include?('-h') || ARGV.include?('--help')
end
def running_init_command?
ARGV.include?("init")
end
def utf8_locale?
(ENV['LANG'] || "").end_with?("UTF-8", "utf8") || (ENV['LC_ALL'] || "").end_with?("UTF-8", "utf8") || (FastlaneCore::CommandExecutor.which('locale') && `locale charmap`.strip == "UTF-8")
end
def take_off
before_import_time = Time.now
if ENV["FASTLANE_DISABLE_ANIMATION"].nil?
# Usually in the fastlane code base we use
#
# Helper.show_loading_indicator
# longer_taking_task_here
# Helper.hide_loading_indicator
#
# but in this case we haven't required FastlaneCore yet
# so we'll have to access the raw API for now
require "tty-spinner"
require_fastlane_spinner = TTY::Spinner.new("[:spinner] π ", format: :dots)
require_fastlane_spinner.auto_spin
# this might take a long time if there is no Gemfile :(
# That's why we show the loading indicator here also
require "fastlane"
require_fastlane_spinner.success
else
require "fastlane"
end
# Loading any .env files before any lanes are called since
# variables like FASTLANE_HIDE_CHANGELOG, SKIP_SLOW_FASTLANE_WARNING
# and FASTLANE_DISABLE_COLORS need to be set early on in execution
load_dot_env
# We want to avoid printing output other than the version number if we are running `fastlane -v`
unless running_version_command? || running_init_command?
print_bundle_exec_warning(is_slow: (Time.now - before_import_time > 3))
end
# Try to check UTF-8 with `locale`, fallback to environment variables
unless utf8_locale?
warn = "WARNING: fastlane requires your locale to be set to UTF-8. To learn more go to https://docs.fastlane.tools/getting-started/ios/setup/#set-up-environment-variables"
UI.error(warn)
at_exit do
# Repeat warning here so users hopefully see it
UI.error(warn)
end
end
# Needs to go after load_dot_env for variable FASTLANE_SKIP_UPDATE_CHECK
FastlaneCore::UpdateChecker.start_looking_for_update('fastlane')
# Disabling colors if environment variable set
require 'fastlane_core/ui/disable_colors' if FastlaneCore::Helper.colors_disabled?
# Set interactive environment variable for spaceship (which can't require fastlane_core)
ENV["FASTLANE_IS_INTERACTIVE"] = FastlaneCore::UI.interactive?.to_s
ARGV.unshift("spaceship") if ARGV.first == "spaceauth"
tool_name = ARGV.first ? ARGV.first.downcase : nil
tool_name = process_emojis(tool_name)
tool_name = map_aliased_tools(tool_name)
if tool_name && Fastlane::TOOLS.include?(tool_name.to_sym) && !available_lanes.include?(tool_name.to_sym)
# Triggering a specific tool
# This happens when the users uses things like
#
# fastlane sigh
# fastlane snapshot
#
require tool_name
begin
# First, remove the tool's name from the arguments
# Since it will be parsed by the `commander` at a later point
# and it must not contain the binary name
ARGV.shift
# Import the CommandsGenerator class, which is used to parse
# the user input
require File.join(tool_name, "commands_generator")
# Call the tool's CommandsGenerator class and let it do its thing
commands_generator = Object.const_get(tool_name.fastlane_module)::CommandsGenerator
rescue LoadError
# This will only happen if the tool we call here, doesn't provide
# a CommandsGenerator class yet
# When we launch this feature, this should never be the case
abort("#{tool_name} can't be called via `fastlane #{tool_name}`, run '#{tool_name}' directly instead".red)
end
# Some of the tools use other actions so need to load all
# actions before we start the tool generator
# Example: scan uses slack
Fastlane.load_actions
commands_generator.start
elsif tool_name == "fastlane-credentials"
require 'credentials_manager'
ARGV.shift
CredentialsManager::CLI.new.run
else
# Triggering fastlane to call a lane
require "fastlane/commands_generator"
Fastlane::CommandsGenerator.start
end
ensure
FastlaneCore::UpdateChecker.show_update_status('fastlane', Fastlane::VERSION)
end
def map_aliased_tools(tool_name)
Fastlane::TOOL_ALIASES[tool_name&.to_sym] || tool_name
end
# Since loading dotenv should respect additional environments passed using
# --env, we must extract the arguments out of ARGV and process them before
# calling into commander. This is required since the ENV must be configured
# before running any other commands in order to correctly respect variables
# like FASTLANE_HIDE_CHANGELOG and FASTLANE_DISABLE_COLORS
def load_dot_env
env_cl_param = lambda do
index = ARGV.index("--env")
return nil if index.nil?
ARGV.delete_at(index)
return nil if ARGV[index].nil?
value = ARGV[index]
ARGV.delete_at(index)
value
end
require 'fastlane/helper/dotenv_helper'
Fastlane::Helper::DotenvHelper.load_dot_env(env_cl_param.call)
end
# Since fastlane also supports the rocket and biceps emoji as executable
# we need to map those to the appropriate tools
def process_emojis(tool_name)
return {
"π" => "fastlane",
"πͺ" => "gym"
}[tool_name] || tool_name
end
def print_bundle_exec_warning(is_slow: false)
return if FastlaneCore::Helper.bundler? # user is already using bundler
return if FastlaneCore::Env.truthy?('SKIP_SLOW_FASTLANE_WARNING') # user disabled the warnings
return if FastlaneCore::Helper.contained_fastlane? # user uses the bundled fastlane
gemfile_path = PluginManager.new.gemfile_path
if gemfile_path
# The user has a Gemfile, but forgot to use `bundle exec`
# Let's tell the user how to use `bundle exec`
# We show this warning no matter if the command is slow or not
UI.important("fastlane detected a Gemfile in the current directory")
UI.important("However, it seems like you didn't use `bundle exec`")
UI.important("To launch fastlane faster, please use")
UI.message("")
UI.command "bundle exec fastlane #{ARGV.join(' ')}"
UI.message("")
elsif is_slow
# fastlane is slow and there is no Gemfile
# Let's tell the user how to use `gem cleanup` and how to
# start using a Gemfile
UI.important("Seems like launching fastlane takes a while - please run")
UI.message("")
UI.command "[sudo] gem cleanup"
UI.message("")
UI.important("to uninstall outdated gems and make fastlane launch faster")
UI.important("Alternatively it's recommended to start using a Gemfile to lock your dependencies")
UI.important("To get started with a Gemfile, run")
UI.message("")
UI.command "bundle init"
UI.command "echo 'gem \"fastlane\"' >> Gemfile"
UI.command "bundle install"
UI.message("")
UI.important("After creating the Gemfile and Gemfile.lock, commit those files into version control")
end
UI.important("Get started using a Gemfile for fastlane https://docs.fastlane.tools/getting-started/ios/setup/#use-a-gemfile")
end
# Returns an array of symbols for the available lanes for the Fastfile
# This doesn't actually use the Fastfile parser, but only
# the available lanes. This way it's much faster, which
# is very important in this case, since it will be executed
# every time one of the tools is launched
# Use this only if performance is :key:
def available_lanes
fastfile_path = FastlaneCore::FastlaneFolder.fastfile_path
return [] if fastfile_path.nil?
output = `cat #{fastfile_path.shellescape} | grep \"^\s*lane \:\" | awk -F ':' '{print $2}' | awk -F ' ' '{print $1}'`
return output.strip.split(" ").collect(&:to_sym)
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/console.rb | fastlane/lib/fastlane/console.rb | require 'irb'
module Fastlane
# Opens an interactive developer console
class Console
def self.execute(args, options)
ARGV.clear
IRB.setup(nil)
@irb = IRB::Irb.new(nil)
IRB.conf[:MAIN_CONTEXT] = @irb.context
IRB.conf[:PROMPT][:FASTLANE] = IRB.conf[:PROMPT][:SIMPLE].dup
IRB.conf[:PROMPT][:FASTLANE][:RETURN] = "%s\n"
@irb.context.prompt_mode = :FASTLANE
@irb.context.workspace = IRB::WorkSpace.new(binding)
trap('INT') do
@irb.signal_handle
end
UI.message('Welcome to fastlane interactive!')
catch(:IRB_EXIT) { @irb.eval_input }
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/action_collector.rb | fastlane/lib/fastlane/action_collector.rb | module Fastlane
class ActionCollector
def show_message
UI.message("Sending Crash/Success information. Learn more at https://docs.fastlane.tools/#metrics")
UI.message("No personal/sensitive data is sent. Only sharing the following:")
UI.message(launches)
UI.message(@error) if @error
UI.message("This information is used to fix failing actions and improve integrations that are often used.")
UI.message("You can disable this by adding `opt_out_usage` at the top of your Fastfile")
end
def determine_version(name)
self.class.determine_version(name)
end
# e.g.
# :gym
# :xcversion
# "fastlane-plugin-my_plugin/xcversion"
def self.determine_version(name)
if name.to_s.include?(PluginManager.plugin_prefix)
# That's an action from a plugin, we need to fetch its version number
begin
plugin_name = name.split("/").first.gsub(PluginManager.plugin_prefix, '')
return Fastlane.const_get(plugin_name.fastlane_class)::VERSION
rescue => ex
UI.verbose(ex)
return "undefined"
end
end
return Fastlane::VERSION # that's the case for all built-in actions
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/commands_generator.rb | fastlane/lib/fastlane/commands_generator.rb | require 'commander'
require 'fastlane/new_action'
require 'fastlane_core/ui/help_formatter'
HighLine.track_eof = false
module Fastlane
class CommandsGenerator
include Commander::Methods
def self.start
# since at this point we haven't yet loaded commander
# however we do want to log verbose information in the PluginManager
FastlaneCore::Globals.verbose = true if ARGV.include?("--verbose")
if ARGV.include?("--capture_output")
FastlaneCore::Globals.verbose = true
FastlaneCore::Globals.capture_output = true
end
FastlaneCore::Swag.show_loader
# has to be checked here - in case we want to troubleshoot plugin related issues
if ARGV.include?("--troubleshoot")
self.confirm_troubleshoot
end
if FastlaneCore::Globals.capture_output?
# Trace mode is enabled
# redirect STDOUT and STDERR
out_channel = StringIO.new
$stdout = out_channel
$stderr = out_channel
end
Fastlane.load_actions
FastlaneCore::Swag.stop_loader
# do not use "include" as it may be some where in the commandline where "env" is required, therefore explicit index->0
unless ARGV[0] == "env" || CLIToolsDistributor.running_version_command? || CLIToolsDistributor.running_help_command?
# *after* loading the plugins
hide_plugins_table = FastlaneCore::Env.truthy?("FASTLANE_HIDE_PLUGINS_TABLE")
Fastlane.plugin_manager.load_plugins(print_table: !hide_plugins_table)
Fastlane::PluginUpdateManager.start_looking_for_updates
end
self.new.run
ensure
Fastlane::PluginUpdateManager.show_update_status
if FastlaneCore::Globals.capture_output?
if $stdout.respond_to?(:string)
# Sometimes you can get NoMethodError: undefined method `string' for #<IO:<STDOUT>> when running with FastlaneRunner (swift)
FastlaneCore::Globals.captured_output = Helper.strip_ansi_colors($stdout.string)
end
$stdout = STDOUT
$stderr = STDERR
require "fastlane/environment_printer"
Fastlane::EnvironmentPrinter.output
end
end
def self.confirm_troubleshoot
if Helper.ci?
UI.error("---")
UI.error("You are trying to use '--troubleshoot' on CI")
UI.error("this option is not usable in CI, as it is insecure")
UI.error("---")
UI.user_error!("Do not use --troubleshoot in CI")
end
# maybe already set by 'start'
return if $troubleshoot
UI.error("---")
UI.error("Are you sure you want to enable '--troubleshoot'?")
UI.error("All commands will run in full unfiltered output mode.")
UI.error("Sensitive data, like passwords, could be printed to the log.")
UI.error("---")
if UI.confirm("Do you really want to enable --troubleshoot")
$troubleshoot = true
end
end
def run
program :name, 'fastlane'
program :version, Fastlane::VERSION
program :description, [
"CLI for 'fastlane' - #{Fastlane::DESCRIPTION}\n",
"\tRun using `fastlane [platform] [lane_name]`",
"\tTo pass values to the lanes use `fastlane [platform] [lane_name] key:value key2:value2`"
].join("\n")
program :help, 'Author', 'Felix Krause <fastlane@krausefx.com>'
program :help, 'Website', 'https://fastlane.tools'
program :help, 'GitHub', 'https://github.com/fastlane/fastlane'
program :help_formatter, FastlaneCore::HelpFormatter
global_option('--verbose') { FastlaneCore::Globals.verbose = true }
global_option('--capture_output', 'Captures the output of the current run, and generates a markdown issue template') do
FastlaneCore::Globals.capture_output = false
FastlaneCore::Globals.verbose = true
end
global_option('--troubleshoot', 'Enables extended verbose mode. Use with caution, as this even includes ALL sensitive data. Cannot be used on CI.')
global_option('--env STRING[,STRING2]', String, 'Add environment(s) to use with `dotenv`')
always_trace!
command :trigger do |c|
c.syntax = 'fastlane [lane]'
c.description = 'Run a specific lane. Pass the lane name and optionally the platform first.'
c.option('--disable_runner_upgrades', 'Prevents fastlane from attempting to update FastlaneRunner swift project')
c.option('--swift_server_port INT', 'Set specific port to communicate between fastlane and FastlaneRunner')
c.action do |args, options|
if ensure_fastfile
Fastlane::CommandLineHandler.handle(args, options)
end
end
end
command :init do |c|
c.syntax = 'fastlane init'
c.description = 'Helps you with your initial fastlane setup'
c.option('-u STRING', '--user STRING', String, 'iOS projects only: Your Apple ID')
c.action do |args, options|
is_swift_fastfile = args.include?("swift")
Fastlane::Setup.start(user: options.user, is_swift_fastfile: is_swift_fastfile)
end
end
# Creating alias for mapping "swift init" to "init swift"
alias_command(:'swift init', :init, 'swift')
command :new_action do |c|
c.syntax = 'fastlane new_action'
c.description = 'Create a new custom action for fastlane.'
c.option('--name STRING', String, 'Name of your new action')
c.action do |args, options|
Fastlane::NewAction.run(new_action_name: options.name)
end
end
command :socket_server do |c|
c.syntax = 'fastlane start_server'
c.description = 'Starts local socket server and enables only a single local connection'
c.option('-s', '--stay_alive', 'Keeps socket server up even after error or disconnects, requires CTRL-C to kill.')
c.option('-c seconds', '--connection_timeout', 'Sets connection established timeout')
c.option('-p port', '--port', "Sets the port on localhost for the socket connection")
c.action do |args, options|
default_connection_timeout = 5
stay_alive = options.stay_alive || false
connection_timeout = options.connection_timeout || default_connection_timeout
port = options.port || 2000
if stay_alive && options.connection_timeout.nil?
UI.important("stay_alive is set, but the connection timeout is not, this will give you #{default_connection_timeout} seconds to (re)connect")
end
require 'fastlane/server/socket_server'
require 'fastlane/server/socket_server_action_command_executor'
command_executor = SocketServerActionCommandExecutor.new
server = Fastlane::SocketServer.new(
command_executor: command_executor,
connection_timeout: connection_timeout,
stay_alive: stay_alive,
port: port
)
result = server.start
UI.success("Result: #{result}") if result
end
end
command :lanes do |c|
c.syntax = 'fastlane lanes'
c.description = 'Lists all available lanes and shows their description'
c.option("-j", "--json", "Output the lanes in JSON instead of text")
c.action do |args, options|
if options.json || ensure_fastfile
require 'fastlane/lane_list'
path = FastlaneCore::FastlaneFolder.fastfile_path
if options.json
Fastlane::LaneList.output_json(path)
else
Fastlane::LaneList.output(path)
end
end
end
end
command :list do |c|
c.syntax = 'fastlane list'
c.description = 'Lists all available lanes without description'
c.action do |args, options|
if ensure_fastfile
ff = Fastlane::FastFile.new(FastlaneCore::FastlaneFolder.fastfile_path)
UI.message("Available lanes:")
ff.runner.available_lanes.each do |lane|
UI.message("- #{lane}")
end
UI.important("Execute using `fastlane [lane_name]`")
end
end
end
command :docs do |c|
c.syntax = 'fastlane docs'
c.description = 'Generate a markdown based documentation based on the Fastfile'
c.option('-f', '--force', 'Overwrite the existing README.md in the ./fastlane folder')
c.action do |args, options|
if ensure_fastfile
ff = Fastlane::FastFile.new(File.join(FastlaneCore::FastlaneFolder.path || '.', 'Fastfile'))
UI.message("You don't need to run `fastlane docs` manually anymore, this will be done automatically for you when running a lane.")
Fastlane::DocsGenerator.run(ff)
end
end
end
command :run do |c|
c.syntax = 'fastlane run [action] key1:value1 key2:value2'
c.description = 'Run a fastlane one-off action without a full lane'
c.action do |args, options|
require 'fastlane/one_off'
result = Fastlane::OneOff.execute(args: args)
UI.success("Result: #{result}") if result
end
end
command :actions do |c|
c.syntax = 'fastlane actions'
c.description = 'Lists all available fastlane actions'
c.option('--platform STRING', String, 'Only show actions available on the given platform')
c.action do |args, options|
require 'fastlane/documentation/actions_list'
Fastlane::ActionsList.run(filter: args.first, platform: options.platform)
end
end
command :action do |c|
c.syntax = 'fastlane action [tool_name]'
c.description = 'Shows more information for a specific command'
c.action do |args, options|
require 'fastlane/documentation/actions_list'
Fastlane::ActionsList.run(filter: args.first)
end
end
command :console do |c|
c.syntax = 'fastlane console'
c.description = 'Opens an interactive developer console'
c.action do |args, options|
require 'fastlane/console'
Fastlane::Console.execute(args, options)
end
end
command :enable_auto_complete do |c|
c.syntax = 'fastlane enable_auto_complete'
c.description = 'Enable tab auto completion'
c.option('-c STRING[,STRING2]', '--custom STRING[,STRING2]', String, 'Add custom command(s) for which tab auto complete should be enabled too')
c.action do |args, options|
require 'fastlane/auto_complete'
Fastlane::AutoComplete.execute(args, options)
end
end
command :env do |c|
c.syntax = 'fastlane env'
c.description = 'Print your fastlane environment, use this when you submit an issue on GitHub'
c.action do |args, options|
require "fastlane/environment_printer"
Fastlane::EnvironmentPrinter.output
end
end
command :update_fastlane do |c|
c.syntax = 'fastlane update_fastlane'
c.description = 'Update fastlane to the latest release'
c.action do |args, options|
require 'fastlane/one_off'
Fastlane::OneOff.run(action: "update_fastlane", parameters: {})
end
end
#####################################################
# @!group Plugins
#####################################################
command :new_plugin do |c|
c.syntax = 'fastlane new_plugin [plugin_name]'
c.description = 'Create a new plugin that can be used with fastlane'
c.action do |args, options|
PluginGenerator.new.generate(args.shift)
end
end
command :add_plugin do |c|
c.syntax = 'fastlane add_plugin [plugin_name]'
c.description = 'Add a new plugin to your fastlane setup'
c.action do |args, options|
args << UI.input("Enter the name of the plugin to install: ") if args.empty?
args.each do |plugin_name|
Fastlane.plugin_manager.add_dependency(plugin_name)
end
UI.important("Make sure to commit your Gemfile, Gemfile.lock and #{PluginManager::PLUGINFILE_NAME} to version control")
Fastlane.plugin_manager.install_dependencies!
end
end
command :install_plugins do |c|
c.syntax = 'fastlane install_plugins'
c.description = 'Install all plugins for this project'
c.action do |args, options|
Fastlane.plugin_manager.install_dependencies!
end
end
command :update_plugins do |c|
c.syntax = 'fastlane update_plugins'
c.description = 'Update all plugin dependencies'
c.action do |args, options|
Fastlane.plugin_manager.update_dependencies!
end
end
command :search_plugins do |c|
c.syntax = 'fastlane search_plugins [search_query]'
c.description = 'Search for plugins, search query is optional'
c.action do |args, options|
search_query = args.last
PluginSearch.print_plugins(search_query: search_query)
end
end
#####################################################
# @!group Swift
#####################################################
if FastlaneCore::FastlaneFolder.swift?
command :generate_swift do |c|
c.syntax = 'fastlane generate_swift'
c.description = 'Generates additional Swift APIs for plugins and local actions'
c.action do |args, options|
SwiftActionsAPIGenerator.new(target_output_path: FastlaneCore::FastlaneFolder.swift_folder_path).generate_swift
SwiftPluginsAPIGenerator.new(target_output_path: FastlaneCore::FastlaneFolder.swift_folder_path).generate_swift
end
end
end
default_command(:trigger)
run!
end
# Makes sure a Fastfile is available
# Shows an appropriate message to the user
# if that's not the case
# return true if the Fastfile is available
def ensure_fastfile
return true if FastlaneCore::FastlaneFolder.setup?
create = UI.confirm('Could not find fastlane in current directory. Make sure to have your fastlane configuration files inside a folder called "fastlane". Would you like to set fastlane up?')
if create
Fastlane::Setup.start
end
return false
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/runner.rb | fastlane/lib/fastlane/runner.rb | module Fastlane
class Runner
# Symbol for the current lane
attr_accessor :current_lane
# Symbol for the current platform
attr_accessor :current_platform
# @return [Hash] All the lanes available, first the platform, then the lane
attr_accessor :lanes
def full_lane_name
[current_platform, current_lane].reject(&:nil?).join(' ')
end
# This will take care of executing **one** lane. That's when the user triggers a lane from the CLI for example
# This method is **not** executed when switching a lane
# @param lane The name of the lane to execute
# @param platform The name of the platform to execute
# @param parameters [Hash] The parameters passed from the command line to the lane
def execute(lane, platform = nil, parameters = nil)
UI.crash!("No lane given") unless lane
self.current_lane = lane.to_sym
self.current_platform = (platform ? platform.to_sym : nil)
lane_obj = lanes.fetch(current_platform, {}).fetch(current_lane, nil)
UI.user_error!("Could not find lane '#{full_lane_name}'. Available lanes: #{available_lanes.join(', ')}") unless lane_obj
UI.user_error!("You can't call the private lane '#{lane}' directly") if lane_obj.is_private
ENV["FASTLANE_LANE_NAME"] = current_lane.to_s
ENV["FASTLANE_PLATFORM_NAME"] = (current_platform ? current_platform.to_s : nil)
Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] = current_platform
Actions.lane_context[Actions::SharedValues::LANE_NAME] = full_lane_name
UI.success("Driving the lane '#{full_lane_name}' π")
return_val = nil
path_to_use = FastlaneCore::FastlaneFolder.path || Dir.pwd
parameters ||= {} # by default no parameters
begin
Dir.chdir(path_to_use) do # the file is located in the fastlane folder
execute_flow_block(before_all_blocks, current_platform, current_lane, parameters)
execute_flow_block(before_each_blocks, current_platform, current_lane, parameters)
return_val = lane_obj.call(parameters)
# after blocks are only called if no exception was raised before
# Call the platform specific after block and then the general one
execute_flow_block(after_each_blocks, current_platform, current_lane, parameters)
execute_flow_block(after_all_blocks, current_platform, current_lane, parameters)
end
return return_val
rescue => ex
Dir.chdir(path_to_use) do
# Provide error block exception without color code
begin
error_blocks[current_platform].call(current_lane, ex, parameters) if current_platform && error_blocks[current_platform]
error_blocks[nil].call(current_lane, ex, parameters) if error_blocks[nil]
rescue => error_block_exception
UI.error("An error occurred while executing the `error` block:")
UI.error(error_block_exception.to_s)
raise ex # raise the original error message
end
end
raise ex
end
end
# @param filter_platform: Filter, to only show the lanes of a given platform
# @return an array of lanes (platform lane_name) to print them out to the user
def available_lanes(filter_platform = nil)
all = []
lanes.each do |platform, platform_lanes|
next if filter_platform && filter_platform.to_s != platform.to_s # skip actions that don't match
platform_lanes.each do |lane_name, lane|
all << [platform, lane_name].reject(&:nil?).join(' ') unless lane.is_private
end
end
all
end
# Pass a action symbol (e.g. :deliver or :commit_version_bump)
# and this method will return a reference to the action class
# if it exists. In case the action with this name can't be found
# this method will return nil.
# This method is being called by `trigger_action_by_name` to see
# if a given action is available (either built-in or loaded from a plugin)
# and is also being called from the fastlane docs generator
def class_reference_from_action_name(method_sym)
method_str = method_sym.to_s.delete("?") # as a `?` could be at the end of the method name
class_ref = Actions.action_class_ref(method_str)
return class_ref if class_ref && class_ref.respond_to?(:run)
nil
end
# Pass a action alias symbol (e.g. :enable_automatic_code_signing)
# and this method will return a reference to the action class
# if it exists. In case the action with this alias can't be found
# this method will return nil.
def class_reference_from_action_alias(method_sym)
alias_found = find_alias(method_sym.to_s)
return nil unless alias_found
class_reference_from_action_name(alias_found.to_sym)
end
# lookup if an alias exists
def find_alias(action_name)
Actions.alias_actions.each do |key, v|
next unless Actions.alias_actions[key]
next unless Actions.alias_actions[key].include?(action_name)
return key
end
nil
end
# This is being called from `method_missing` from the Fastfile
# It's also used when an action is called from another action
# @param from_action Indicates if this action is being triggered by another action.
# If so, it won't show up in summary.
def trigger_action_by_name(method_sym, custom_dir, from_action, *arguments)
# First, check if there is a predefined method in the actions folder
class_ref = class_reference_from_action_name(method_sym)
unless class_ref
class_ref = class_reference_from_action_alias(method_sym)
# notify action that it has been used by alias
if class_ref.respond_to?(:alias_used)
orig_action = method_sym.to_s
arguments = [{}] if arguments.empty?
class_ref.alias_used(orig_action, arguments.first)
end
end
# It's important to *not* have this code inside the rescue block
# otherwise all NameErrors will be caught and the error message is
# confusing
begin
return self.try_switch_to_lane(method_sym, arguments)
rescue LaneNotAvailableError
# We don't actually handle this here yet
# We just try to use a user configured lane first
# and only if there is none, we're gonna check for the
# built-in actions
end
if class_ref
if class_ref.respond_to?(:run)
# Action is available, now execute it
return self.execute_action(method_sym, class_ref, arguments, custom_dir: custom_dir, from_action: from_action)
else
UI.user_error!("Action '#{method_sym}' of class '#{class_name}' was found, but has no `run` method.")
end
end
# No lane, no action, let's at least show the correct error message
if Fastlane.plugin_manager.plugin_is_added_as_dependency?(PluginManager.plugin_prefix + method_sym.to_s)
# That's a plugin, but for some reason we can't find it
UI.user_error!("Plugin '#{method_sym}' was not properly loaded, make sure to follow the plugin docs for troubleshooting: #{PluginManager::TROUBLESHOOTING_URL}")
elsif Fastlane::Actions.formerly_bundled_actions.include?(method_sym.to_s)
# This was a formerly bundled action which is now a plugin.
UI.verbose(caller.join("\n"))
UI.user_error!("The action '#{method_sym}' is no longer bundled with fastlane. You can install it using `fastlane add_plugin #{method_sym}`")
else
# So there is no plugin under that name, so just show the error message generated by the lane switch
UI.verbose(caller.join("\n"))
UI.user_error!("Could not find action, lane or variable '#{method_sym}'. Check out the documentation for more details: https://docs.fastlane.tools/actions")
end
end
#
# All the methods that are usually called on execution
#
class LaneNotAvailableError < StandardError
end
def try_switch_to_lane(new_lane, parameters)
block = lanes.fetch(current_platform, {}).fetch(new_lane, nil)
block ||= lanes.fetch(nil, {}).fetch(new_lane, nil) # fallback to general lane for multiple platforms
if block
original_full = full_lane_name
original_lane = current_lane
UI.user_error!("Parameters for a lane must always be a hash") unless (parameters.first || {}).kind_of?(Hash)
execute_flow_block(before_each_blocks, current_platform, new_lane, parameters)
pretty = [new_lane]
pretty = [current_platform, new_lane] if current_platform
Actions.execute_action("Switch to #{pretty.join(' ')} lane") {} # log the action
UI.message("Cruising over to lane '#{pretty.join(' ')}' π")
# Actually switch lane now
self.current_lane = new_lane
result = block.call(parameters.first || {}) # to always pass a hash
self.current_lane = original_lane
# after blocks are only called if no exception was raised before
# Call the platform specific after block and then the general one
execute_flow_block(after_each_blocks, current_platform, new_lane, parameters)
UI.message("Cruising back to lane '#{original_full}' π")
return result
else
raise LaneNotAvailableError.new, "Lane not found"
end
end
def execute_action(method_sym, class_ref, arguments, custom_dir: nil, from_action: false)
if from_action == true
custom_dir = "." # We preserve the directory from where the previous action was called from
elsif custom_dir.nil?
custom_dir ||= "." if Helper.test?
custom_dir ||= ".."
end
verify_supported_os(method_sym, class_ref)
begin
Dir.chdir(custom_dir) do # go up from the fastlane folder, to the project folder
# Removing step_name before its parsed into configurations
args = arguments.kind_of?(Array) && arguments.first.kind_of?(Hash) ? arguments.first : {}
step_name = args.delete(:step_name)
# arguments is an array by default, containing an hash with the actual parameters
# Since we usually just need the passed hash, we'll just use the first object if there is only one
if arguments.count == 0
configurations = ConfigurationHelper.parse(class_ref, {}) # no parameters => empty hash
elsif arguments.count == 1 && arguments.first.kind_of?(Hash)
configurations = ConfigurationHelper.parse(class_ref, arguments.first) # Correct configuration passed
elsif !class_ref.available_options
# This action does not use the new action format
# Just passing the arguments to this method
configurations = arguments
else
UI.user_error!("You have to call the integration like `#{method_sym}(key: \"value\")`. Run `fastlane action #{method_sym}` for all available keys. Please check out the current documentation on GitHub.")
end
# If another action is calling this action, we shouldn't show it in the summary
# A nil value for action_name will hide it from the summary
unless from_action
action_name = step_name
action_name ||= class_ref.method(:step_text).arity == 1 ? class_ref.step_text(configurations) : class_ref.step_text
end
Actions.execute_action(action_name) do
if Fastlane::Actions.is_deprecated?(class_ref)
puts("==========================================".deprecated)
puts("This action (#{method_sym}) is deprecated".deprecated)
puts(class_ref.deprecated_notes.to_s.remove_markdown.deprecated) if class_ref.deprecated_notes
puts("==========================================\n".deprecated)
end
class_ref.runner = self # needed to call another action from an action
return class_ref.run(configurations)
end
end
rescue Interrupt => e
raise e # reraise the interruption to avoid logging this as a crash
rescue FastlaneCore::Interface::FastlaneCommonException => e # these are exceptions that we don't count as crashes
raise e
rescue FastlaneCore::Interface::FastlaneError => e # user_error!
action_completed(method_sym.to_s, status: FastlaneCore::ActionCompletionStatus::USER_ERROR, exception: e)
raise e
rescue Exception => e # rubocop:disable Lint/RescueException
# high chance this is actually FastlaneCore::Interface::FastlaneCrash, but can be anything else
# Catches all exceptions, since some plugins might use system exits to get out
action_completed(method_sym.to_s, status: FastlaneCore::ActionCompletionStatus::FAILED, exception: e)
raise e
end
end
def action_completed(action_name, status: nil, exception: nil)
# https://github.com/fastlane/fastlane/issues/11913
# if exception.nil? || exception.fastlane_should_report_metrics?
# action_completion_context = FastlaneCore::ActionCompletionContext.context_for_action_name(action_name, args: ARGV, status: status)
# FastlaneCore.session.action_completed(completion_context: action_completion_context)
# end
end
def execute_flow_block(block, current_platform, lane, parameters)
# Call the platform specific block and default back to the general one
block[current_platform].call(lane, parameters) if block[current_platform] && current_platform
block[nil].call(lane, parameters) if block[nil]
end
def verify_supported_os(name, class_ref)
if class_ref.respond_to?(:is_supported?)
# This value is filled in based on the executed platform block. Might be nil when lane is in root of Fastfile
platform = Actions.lane_context[Actions::SharedValues::PLATFORM_NAME]
if platform
unless class_ref.is_supported?(platform)
UI.important("Action '#{name}' isn't known to support operating system '#{platform}'.")
end
end
end
end
# Called internally to setup the runner object
#
# @param lane [Lane] A lane object
def add_lane(lane, override = false)
lanes[lane.platform] ||= {}
if !override && lanes[lane.platform][lane.name]
UI.user_error!("Lane '#{lane.name}' was defined multiple times!")
end
lanes[lane.platform][lane.name] = lane
end
def set_before_each(platform, block)
before_each_blocks[platform] = block
end
def set_after_each(platform, block)
after_each_blocks[platform] = block
end
def set_before_all(platform, block)
unless before_all_blocks[platform].nil?
UI.error("You defined multiple `before_all` blocks in your `Fastfile`. The last one being set will be used.")
end
before_all_blocks[platform] = block
end
def set_after_all(platform, block)
unless after_all_blocks[platform].nil?
UI.error("You defined multiple `after_all` blocks in your `Fastfile`. The last one being set will be used.")
end
after_all_blocks[platform] = block
end
def set_error(platform, block)
unless error_blocks[platform].nil?
UI.error("You defined multiple `error` blocks in your `Fastfile`. The last one being set will be used.")
end
error_blocks[platform] = block
end
def lanes
@lanes ||= {}
end
def did_finish
# to maintain compatibility with other sibling classes that have this API
end
def before_each_blocks
@before_each ||= {}
end
def after_each_blocks
@after_each ||= {}
end
def before_all_blocks
@before_all ||= {}
end
def after_all_blocks
@after_all ||= {}
end
def error_blocks
@error_blocks ||= {}
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/one_off.rb | fastlane/lib/fastlane/one_off.rb | module Fastlane
# Call actions without triggering a full lane
class OneOff
def self.execute(args: nil)
action_parameters = {}
action_name = nil
args.each do |current|
if current.include?(":") # that's a key/value which we want to pass to the lane
key, value = current.split(":", 2)
UI.user_error!("Please pass values like this: key:value") unless key.length > 0
value = CommandLineHandler.convert_value(value)
UI.verbose("Using #{key}: #{value}")
action_parameters[key.to_sym] = value
else
action_name ||= current
end
end
UI.crash!("invalid syntax") unless action_name
run(action: action_name,
parameters: action_parameters)
end
def self.run(action: nil, parameters: nil)
Fastlane.load_actions
class_ref = Actions.action_class_ref(action)
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
r = Runner.new
r.execute_action(action, class_ref, [parameters], custom_dir: '.')
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/fast_file.rb | fastlane/lib/fastlane/fast_file.rb | require "rubygems/requirement"
module Fastlane
class FastFile
# Stores all relevant information from the currently running process
attr_accessor :runner
# the platform in which we're currently in when parsing the Fastfile
# This is used to identify the platform in which the lane is in
attr_accessor :current_platform
SharedValues = Fastlane::Actions::SharedValues
# @return The runner which can be executed to trigger the given actions
def initialize(path = nil)
return unless (path || '').length > 0
UI.user_error!("Could not find Fastfile at path '#{path}'") unless File.exist?(path)
@path = File.expand_path(path)
content = File.read(path, encoding: "utf-8")
# From https://github.com/orta/danger/blob/master/lib/danger/Dangerfile.rb
if content.tr!('βββββ', %(""'''))
UI.error("Your #{File.basename(path)} has had smart quotes sanitised. " \
'To avoid issues in the future, you should not use ' \
'TextEdit for editing it. If you are not using TextEdit, ' \
'you should turn off smart quotes in your editor of choice.')
end
content.scan(/^\s*require ["'](.*?)["']/).each do |current|
gem_name = current.last
next if gem_name.include?(".") # these are local gems
begin
require(gem_name)
rescue LoadError
UI.important("You have required a gem, if this is a third party gem, please use `fastlane_require '#{gem_name}'` to ensure the gem is installed locally.")
end
end
parse(content, @path)
end
def parsing_binding
binding
end
def parse(data, path = nil)
@runner ||= Runner.new
Dir.chdir(FastlaneCore::FastlaneFolder.path || Dir.pwd) do # context: fastlane subfolder
# create nice path that we want to print in case of some problem
relative_path = path.nil? ? '(eval)' : Pathname.new(path).relative_path_from(Pathname.new(Dir.pwd)).to_s
begin
# We have to use #get_binding method, because some test files defines method called `path` (for example SwitcherFastfile)
# and local variable has higher priority, so it causes to remove content of original Fastfile for example. With #get_binding
# is this always clear and safe to declare any local variables we want, because the eval function uses the instance scope
# instead of local.
# rubocop:disable Security/Eval
eval(data, parsing_binding, relative_path) # using eval is ok for this case
# rubocop:enable Security/Eval
rescue SyntaxError => ex
match = ex.to_s.match(/#{Regexp.escape(relative_path)}:(\d+)/)
if match
line = match[1]
UI.content_error(data, line)
UI.user_error!("Syntax error in your Fastfile on line #{line}: #{ex}")
else
UI.user_error!("Syntax error in your Fastfile: #{ex}")
end
end
end
self
end
#####################################################
# @!group DSL
#####################################################
# User defines a new lane
def lane(lane_name, &block)
UI.user_error!("You have to pass a block using 'do' for lane '#{lane_name}'. Make sure you read the docs on GitHub.") unless block
self.runner.add_lane(Lane.new(platform: self.current_platform,
block: block,
description: desc_collection,
name: lane_name,
is_private: false))
@desc_collection = nil # reset the collected description again for the next lane
end
# User defines a new private lane, which can't be called from the CLI
def private_lane(lane_name, &block)
UI.user_error!("You have to pass a block using 'do' for lane '#{lane_name}'. Make sure you read the docs on GitHub.") unless block
self.runner.add_lane(Lane.new(platform: self.current_platform,
block: block,
description: desc_collection,
name: lane_name,
is_private: true))
@desc_collection = nil # reset the collected description again for the next lane
end
# User defines a lane that can overwrite existing lanes. Useful when importing a Fastfile
def override_lane(lane_name, &block)
UI.user_error!("You have to pass a block using 'do' for lane '#{lane_name}'. Make sure you read the docs on GitHub.") unless block
self.runner.add_lane(Lane.new(platform: self.current_platform,
block: block,
description: desc_collection,
name: lane_name,
is_private: false), true)
@desc_collection = nil # reset the collected description again for the next lane
end
# User defines a platform block
def platform(platform_name)
SupportedPlatforms.verify!(platform_name)
self.current_platform = platform_name
yield
self.current_platform = nil
end
# Is executed before each test run
def before_all(&block)
@runner.set_before_all(@current_platform, block)
end
# Is executed before each lane
def before_each(&block)
@runner.set_before_each(@current_platform, block)
end
# Is executed after each test run
def after_all(&block)
@runner.set_after_all(@current_platform, block)
end
# Is executed before each lane
def after_each(&block)
@runner.set_after_each(@current_platform, block)
end
# Is executed if an error occurred during fastlane execution
def error(&block)
@runner.set_error(@current_platform, block)
end
# Is used to look if the method is implemented as an action
def method_missing(method_sym, *arguments, &_block)
self.runner.trigger_action_by_name(method_sym, nil, false, *arguments)
end
#####################################################
# @!group Other things
#####################################################
# Is the given key a platform block or a lane?
def is_platform_block?(key)
UI.crash!('No key given') unless key
return false if self.runner.lanes.fetch(nil, {}).fetch(key.to_sym, nil)
return true if self.runner.lanes[key.to_sym].kind_of?(Hash)
if key.to_sym == :update
# The user ran `fastlane update`, instead of `fastlane update_fastlane`
# We're gonna be nice and understand what the user is trying to do
require 'fastlane/one_off'
Fastlane::OneOff.run(action: "update_fastlane", parameters: {})
else
UI.user_error!("Could not find '#{key}'. Available lanes: #{self.runner.available_lanes.join(', ')}")
end
end
def actions_path(path)
UI.crash!("Path '#{path}' not found!") unless File.directory?(path)
Actions.load_external_actions(path)
end
# Execute shell command
# Accepts arguments with and without the command named keyword so that sh
# behaves like other actions with named keywords
# https://github.com/fastlane/fastlane/issues/14930
#
# Example:
# sh("ls")
# sh("ls", log: false)
# sh(command: "ls")
# sh(command: "ls", step_name: "listing the files")
# sh(command: "ls", log: false)
def sh(*args, &b)
# First accepts hash (or named keywords) like other actions
# Otherwise uses sh method that doesn't have an interface like an action
if args.count == 1 && args.first.kind_of?(Hash)
options = args.first
command = options.delete(:command)
raise ArgumentError, "sh requires :command keyword in argument" if command.nil?
log = options[:log].nil? ? true : options[:log]
FastFile.sh(*command, step_name: options[:step_name], log: log, error_callback: options[:error_callback], &b)
elsif args.count != 1 && args.last.kind_of?(Hash)
new_args = args.dup
options = new_args.pop
log = options[:log].nil? ? true : options[:log]
FastFile.sh(*new_args, step_name: options[:step_name], log: log, error_callback: options[:error_callback], &b)
else
FastFile.sh(*args, &b)
end
end
def self.sh(*command, step_name: nil, log: true, error_callback: nil, &b)
command_header = step_name
command_header ||= log ? Actions.shell_command_from_args(*command) : "shell command"
Actions.execute_action(command_header) do
Actions.sh_no_action(*command, log: log, error_callback: error_callback, &b)
end
end
def desc(string)
desc_collection << string
end
def desc_collection
@desc_collection ||= []
end
def fastlane_require(gem_name)
FastlaneRequire.install_gem_if_needed(gem_name: gem_name, require_gem: true)
end
def generated_fastfile_id(id)
UI.important("The `generated_fastfile_id` action was deprecated, you can remove the line from your `Fastfile`")
end
def import(path = nil)
UI.user_error!("Please pass a path to the `import` action") unless path
path = path.dup.gsub("~", Dir.home)
unless Pathname.new(path).absolute? # unless an absolute path
path = File.join(File.expand_path('..', @path), path)
end
UI.user_error!("Could not find Fastfile at path '#{path}'") unless File.exist?(path)
# First check if there are local actions to import in the same directory as the Fastfile
actions_path = File.join(File.expand_path("..", path), 'actions')
Fastlane::Actions.load_external_actions(actions_path) if File.directory?(actions_path)
action_launched('import')
return_value = parse(File.read(path), path)
action_completed('import', status: FastlaneCore::ActionCompletionStatus::SUCCESS)
return return_value
end
def find_tag(folder: nil, version: nil, remote: false)
req = Gem::Requirement.new(version)
all_tags = get_tags(folder: folder, remote: remote)
return all_tags.select { |t| req =~ FastlaneCore::TagVersion.new(t) }.last
end
# @param url [String] The git URL to clone the repository from
# @param branch [String] The branch to checkout in the repository
# @param path [String] The path to the Fastfile
# @param version [String, Array] Version requirement for repo tags
# @param dependencies [Array] An optional array of additional Fastfiles in the repository
# @param cache_path [String] An optional path to a directory where the repository should be cloned into
# @param git_extra_headers [Array] An optional array of custom HTTP headers to access the git repo (`Authorization: Basic <YOUR BASE64 KEY>`, `Cache-Control: no-cache`, etc.)
def import_from_git(url: nil, branch: 'HEAD', path: 'fastlane/Fastfile', version: nil, dependencies: [], cache_path: nil, git_extra_headers: []) # rubocop:disable Metrics/PerceivedComplexity
UI.user_error!("Please pass a path to the `import_from_git` action") if url.to_s.length == 0
Actions.execute_action('import_from_git') do
require 'tmpdir'
action_launched('import_from_git')
is_eligible_for_caching = !cache_path.nil?
UI.message("Eligible for caching") if is_eligible_for_caching
# Checkout the repo
repo_name = url.split("/").last
checkout_param = branch
import_block = proc do |target_path|
clone_folder = File.join(target_path, repo_name)
checkout_dependencies = dependencies.map(&:shellescape).join(" ")
# If the current call is eligible for caching, we check out all the
# files and directories. If not, we only check out the specified
# `path` and `dependencies`.
checkout_path = is_eligible_for_caching ? "" : "#{path.shellescape} #{checkout_dependencies}"
if Dir[clone_folder].empty?
UI.message("Cloning remote git repo...")
Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
command = ['git', 'clone', url, clone_folder, '--no-checkout']
# When using cached clones, we need the entire repository history
# so we can switch between tags or branches instantly, or else,
# it would defeat the caching's purpose.
command += ['--depth', '1'] unless is_eligible_for_caching
command += ['--branch', branch] unless branch == 'HEAD'
git_extra_headers.each do |header|
command += ['--config', "http.extraHeader=#{header}"]
end
Actions.sh(*command)
end
end
unless version.nil?
if is_eligible_for_caching
checkout_param = find_tag(folder: clone_folder, version: version, remote: false)
if checkout_param.nil?
# Update the repo and try again before failing
UI.message("Updating git repo...")
Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
Actions.sh("cd #{clone_folder.shellescape} && git checkout #{branch} && git reset --hard && git pull --all")
end
checkout_param = find_tag(folder: clone_folder, version: version, remote: false)
else
UI.message("Found tag #{checkout_param}. No git repo update needed.")
end
else
checkout_param = find_tag(folder: clone_folder, version: version, remote: true)
end
UI.user_error!("No tag found matching #{version.inspect}") if checkout_param.nil?
end
if is_eligible_for_caching
if version.nil?
# Update the repo if it's eligible for caching but the version isn't specified
UI.message("Fetching remote git branches and updating git repo...")
Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
command = "cd #{clone_folder.shellescape} && git fetch --all --quiet && git checkout #{checkout_param.shellescape} #{checkout_path} && git reset --hard"
# Check if checked out "branch" is actually a branch or a tag
current_branch = Actions.sh("cd #{clone_folder.shellescape} && git rev-parse --abbrev-ref HEAD")
command << " && git rebase" unless current_branch.strip.eql?("HEAD")
Actions.sh(command)
end
else
begin
# https://stackoverflow.com/a/1593574/865175
current_tag = Actions.sh("cd #{clone_folder.shellescape} && git describe --exact-match --tags HEAD").strip
rescue
current_tag = nil
end
if current_tag != version
Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{checkout_path}")
end
end
else
Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{checkout_path}")
end
# Knowing that we check out all the files and directories when the
# current call is eligible for caching, we don't need to also
# explicitly check out the "actions" directory.
unless is_eligible_for_caching
# We also want to check out all the local actions of this fastlane setup
containing = path.split(File::SEPARATOR)[0..-2]
containing = "." if containing.count == 0
actions_folder = File.join(containing, "actions")
begin
Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{actions_folder.shellescape}")
rescue
# We don't care about a failure here, as local actions are optional
end
end
return_value = nil
if dependencies.any?
return_value = [import(File.join(clone_folder, path))]
return_value += dependencies.map { |file_path| import(File.join(clone_folder, file_path)) }
else
return_value = import(File.join(clone_folder, path))
end
action_completed('import_from_git', status: FastlaneCore::ActionCompletionStatus::SUCCESS)
return return_value
end
if is_eligible_for_caching
import_block.call(File.expand_path(cache_path))
else
Dir.mktmpdir("fl_clone", &import_block)
end
end
end
#####################################################
# @!group Versioning helpers
#####################################################
def get_tags(folder: nil, remote: false)
if remote
UI.message("Fetching remote git tags...")
Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
Actions.sh("cd #{folder.shellescape} && git fetch --all --tags -q")
end
end
# Fetch all possible tags
git_tags_string = Actions.sh("cd #{folder.shellescape} && git tag -l")
git_tags = git_tags_string.split("\n")
# Sort tags based on their version number
return git_tags
.select { |tag| FastlaneCore::TagVersion.correct?(tag) }
.sort_by { |tag| FastlaneCore::TagVersion.new(tag) }
end
#####################################################
# @!group Overwriting Ruby methods
#####################################################
# Speak out loud
def say(value)
# Overwrite this, since there is already a 'say' method defined in the Ruby standard library
value ||= yield
value = { text: value } if value.kind_of?(String) || value.kind_of?(Array)
self.runner.trigger_action_by_name(:say, nil, false, value)
end
def puts(value)
# Overwrite this, since there is already a 'puts' method defined in the Ruby standard library
value ||= yield if block_given?
action_launched('puts')
return_value = Fastlane::Actions::PutsAction.run([value])
action_completed('puts', status: FastlaneCore::ActionCompletionStatus::SUCCESS)
return return_value
end
def test(params = {})
# Overwrite this, since there is already a 'test' method defined in the Ruby standard library
self.runner.try_switch_to_lane(:test, [params])
end
def action_launched(action_name)
action_launch_context = FastlaneCore::ActionLaunchContext.context_for_action_name(action_name,
fastlane_client_language: :ruby,
args: ARGV)
FastlaneCore.session.action_launched(launch_context: action_launch_context)
end
def action_completed(action_name, status: nil)
completion_context = FastlaneCore::ActionCompletionContext.context_for_action_name(action_name,
args: ARGV,
status: status)
FastlaneCore.session.action_completed(completion_context: completion_context)
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/lane_manager.rb | fastlane/lib/fastlane/lane_manager.rb | require_relative 'lane_manager_base.rb'
module Fastlane
class LaneManager < LaneManagerBase
# @param platform The name of the platform to execute
# @param lane_name The name of the lane to execute
# @param parameters [Hash] The parameters passed from the command line to the lane
# @param A custom Fastfile path, this is used by fastlane.ci
def self.cruise_lane(platform, lane, parameters = nil, fastfile_path = nil)
UI.user_error!("lane must be a string") unless lane.kind_of?(String) || lane.nil?
UI.user_error!("platform must be a string") unless platform.kind_of?(String) || platform.nil?
UI.user_error!("parameters must be a hash") unless parameters.kind_of?(Hash) || parameters.nil?
ff = Fastlane::FastFile.new(fastfile_path || FastlaneCore::FastlaneFolder.fastfile_path)
is_platform = false
begin
is_platform = ff.is_platform_block?(lane)
rescue # rescue, because this raises an exception if it can't be found at all
end
unless is_platform
# maybe the user specified a default platform
# We'll only do this, if the lane specified isn't a platform, as we want to list all platforms then
# Make sure that's not a lane without a platform
unless ff.runner.available_lanes.include?(lane)
platform ||= Actions.lane_context[Actions::SharedValues::DEFAULT_PLATFORM]
end
end
if !platform && lane
# Either, the user runs a specific lane in root or want to auto complete the available lanes for a platform
# e.g. `fastlane ios` should list all available iOS actions
if ff.is_platform_block?(lane)
platform = lane
lane = nil
end
end
platform, lane = choose_lane(ff, platform) unless lane
started = Time.now
e = nil
begin
ff.runner.execute(lane, platform, parameters)
rescue NameError => ex
print_lane_context
print_error_line(ex)
e = ex
rescue Exception => ex # rubocop:disable Lint/RescueException
# We also catch Exception, since the implemented action might send a SystemExit signal
# (or similar). We still want to catch that, since we want properly finish running fastlane
# Tested with `xcake`, which throws a `Xcake::Informative` object
print_lane_context
print_error_line(ex)
UI.error(ex.to_s) if ex.kind_of?(StandardError) # we don't want to print things like 'system exit'
e = ex
end
# After running the lanes, since skip_docs might be somewhere in-between
Fastlane::DocsGenerator.run(ff) unless skip_docs?
duration = ((Time.now - started) / 60.0).round
finish_fastlane(ff, duration, e)
return ff
end
def self.skip_docs?
Helper.test? || FastlaneCore::Env.truthy?("FASTLANE_SKIP_DOCS")
end
# Lane chooser if user didn't provide a lane
# @param platform: is probably nil, but user might have called `fastlane android`, and only wants to list those actions
def self.choose_lane(ff, platform)
available = []
# nil is the key for lanes that are not under a specific platform
lane_platforms = [nil] + Fastlane::SupportedPlatforms.all
lane_platforms.each do |p|
available += ff.runner.lanes[p].to_a.reject { |lane| lane.last.is_private }
end
if available.empty?
UI.user_error!("It looks like you don't have any lanes to run just yet. Check out how to get started here: https://github.com/fastlane/fastlane π")
end
rows = []
available.each_with_index do |lane, index|
rows << [index + 1, lane.last.pretty_name, lane.last.description.join("\n")]
end
rows << [0, "cancel", "No selection, exit fastlane!"]
require 'terminal-table'
table = Terminal::Table.new(
title: "Available lanes to run",
headings: ['Number', 'Lane Name', 'Description'],
rows: FastlaneCore::PrintTable.transform_output(rows)
)
UI.message("Welcome to fastlane! Here's what your app is set up to do:")
puts(table)
fastlane_command = Helper.bundler? ? "bundle exec fastlane" : "fastlane"
i = UI.input("Which number would you like to run?")
i = i.to_i - 1
if i >= 0 && available[i]
selection = available[i].last.pretty_name
UI.important("Running lane `#{selection}`. Next time you can do this by directly typing `#{fastlane_command} #{selection}` π.")
platform = selection.split(' ')[0]
lane_name = selection.split(' ')[1]
unless lane_name # no specific platform, just a root lane
lane_name = platform
platform = nil
end
return platform, lane_name # yeah
else
UI.user_error!("Run `#{fastlane_command}` the next time you need to build, test or release your app π")
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/swift_lane_manager.rb | fastlane/lib/fastlane/swift_lane_manager.rb | require_relative 'lane_manager_base.rb'
require_relative 'swift_runner_upgrader.rb'
module Fastlane
class SwiftLaneManager < LaneManagerBase
# @param lane_name The name of the lane to execute
# @param parameters [Hash] The parameters passed from the command line to the lane
def self.cruise_lane(lane, parameters = nil, disable_runner_upgrades: false, swift_server_port: nil)
UI.user_error!("lane must be a string") unless lane.kind_of?(String) || lane.nil?
UI.user_error!("parameters must be a hash") unless parameters.kind_of?(Hash) || parameters.nil?
# Sets environment variable and lane context for lane name
ENV["FASTLANE_LANE_NAME"] = lane
Actions.lane_context[Actions::SharedValues::LANE_NAME] = lane
started = Time.now
e = nil
begin
display_upgraded_message = false
if disable_runner_upgrades
UI.verbose("disable_runner_upgrades is true, not attempting to update the FastlaneRunner project".yellow)
elsif Helper.ci?
UI.verbose("Running in CI, not attempting to update the FastlaneRunner project".yellow)
else
display_upgraded_message = self.ensure_runner_up_to_date_fastlane!
end
self.ensure_runner_built!
swift_server_port ||= 2000
socket_thread = self.start_socket_thread(port: swift_server_port)
sleep(0.250) while socket_thread[:ready].nil?
# wait on socket_thread to be in ready state, then start the runner thread
self.cruise_swift_lane_in_thread(lane, parameters, swift_server_port)
socket_thread.value
rescue Exception => ex # rubocop:disable Lint/RescueException
e = ex
end
# If we have a thread exception, drop that in the exception
# won't ever have a situation where e is non-nil, and socket_thread[:exception] is also non-nil
e ||= socket_thread[:exception]
unless e.nil?
print_lane_context
# We also catch Exception, since the implemented action might send a SystemExit signal
# (or similar). We still want to catch that, since we want properly finish running fastlane
# Tested with `xcake`, which throws a `Xcake::Informative` object
UI.error(e.to_s) if e.kind_of?(StandardError) # we don't want to print things like 'system exit'
end
skip_message = false
# if socket_thread is nil, we were probably debugging, or something else weird happened
exit_reason = :cancelled if socket_thread.nil?
# normal exit means we have a reason
exit_reason ||= socket_thread[:exit_reason]
if exit_reason == :cancelled && e.nil?
skip_message = true
end
duration = ((Time.now - started) / 60.0).round
finish_fastlane(nil, duration, e, skip_message: skip_message)
if display_upgraded_message
UI.message("We updated your FastlaneRunner project during this run to make it compatible with your current version of fastlane.".yellow)
UI.message("Please make sure to check the changes into source control.".yellow)
end
end
def self.display_lanes
self.ensure_runner_built!
return_value = Actions.sh(%(#{FastlaneCore::FastlaneFolder.swift_runner_path} lanes))
if FastlaneCore::Globals.verbose?
UI.message("runner output: ".yellow + return_value)
end
end
def self.cruise_swift_lane_in_thread(lane, parameters = nil, swift_server_port)
if parameters.nil?
parameters = {}
end
parameter_string = ""
parameters.each do |key, value|
parameter_string += " #{key} #{value}"
end
if FastlaneCore::Globals.verbose?
parameter_string += " logMode verbose"
end
parameter_string += " swiftServerPort #{swift_server_port}"
return Thread.new do
if FastlaneCore::Globals.verbose?
return_value = Actions.sh(%(#{FastlaneCore::FastlaneFolder.swift_runner_path} lane #{lane}#{parameter_string}))
UI.message("runner output: ".yellow + return_value)
else
Actions.sh(%(#{FastlaneCore::FastlaneFolder.swift_runner_path} lane #{lane}#{parameter_string} > /dev/null))
end
end
end
def self.swap_paths_in_target(file_refs_to_swap: nil, expected_path_to_replacement_path_tuples: nil)
made_project_updates = false
file_refs_to_swap.each do |file_ref|
expected_path_to_replacement_path_tuples.each do |preinstalled_config_relative_path, user_config_relative_path|
next unless file_ref.path == preinstalled_config_relative_path
file_ref.path = user_config_relative_path
made_project_updates = true
end
end
return made_project_updates
end
# Find all the config files we care about (Deliverfile, Gymfile, etc), and build tuples of what file we'll look for
# in the Xcode project, and what file paths we'll need to swap (since we have to inject the user's configs)
#
# Return a mapping of what file paths we're looking => new file pathes we'll need to inject
def self.collect_tool_paths_for_replacement(all_user_tool_file_paths: nil, look_for_new_configs: nil)
new_user_tool_file_paths = all_user_tool_file_paths.select do |user_config, preinstalled_config_relative_path, user_config_relative_path|
if look_for_new_configs
File.exist?(user_config)
else
!File.exist?(user_config)
end
end
# Now strip out the fastlane-relative path and leave us with xcodeproj relative paths
new_user_tool_file_paths = new_user_tool_file_paths.map do |user_config, preinstalled_config_relative_path, user_config_relative_path|
if look_for_new_configs
[preinstalled_config_relative_path, user_config_relative_path]
else
[user_config_relative_path, preinstalled_config_relative_path]
end
end
return new_user_tool_file_paths
end
# open and return the swift project
def self.runner_project
runner_project_path = FastlaneCore::FastlaneFolder.swift_runner_project_path
require 'xcodeproj'
project = Xcodeproj::Project.open(runner_project_path)
return project
end
# return the FastlaneRunner build target
def self.target_for_fastlane_runner_project(runner_project: nil)
fastlane_runner_array = runner_project.targets.select do |target|
target.name == "FastlaneRunner"
end
# get runner target
runner_target = fastlane_runner_array.first
return runner_target
end
def self.target_source_file_refs(target: nil)
return target.source_build_phase.files.to_a.map(&:file_ref)
end
def self.first_time_setup
setup_message = ["fastlane is now configured to use a swift-based Fastfile (Fastfile.swift) π¦
"]
setup_message << "To edit your new Fastfile.swift, type: `open #{FastlaneCore::FastlaneFolder.swift_runner_project_path}`"
# Go through and link up whatever we generated during `fastlane init swift` so the user can edit them easily
self.link_user_configs_to_project(updated_message: setup_message.join("\n"))
end
def self.link_user_configs_to_project(updated_message: nil)
tool_files_folder = FastlaneCore::FastlaneFolder.path
# All the tools that could have <tool name>file.swift their paths, and where we expect to find the user's tool files.
all_user_tool_file_paths = TOOL_CONFIG_FILES.map do |tool_name|
[
File.join(tool_files_folder, "#{tool_name}.swift"),
"../#{tool_name}.swift",
"../../#{tool_name}.swift"
]
end
# Tool files the user now provides
new_user_tool_file_paths = collect_tool_paths_for_replacement(all_user_tool_file_paths: all_user_tool_file_paths, look_for_new_configs: true)
# Tool files we provide AND the user doesn't provide
user_tool_files_possibly_removed = collect_tool_paths_for_replacement(all_user_tool_file_paths: all_user_tool_file_paths, look_for_new_configs: false)
fastlane_runner_project = self.runner_project
runner_target = target_for_fastlane_runner_project(runner_project: fastlane_runner_project)
target_file_refs = target_source_file_refs(target: runner_target)
# Swap in all new user supplied configs into the project
project_modified = swap_paths_in_target(
file_refs_to_swap: target_file_refs,
expected_path_to_replacement_path_tuples: new_user_tool_file_paths
)
# Swap out any configs the user has removed, inserting fastlane defaults
project_modified = swap_paths_in_target(
file_refs_to_swap: target_file_refs,
expected_path_to_replacement_path_tuples: user_tool_files_possibly_removed
) || project_modified
if project_modified
fastlane_runner_project.save
updated_message ||= "Updated #{FastlaneCore::FastlaneFolder.swift_runner_project_path}"
UI.success(updated_message)
else
UI.success("FastlaneSwiftRunner project is up-to-date")
end
return project_modified
end
def self.start_socket_thread(port: nil)
require 'fastlane/server/socket_server'
require 'fastlane/server/socket_server_action_command_executor'
return Thread.new do
command_executor = SocketServerActionCommandExecutor.new
server = Fastlane::SocketServer.new(command_executor: command_executor, port: port)
server.start
end
end
def self.ensure_runner_built!
UI.verbose("Checking for new user-provided tool configuration files")
# if self.link_user_configs_to_project returns true, that means we need to rebuild the runner
runner_needs_building = self.link_user_configs_to_project
if FastlaneCore::FastlaneFolder.swift_runner_built?
runner_last_modified_age = File.mtime(FastlaneCore::FastlaneFolder.swift_runner_path).to_i
fastfile_last_modified_age = File.mtime(FastlaneCore::FastlaneFolder.fastfile_path).to_i
if runner_last_modified_age < fastfile_last_modified_age
# It's older than the Fastfile, so build it again
UI.verbose("Found changes to user's Fastfile.swift, setting re-build runner flag")
runner_needs_building = true
end
else
# Runner isn't built yet, so build it
UI.verbose("No runner found, setting re-build runner flag")
runner_needs_building = true
end
if runner_needs_building
self.build_runner!
end
end
# do we have the latest FastlaneSwiftRunner code from the current version of fastlane?
def self.ensure_runner_up_to_date_fastlane!
upgraded = false
upgrader = SwiftRunnerUpgrader.new
upgrade_needed = upgrader.upgrade_if_needed!(dry_run: true)
if upgrade_needed
UI.message("It looks like your `FastlaneSwiftRunner` project is not up-to-date".green)
UI.message("If you don't update it, fastlane could fail".green)
UI.message("We can try to automatically update it for you, usually this works π π".green)
user_wants_upgrade = UI.confirm("Should we try to upgrade just your `FastlaneSwiftRunner` project?")
UI.important("Ok, if things break, you can try to run this lane again and you'll be prompted to upgrade another time") unless user_wants_upgrade
if user_wants_upgrade
upgraded = upgrader.upgrade_if_needed!
UI.success("Updated your FastlaneSwiftRunner project with the newest runner code") if upgraded
self.build_runner! if upgraded
end
end
return upgraded
end
def self.build_runner!
UI.verbose("Building FastlaneSwiftRunner")
require 'fastlane_core'
require 'gym'
require 'gym/generators/build_command_generator'
project_options = {
project: FastlaneCore::FastlaneFolder.swift_runner_project_path,
skip_archive: true
}
Gym.config = FastlaneCore::Configuration.create(Gym::Options.available_options, project_options)
build_command = Gym::BuildCommandGenerator.generate
FastlaneCore::CommandExecutor.execute(
command: build_command,
print_all: false,
print_command: !Gym.config[:silent]
)
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/auto_complete.rb | fastlane/lib/fastlane/auto_complete.rb | require 'fileutils'
module Fastlane
# Enable tab auto completion
class AutoComplete
# This method copies the tab auto completion scripts to the user's home folder,
# while optionally adding custom commands for which to enable auto complete
# @param [Array] options An array of all options (e.g. --custom fl)
def self.execute(args, options)
shell = ENV['SHELL']
if shell.end_with?("fish")
fish_completions_dir = "~/.config/fish/completions"
if UI.interactive?
confirm = UI.confirm("This will copy a fish script into #{fish_completions_dir} that provides the command tab completion. If the directory does not exist it will be created. Sound good?")
return unless confirm
end
fish_completions_dir = File.expand_path(fish_completions_dir)
FileUtils.mkdir_p(fish_completions_dir)
completion_script_path = File.join(Fastlane::ROOT, 'lib', 'assets', 'completions', 'completion.fish')
final_completion_script_path = File.join(fish_completions_dir, 'fastlane.fish')
FileUtils.cp(completion_script_path, final_completion_script_path)
UI.success("Copied! You can now use tab completion for lanes")
else
fastlane_conf_dir = "~/.fastlane"
if UI.interactive?
confirm = UI.confirm("This will copy a shell script into #{fastlane_conf_dir} that provides the command tab completion. Sound good?")
return unless confirm
end
# create the ~/.fastlane directory
fastlane_conf_dir = File.expand_path(fastlane_conf_dir)
FileUtils.mkdir_p(fastlane_conf_dir)
# then copy all of the completions files into it from the gem
completion_script_path = File.join(Fastlane::ROOT, 'lib', 'assets', 'completions')
FileUtils.cp_r(completion_script_path, fastlane_conf_dir)
custom_commands = options.custom.to_s.split(',')
Fastlane::SHELLS.each do |shell_name|
open("#{fastlane_conf_dir}/completions/completion.#{shell_name}", 'a') do |file|
default_line_prefix = Helper.bundler? ? "bundle exec " : ""
file.puts(self.get_auto_complete_line(shell_name, "#{default_line_prefix}fastlane"))
custom_commands.each do |command|
auto_complete_line = self.get_auto_complete_line(shell_name, command)
next if auto_complete_line.nil?
file.puts(auto_complete_line)
end
end
end
UI.success("Copied! To use auto complete for fastlane, add the following line to your favorite rc file (e.g. ~/.bashrc)")
UI.important(" . ~/.fastlane/completions/completion.sh")
UI.success("Don't forget to source that file in your current shell! π")
end
end
# Helper to get the auto complete register script line
def self.get_auto_complete_line(shell, command)
if shell == :bash
prefix = "complete -F"
elsif shell == :zsh
prefix = "compctl -K"
else
return nil
end
return "#{prefix} _fastlane_complete #{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/features.rb | fastlane/lib/fastlane/features.rb | # Use this file as the place to register Feature switches for the fastlane_core project
# FastlaneCore::Feature.register(env_var: 'YOUR_FEATURE_SWITCH_ENV_VAR',
# description: 'Describe what this feature switch controls')
FastlaneCore::Feature.register(env_var: 'FASTLANE_ENABLE_BETA_DELIVER_SYNC_SCREENSHOTS',
description: 'Use a newly implemented screenshots synchronization logic')
FastlaneCore::Feature.register(env_var: 'FASTLANE_WWDR_USE_HTTP1_AND_RETRIES',
description: 'Adds --http1.1 and --retry 3 --retry-all-errors to the curl command to download WWDR certificates')
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/swift_fastlane_function.rb | fastlane/lib/fastlane/swift_fastlane_function.rb | module Fastlane
class SwiftFunction
attr_accessor :function_name
attr_accessor :function_description
attr_accessor :function_details
attr_accessor :return_type
attr_accessor :return_value
attr_accessor :sample_return_value
attr_accessor :param_names
attr_accessor :param_descriptions
attr_accessor :param_default_values
attr_accessor :param_optionality_values
attr_accessor :param_type_overrides
attr_accessor :param_is_strings
attr_accessor :reserved_words
attr_accessor :default_values_to_ignore
def initialize(action_name: nil, action_description: nil, action_details: nil, keys: nil, key_descriptions: nil, key_default_values: nil, key_optionality_values: nil, key_type_overrides: nil, key_is_strings: nil, return_type: nil, return_value: nil, sample_return_value: nil)
@function_name = action_name
@function_description = action_description
@function_details = action_details
@param_names = keys
@param_descriptions = key_descriptions
@param_default_values = key_default_values
@param_optionality_values = key_optionality_values
@param_is_strings = key_is_strings
@return_type = return_type
@return_value = non_empty(string: return_value)
@sample_return_value = non_empty(string: sample_return_value)
@param_type_overrides = key_type_overrides
# rubocop:disable Layout/LineLength
# class instance?
@reserved_words = %w[actor associativity async await break case catch class continue convenience default deinit didSet do else enum extension fallthrough false final for func guard if in infix init inout internal lazy let mutating nil operator override precedence private public repeat required return self static struct subscript super switch throws true try var weak where while willSet].to_set
# rubocop:enable Layout/LineLength
end
def sanitize_reserved_word(word: nil)
unless @reserved_words.include?(word)
return word
end
return "`#{word}`"
end
def non_empty(string: nil)
if string.nil? || string.to_s.empty?
return nil
else
return string
end
end
def return_declaration
expected_type = swift_type_for_return_type
unless expected_type.to_s.length > 0
return ""
end
return " -> #{expected_type}"
end
def swift_type_for_return_type
unless @return_type
return ""
end
case @return_type
when :string
return "String"
when :array_of_strings
return "[String]"
when :hash_of_strings
return "[String : String]"
when :hash
return "[String : Any]"
when :bool
return "Bool"
when :int
return "Int"
else
return ""
end
end
def camel_case_lower(string: nil)
string.split('_').inject([]) { |buffer, e| buffer.push(buffer.empty? ? e : e.capitalize) }.join
end
def determine_type_from_override(type_override: nil, default_type: nil)
if type_override == Array
return "[String]"
elsif type_override == Hash
return "[String : Any]"
elsif type_override == Integer
return "Int"
elsif type_override == Boolean
return "Bool"
elsif type_override == Float
return "Float"
elsif type_override == String
return "String"
elsif type_override == :string_callback
# David Hart:
# It doesn't make sense to add escaping annotations to optional closures because they aren't function types:
# they are basically an enum (Optional) containing a function, the same way you would store a closure in any type:
# it's implicitly escaping because it's owned by another type.
return "((String) -> Void)?"
else
return default_type
end
end
def override_default_value_if_not_correct_type(param_name: nil, param_type: nil, default_value: nil)
return "[]" if param_type == "[String]" && default_value == ""
return "nil" if param_type == "((String) -> Void)?"
return default_value
end
def get_type(param: nil, default_value: nil, optional: nil, param_type_override: nil, is_string: true)
require 'bigdecimal'
unless param_type_override.nil?
type = determine_type_from_override(type_override: param_type_override)
end
# defaulting type to Any if is_string is false so users are allowed to input all allowed types
type ||= is_string ? "String" : "Any"
optional_specifier = ""
# if we are optional and don't have a default value, we'll need to use ?
optional_specifier = "?" if (optional && default_value.nil?) && type != "((String) -> Void)?"
# If we have a default value of true or false, we can infer it is a Bool
if default_value.class == FalseClass
type = "Bool"
elsif default_value.class == TrueClass
type = "Bool"
elsif default_value.kind_of?(Array)
type = "[String]"
elsif default_value.kind_of?(Hash)
type = "[String : Any]"
# Although we can have a default value of Integer type, if param_type_override overridden that value, respect it.
elsif default_value.kind_of?(Integer)
if type == "Double" || type == "Float"
begin
# If we're not able to instantiate
_ = BigDecimal(default_value)
rescue
# We set it as a Int
type = "Int"
end
else
type = "Int"
end
end
return "#{type}#{optional_specifier}"
end
# rubocop:disable Metrics/PerceivedComplexity
def parameters
unless @param_names
return ""
end
param_names_and_types = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides, param_is_strings).map do |param, default_value, optional, param_type_override, is_string|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override, is_string: is_string)
unless default_value.nil?
if type == "[String : Any]"
# we can't handle default values for Hashes, yet
# see method swift_default_implementations for similar behavior
default_value = "[:]"
elsif type != "Bool" && type != "[String]" && type != "Int" && type != "@escaping ((String) -> Void)" && type != "Float" && type != "Double"
default_value = "\"#{default_value}\""
elsif type == "Float" || type == "Double"
require 'bigdecimal'
default_value = BigDecimal(default_value).to_s
end
end
# if we don't have a default value, but the param is optional, set a default value in Swift to be nil
if optional && default_value.nil?
default_value = "nil"
end
# sometimes we get to the point where we have a default value but its type is wrong
# so we need to correct that because [String] = "" is not valid swift
default_value = override_default_value_if_not_correct_type(param_type: type, param_name: param, default_value: default_value)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
if default_value.nil?
"#{param}: #{type}"
else
if type == "((String) -> Void)?"
"#{param}: #{type} = nil"
elsif optional && type.end_with?('?') && !type.start_with?('Any') || type.start_with?('Bool')
"#{param}: OptionalConfigValue<#{type}> = .fastlaneDefault(#{default_value})"
else
"#{param}: #{type} = #{default_value}"
end
end
end
return param_names_and_types
end
# rubocop:enable Metrics/PerceivedComplexity
def swift_code
function_name = camel_case_lower(string: self.function_name)
function_return_declaration = self.return_declaration
discardable_result = function_return_declaration.length > 0 ? "@discardableResult " : ''
# Calculate the necessary indent to line up parameter names on new lines
# with the first parameter after the opening paren following the function name.
# i.e.: @discardableResult func someFunctionName(firstParameter: T
# secondParameter: T)
# This just creates a string with as many spaces are necessary given whether or not
# the function has a 'discardableResult' annotation, the 'func' keyword, function name
# and the opening paren.
function_keyword_definition = 'public func '
open_paren = '('
closed_paren = ')'
indent = ' ' * (discardable_result.length + function_name.length + function_keyword_definition.length + open_paren.length)
params = self.parameters.join(",\n#{indent}")
return "#{swift_documentation}#{discardable_result}#{function_keyword_definition}#{function_name}#{open_paren}#{params}#{closed_paren}#{function_return_declaration} {\n#{self.implementation}\n}\n"
end
def swift_documentation
has_parameters = @param_names && @param_names.length > 0
unless @function_description || @function_details || has_parameters
return ''
end
description = " #{fix_documentation_indentation(string: @function_description)}" if @function_description
details = " #{fix_documentation_indentation(string: @function_details)}" if @function_details
separator = ''
documentation_elements = [description, swift_parameter_documentation, swift_return_value_documentation, details].compact
# Adds newlines between each documentation element.
documentation = documentation_elements.flat_map { |element| [element, separator] }.tap(&:pop).join("\n")
return "/**\n#{documentation.gsub('/*', '/\\*')}\n*/\n"
end
def swift_parameter_documentation
unless @param_names && @param_names.length > 0
return nil
end
names_and_descriptions = @param_names.zip(@param_descriptions)
if @param_names.length == 1
detail_strings = names_and_descriptions.map { |name, description| " - parameter #{camel_case_lower(string: name)}: #{description}" }
return detail_strings.first
else
detail_strings = names_and_descriptions.map { |name, description| " - #{camel_case_lower(string: name)}: #{description}" }
return " - parameters:\n#{detail_strings.join("\n")}"
end
end
def swift_return_value_documentation
unless @return_value
return nil
end
sample = ". Example: #{@sample_return_value}" if @sample_return_value
return " - returns: #{return_value}#{sample}"
end
def fix_documentation_indentation(string: nil)
indent = ' '
string.gsub("\n", "\n#{indent}")
end
def build_argument_list
unless @param_names
return "[]" # return empty list for argument
end
argument_object_strings = @param_names.zip(param_type_overrides, param_default_values, param_optionality_values, param_is_strings).map do |name, type_override, default_value, is_optional, is_string|
type = get_type(param: name, default_value: default_value, optional: is_optional, param_type_override: type_override, is_string: is_string)
sanitized_name = camel_case_lower(string: name)
sanitized_name = sanitize_reserved_word(word: sanitized_name)
type_string = type_override == :string_callback ? ".stringClosure" : "nil"
if !(type_override == :string_callback || !(is_optional && default_value.nil? && !type.start_with?('Any') || type.start_with?('Bool')))
{ name: "#{sanitized_name.gsub('`', '')}Arg", arg: "let #{sanitized_name.gsub('`', '')}Arg = #{sanitized_name}.asRubyArgument(name: \"#{name}\", type: #{type_string})" }
else
{ name: "#{sanitized_name.gsub('`', '')}Arg", arg: "let #{sanitized_name.gsub('`', '')}Arg = RubyCommand.Argument(name: \"#{name}\", value: #{sanitized_name}, type: #{type_string})" }
end
end
return argument_object_strings
end
def return_statement
returned_object = "runner.executeCommand(command)"
case @return_type
when :array_of_strings
returned_object = "parseArray(fromString: #{returned_object})"
when :hash_of_strings
returned_object = "parseDictionary(fromString: #{returned_object})"
when :hash
returned_object = "parseDictionary(fromString: #{returned_object})"
when :bool
returned_object = "parseBool(fromString: #{returned_object})"
when :int
returned_object = "parseInt(fromString: #{returned_object})"
end
expected_type = swift_type_for_return_type
return_string = "_ = "
if expected_type.length > 0
return_string = "return "
end
return "#{return_string}#{returned_object}"
end
def implementation
args = build_argument_list
implm = "#{args.group_by { |h| h[:arg] }.keys.join("\n")}\n"
if args.empty?
implm += "let args: [RubyCommand.Argument] = []\n"
else
implm += "let array: [RubyCommand.Argument?] = [#{args.group_by { |h| h[:name] }.keys.join(",\n")}]\n"
implm += "let args: [RubyCommand.Argument] = array\n"
implm += ".filter { $0?.value != nil }\n"
implm += ".compactMap { $0 }\n"
end
implm += "let command = RubyCommand(commandID: \"\", methodName: \"#{@function_name}\", className: nil, args: args)\n"
return implm + " #{return_statement}"
end
end
class ToolSwiftFunction < SwiftFunction
def protocol_name
function_name = camel_case_lower(string: self.function_name)
return function_name.capitalize + "fileProtocol"
end
def class_name
function_name = camel_case_lower(string: self.function_name)
return function_name.capitalize + "file"
end
def swift_vars
unless @param_names
return []
end
swift_vars = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides, param_descriptions).map do |param, default_value, optional, param_type_override, param_description|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
static_var_for_parameter_name = param
if param_description
documentation = " /// #{param_description}\n"
end
"\n#{documentation}"\
" var #{static_var_for_parameter_name}: #{type} { get }"
end
return swift_vars
end
def swift_default_implementations
unless @param_names
return []
end
swift_implementations = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides).map do |param, default_value, optional, param_type_override|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
var_for_parameter_name = param
unless default_value.nil?
if type == "Bool" || type == "[String]" || type == "Int" || default_value.kind_of?(Array)
default_value = default_value.to_s
elsif default_value.kind_of?(Hash)
# we can't handle default values for Hashes, yet
# see method parameters for similar behavior
default_value = "[:]"
else
default_value = "\"#{default_value}\""
end
end
# if we don't have a default value, but the param is options, just set a default value to nil
if optional && default_value.nil?
default_value = "nil"
end
# if we don't have a default value still, we need to assign them based on type
if type == "String"
default_value ||= "\"\""
end
if type == "Bool"
default_value ||= "false"
end
if type == "[String]"
default_value ||= "[]"
end
if type == "[String : Any]"
default_value ||= "[:]"
end
" var #{var_for_parameter_name}: #{type} { return #{default_value} }"
end
return swift_implementations
end
def parameters
unless @param_names
return ""
end
param_names_and_types = @param_names.zip(param_default_values, param_optionality_values, param_type_overrides).map do |param, default_value, optional, param_type_override, is_string|
type = get_type(param: param, default_value: default_value, optional: optional, param_type_override: param_type_override, is_string: is_string)
param = camel_case_lower(string: param)
param = sanitize_reserved_word(word: param)
static_var_for_parameter_name = param
if type == "((String) -> Void)?"
"#{param}: #{type} = nil"
elsif (optional && type.end_with?('?') && !type.start_with?('Any')) || type.start_with?('Bool')
"#{param}: OptionalConfigValue<#{type}> = .fastlaneDefault(#{self.class_name.downcase}.#{static_var_for_parameter_name})"
else
"#{param}: #{type} = #{self.class_name.downcase}.#{static_var_for_parameter_name}"
end
end
return param_names_and_types
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/action.rb | fastlane/lib/fastlane/action.rb | require 'fastlane/actions/actions_helper'
require 'forwardable'
module Fastlane
class Action
AVAILABLE_CATEGORIES = [
:testing,
:building,
:screenshots,
:project,
:code_signing,
:documentation,
:beta,
:push,
:production,
:source_control,
:notifications,
:app_store_connect,
:misc,
:deprecated # This should be the last item
]
RETURN_TYPES = [
:string,
:array_of_strings,
:hash_of_strings,
:hash,
:bool,
:int
]
class << self
attr_accessor :runner
extend(Forwardable)
# to allow a simple `sh` in the custom actions
def_delegator(Actions, :sh_control_output, :sh)
end
def self.run(params)
end
# Implement in subclasses
def self.description
"No description provided".red
end
def self.details
nil # this is your chance to provide a more detailed description of this action
end
def self.available_options
# [
# FastlaneCore::ConfigItem.new(key: :ipa_path,
# env_name: "CRASHLYTICS_IPA_PATH",
# description: "Value Description")
# ]
nil
end
def self.output
# Return the keys you provide on the shared area
# [
# ['IPA_OUTPUT_PATH', 'The path to the newly generated ipa file']
# ]
nil
end
def self.return_type
# Describes what type of data is expected to be returned, see RETURN_TYPES
nil
end
def self.return_value
# Describes what this method returns
nil
end
def self.sample_return_value
# Very optional
# You can return a sample return value, that might be returned by the actual action
# This is currently only used when generating the documentation and running its tests
nil
end
def self.author
nil
end
def self.authors
nil
end
def self.is_supported?(platform)
# you can do things like
# true
#
# platform == :ios
#
# [:ios, :mac].include?(platform)
#
UI.crash!("Implementing `is_supported?` for all actions is mandatory. Please update #{self}")
end
# Returns an array of string of sample usage of this action
def self.example_code
nil
end
# Is printed out in the Steps: output in the terminal
# Return nil if you don't want any logging in the terminal/JUnit Report
def self.step_text(params)
self.action_name
end
# Documentation category, available values defined in AVAILABLE_CATEGORIES
def self.category
:undefined
end
# instead of "AddGitAction", this will return "add_git" to print it to the user
def self.action_name
self.name.split('::').last.gsub(/Action$/, '').fastlane_underscore
end
def self.lane_context
Actions.lane_context
end
# Allows the user to call an action from an action
def self.method_missing(method_sym, *arguments, &_block)
UI.error("Unknown method '#{method_sym}'")
UI.user_error!("To call another action from an action use `other_action.#{method_sym}` instead")
end
# When shelling out from the action, should we use `bundle exec`?
def self.shell_out_should_use_bundle_exec?
return File.exist?('Gemfile') && !Helper.contained_fastlane?
end
# Return a new instance of the OtherAction action
# We need to do this, since it has to have access to
# the runner object
def self.other_action
return OtherAction.new(self.runner)
end
# Describes how the user should handle deprecated an action if its deprecated
# Returns a string (or nil)
def self.deprecated_notes
nil
end
end
end
class String
def markdown_preserve_newlines
self.gsub(/(\n|$)/, '|\1') # prepend new lines with "|" so the erb template knows *not* to replace them with "<br>"s
end
def markdown_sample(is_first = false)
self.markdown_clean_heredoc!
self.markdown_details(is_first)
end
def markdown_list(is_first = false)
self.markdown_clean_heredoc!
self.gsub!(/^/, "- ") # add list dashes
self.prepend(">") unless is_first # the empty line that will be added breaks the quote
self.markdown_details(is_first)
end
def markdown_details(is_first)
self.prepend("\n") unless is_first
self << "\n>" # continue the quote
self.markdown_preserve_newlines
end
def markdown_clean_heredoc!
self.chomp! # remove the last new line added by the heredoc
self.dedent! # remove the leading whitespace (similar to the squiggly heredoc `<<~`)
end
def dedent!
first_line_indent = self.match(/^\s*/)[0]
self.gsub!(/^#{first_line_indent}/, "")
end
def remove_markdown
string = self.gsub(/^>/, "") # remove Markdown quotes
string = string.gsub(/\[http[^\]]+\]\(([^)]+)\)/, '\1 π') # remove Markdown links
string = string.gsub(/\[([^\]]+)\]\(([^\)]+)\)/, '"\1" (\2 π)') # remove Markdown links with custom text
string = string.gsub("|", "") # remove new line preserve markers
return string
end
end
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/other_action.rb | fastlane/lib/fastlane/other_action.rb | module Fastlane
# This class is used to call other actions from within actions
# We use a separate class so that we can easily identify when
# we have dependencies between actions
class OtherAction
attr_accessor :runner
def initialize(runner)
self.runner = runner
end
# Allows the user to call an action from an action
def method_missing(method_sym, *arguments, &_block)
# We have to go inside the fastlane directory
# since in the fastlane runner.rb we do the following
# custom_dir = ".."
# Dir.chdir(custom_dir) do
# this goes one folder up, since we're inside the "fastlane"
# folder at that point
# Since we call an action from an action we need to go inside
# the fastlane folder too
self.runner.trigger_action_by_name(method_sym,
FastlaneCore::FastlaneFolder.path,
true,
*arguments)
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/command_line_handler.rb | fastlane/lib/fastlane/command_line_handler.rb | module Fastlane
class CommandLineHandler
# This method handles command line inputs and properly transforms them to a usable format
# @param [Array] args An array of all arguments (not options)
# @param [Array] args A hash of all options (e.g. --env NAME)
def self.handle(args, options)
lane_parameters = {} # the parameters we'll pass to the lane
platform_lane_info = [] # the part that's responsible for the lane/platform definition
args.each do |current|
if current.include?(":") # that's a key/value which we want to pass to the lane
key, value = current.split(":", 2)
UI.user_error!("Please pass values like this: key:value") unless key.length > 0
value = convert_value(value)
UI.verbose("Using #{key}: #{value}")
lane_parameters[key.to_sym] = value
else
platform_lane_info << current
end
end
platform = nil
lane = platform_lane_info[1]
if lane
platform = platform_lane_info[0]
else
lane = platform_lane_info[0]
end
if FastlaneCore::FastlaneFolder.swift?
disable_runner_upgrades = options.disable_runner_upgrades || false
swift_server_port = options.swift_server_port
Fastlane::SwiftLaneManager.cruise_lane(lane, lane_parameters, disable_runner_upgrades: disable_runner_upgrades, swift_server_port: swift_server_port)
else
Fastlane::LaneManager.cruise_lane(platform, lane, lane_parameters)
end
end
# Helper to convert into the right data type
def self.convert_value(value)
return true if value == 'true' || value == 'yes'
return false if value == 'false' || value == 'no'
# Default case:
return value
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/fastlane_require.rb | fastlane/lib/fastlane/fastlane_require.rb | module Fastlane
class FastlaneRequire
class << self
def install_gem_if_needed(gem_name: nil, require_gem: true)
gem_require_name = format_gem_require_name(gem_name)
# check if it's installed
if gem_installed?(gem_name)
UI.success("gem '#{gem_name}' is already installed") if FastlaneCore::Globals.verbose?
require gem_require_name if require_gem
return true
end
if Helper.bundler?
# User uses bundler, we don't want to install gems on the fly here
# Instead tell the user how to add it to their Gemfile
UI.important("Missing gem '#{gem_name}', please add the following to your local Gemfile:")
UI.important("")
UI.command_output("gem \"#{gem_name}\"")
UI.important("")
UI.user_error!("Add 'gem \"#{gem_name}\"' to your Gemfile and restart fastlane") unless Helper.test?
end
require "rubygems/command_manager"
installer = Gem::CommandManager.instance[:install]
UI.important("Installing Ruby gem '#{gem_name}'...")
spec_name = self.find_gem_name(gem_name)
UI.important("Found gem \"#{spec_name}\" instead of the required name \"#{gem_name}\"") if spec_name != gem_name
return if Helper.test?
# We install the gem like this because we also want to gem to be available to be required
# at this point. If we were to shell out, this wouldn't be the case
installer.install_gem(spec_name, Gem::Requirement.default)
UI.success("Successfully installed '#{gem_name}'")
require gem_require_name if require_gem
end
def gem_installed?(name, req = Gem::Requirement.default)
installed = Gem::Specification.any? { |s| s.name == name and req =~ s.version }
return true if installed
# In special cases a gem is already preinstalled, e.g. YAML.
# To find out we try to load a gem with that name in a child process
# (so we don't actually load anything we don't want to load)
# See https://github.com/fastlane/fastlane/issues/6951
require_tester = <<-RB.gsub(/^ */, '')
begin
require ARGV.first
rescue LoadError
exit(1)
end
RB
system(RbConfig.ruby, "-e", require_tester.lines.map(&:chomp).join("; "), name)
return $?.success?
end
def find_gem_name(user_supplied_name)
fetcher = Gem::SpecFetcher.fetcher
# RubyGems 3.2.0 changed behavior of suggest_gems_from_name to no longer return user supplied name (only similar suggestions)
# First search for exact gem with detect then use suggest_gems_from_name
if (detected_gem = fetcher.detect(:latest) { |nt| nt.name == user_supplied_name }.first)
return detected_gem[0].name
end
gems = fetcher.suggest_gems_from_name(user_supplied_name)
return gems.first
end
def format_gem_require_name(gem_name)
# from "fastlane-plugin-xcversion" to "fastlane/plugin/xcversion"
gem_name = gem_name.tr("-", "/") if gem_name.start_with?("fastlane-plugin-")
return gem_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/notification/slack.rb | fastlane/lib/fastlane/notification/slack.rb | module Fastlane
module Notification
class Slack
def initialize(webhook_url)
@webhook_url = webhook_url
@client = Faraday.new do |conn|
conn.use(Faraday::Response::RaiseError)
end
end
# Overriding channel, icon_url, icon_emoji and username is only supported in legacy incoming webhook.
# Also note that the use of attachments has been discouraged by Slack, in favor of Block Kit.
# https://api.slack.com/legacy/custom-integrations/messaging/webhooks
def post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:, icon_emoji:)
@client.post(@webhook_url) do |request|
request.headers['Content-Type'] = 'application/json'
request.body = {
channel: channel,
username: username,
icon_url: icon_url,
icon_emoji: icon_emoji,
attachments: attachments,
link_names: link_names
}.to_json
end
end
# This class was inspired by `LinkFormatter` in `slack-notifier` gem
# https://github.com/stevenosloan/slack-notifier/blob/4bf6582663dc9e5070afe3fdc42d67c14a513354/lib/slack-notifier/util/link_formatter.rb
class LinkConverter
HTML_PATTERN = %r{<a.*?href=['"](?<link>#{URI.regexp})['"].*?>(?<label>.+?)<\/a>}
MARKDOWN_PATTERN = /\[(?<label>[^\[\]]*?)\]\((?<link>#{URI.regexp}|mailto:#{URI::MailTo::EMAIL_REGEXP})\)/
def self.convert(string)
convert_markdown_to_slack_link(convert_html_to_slack_link(string.scrub))
end
def self.convert_html_to_slack_link(string)
string.gsub(HTML_PATTERN) do |match|
slack_link(Regexp.last_match[:link], Regexp.last_match[:label])
end
end
def self.convert_markdown_to_slack_link(string)
string.gsub(MARKDOWN_PATTERN) do |match|
slack_link(Regexp.last_match[:link], Regexp.last_match[:label])
end
end
def self.slack_link(href, text)
return "<#{href}>" if text.nil? || text.empty?
"<#{href}|#{text}>"
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/actions/update_keychain_access_groups.rb | fastlane/lib/fastlane/actions/update_keychain_access_groups.rb | module Fastlane
module Actions
module SharedValues
KEYCHAIN_ACCESS_GROUPS = :KEYCHAIN_ACCESS_GROUPS
end
class UpdateKeychainAccessGroupsAction < Action
require 'plist'
def self.run(params)
UI.message("Entitlements File: #{params[:entitlements_file]}")
UI.message("New keychain access groups: #{params[:identifiers]}")
entitlements_file = params[:entitlements_file]
UI.user_error!("Could not find entitlements file at path '#{entitlements_file}'") unless File.exist?(entitlements_file)
# parse entitlements
result = Plist.parse_xml(entitlements_file)
UI.user_error!("Entitlements file at '#{entitlements_file}' cannot be parsed.") unless result
# keychain access groups key
keychain_access_groups_key = 'keychain-access-groups'
# get keychain access groups
keychain_access_groups_field = result[keychain_access_groups_key]
UI.user_error!("No existing keychain access groups field specified. Please specify an keychain access groups in the entitlements file.") unless keychain_access_groups_field
# set new keychain access groups
UI.message("Old keychain access groups: #{keychain_access_groups_field}")
result[keychain_access_groups_key] = params[:identifiers]
# save entitlements file
result.save_plist(entitlements_file)
UI.message("New keychain access groups: #{result[keychain_access_groups_key]}")
Actions.lane_context[SharedValues::KEYCHAIN_ACCESS_GROUPS] = result[keychain_access_groups_key]
end
def self.description
"This action changes the keychain access groups in the entitlements file"
end
def self.details
"Updates the Keychain Group Access Groups in the given Entitlements file, so you can have keychain access groups for the app store build and keychain access groups for an enterprise build."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :entitlements_file,
env_name: "FL_UPDATE_KEYCHAIN_ACCESS_GROUPS_ENTITLEMENTS_FILE_PATH", # The name of the environment variable
description: "The path to the entitlement file which contains the keychain access groups", # a short description of this parameter
verify_block: proc do |value|
UI.user_error!("Please pass a path to an entitlements file. ") unless value.include?(".entitlements")
UI.user_error!("Could not find entitlements file") if !File.exist?(value) && !Helper.test?
end),
FastlaneCore::ConfigItem.new(key: :identifiers,
env_name: "FL_UPDATE_KEYCHAIN_ACCESS_GROUPS_IDENTIFIERS",
description: "An Array of unique identifiers for the keychain access groups. Eg. ['your.keychain.access.groups.identifiers']",
type: Array)
]
end
def self.output
[
['KEYCHAIN_ACCESS_GROUPS', 'The new Keychain Access Groups']
]
end
def self.authors
["yutae"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'update_keychain_access_groups(
entitlements_file: "/path/to/entitlements_file.entitlements",
identifiers: ["your.keychain.access.groups.identifiers"]
)'
]
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/build_app.rb | fastlane/lib/fastlane/actions/build_app.rb | module Fastlane
module Actions
module SharedValues
IPA_OUTPUT_PATH ||= :IPA_OUTPUT_PATH
PKG_OUTPUT_PATH ||= :PKG_OUTPUT_PATH
DSYM_OUTPUT_PATH ||= :DSYM_OUTPUT_PATH
XCODEBUILD_ARCHIVE ||= :XCODEBUILD_ARCHIVE # originally defined in XcodebuildAction
end
class BuildAppAction < Action
# rubocop:disable Metrics/PerceivedComplexity
def self.run(values)
require 'gym'
unless Actions.lane_context[SharedValues::SIGH_PROFILE_TYPE].to_s == "development"
values[:export_method] ||= Actions.lane_context[SharedValues::SIGH_PROFILE_TYPE]
end
if Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING]
# Since Xcode 9 you need to explicitly provide the provisioning profile per app target
# If the user is smart and uses match and gym together with fastlane, we can do all
# the heavy lifting for them
values[:export_options] ||= {}
# It's not always a hash, because the user might have passed a string path to a ready plist file
# If that's the case, we won't set the provisioning profiles
# see https://github.com/fastlane/fastlane/issues/9490
if values[:export_options].kind_of?(Hash)
match_mapping = (Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING] || {}).dup
existing_mapping = (values[:export_options][:provisioningProfiles] || {}).dup
# Be smart about how we merge those mappings in case there are conflicts
mapping_object = Gym::CodeSigningMapping.new
hash_to_use = mapping_object.merge_profile_mapping(primary_mapping: existing_mapping,
secondary_mapping: match_mapping,
export_method: values[:export_method])
values[:export_options][:provisioningProfiles] = hash_to_use
else
self.show_xcode_9_warning
end
elsif Actions.lane_context[SharedValues::SIGH_PROFILE_PATHS]
# Since Xcode 9 you need to explicitly provide the provisioning profile per app target
# If the user used sigh we can match the profiles from sigh
values[:export_options] ||= {}
if values[:export_options].kind_of?(Hash)
# It's not always a hash, because the user might have passed a string path to a ready plist file
# If that's the case, we won't set the provisioning profiles
# see https://github.com/fastlane/fastlane/issues/9684
values[:export_options][:provisioningProfiles] ||= {}
Actions.lane_context[SharedValues::SIGH_PROFILE_PATHS].each do |profile_path|
begin
profile = FastlaneCore::ProvisioningProfile.parse(profile_path)
app_id_prefix = profile["ApplicationIdentifierPrefix"].first
entitlements = profile["Entitlements"]
bundle_id = (entitlements["application-identifier"] || entitlements["com.apple.application-identifier"]).gsub("#{app_id_prefix}.", "")
values[:export_options][:provisioningProfiles][bundle_id] = profile["Name"]
rescue => ex
UI.error("Couldn't load profile at path: #{profile_path}")
UI.error(ex)
UI.verbose(ex.backtrace.join("\n"))
end
end
else
self.show_xcode_9_warning
end
end
gym_output_path = Gym::Manager.new.work(values)
if gym_output_path.nil?
UI.important("No output path received from gym")
return nil
end
absolute_output_path = File.expand_path(gym_output_path)
# Binary path
if File.extname(absolute_output_path) == ".ipa"
absolute_dsym_path = absolute_output_path.gsub(/.ipa$/, ".app.dSYM.zip")
Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] = absolute_output_path
ENV[SharedValues::IPA_OUTPUT_PATH.to_s] = absolute_output_path # for deliver
elsif File.extname(absolute_output_path) == ".pkg"
absolute_dsym_path = absolute_output_path.gsub(/.pkg$/, ".dSYM.zip")
Actions.lane_context[SharedValues::PKG_OUTPUT_PATH] = absolute_output_path
ENV[SharedValues::PKG_OUTPUT_PATH.to_s] = absolute_output_path # for deliver
end
# xcarchive path
Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] = Gym::BuildCommandGenerator.archive_path
# dSYM path
if absolute_dsym_path && File.exist?(absolute_dsym_path)
Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] = absolute_dsym_path
ENV[SharedValues::DSYM_OUTPUT_PATH.to_s] = absolute_dsym_path
end
return absolute_output_path
end
# rubocop:enable Metrics/PerceivedComplexity
def self.description
"Easily build and sign your app (via _gym_)"
end
def self.details
"More information: https://fastlane.tools/gym"
end
def self.output
[
['IPA_OUTPUT_PATH', 'The path to the newly generated ipa file'],
['PKG_OUTPUT_PATH', 'The path to the newly generated pkg file'],
['DSYM_OUTPUT_PATH', 'The path to the dSYM files'],
['XCODEBUILD_ARCHIVE', 'The path to the xcodebuild archive']
]
end
def self.return_value
"The absolute path to the generated ipa file"
end
def self.return_type
:string
end
def self.author
"KrauseFx"
end
def self.available_options
require 'gym'
Gym::Options.available_options
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'build_app(scheme: "MyApp", workspace: "MyApp.xcworkspace")',
'build_app(
workspace: "MyApp.xcworkspace",
configuration: "Debug",
scheme: "MyApp",
silent: true,
clean: true,
output_directory: "path/to/dir", # Destination directory. Defaults to current directory.
output_name: "my-app.ipa", # specify the name of the .ipa file to generate (including file extension)
sdk: "iOS 11.1" # use SDK as the name or path of the base SDK when building the project.
)',
'gym # alias for "build_app"',
'build_ios_app # alias for "build_app (only iOS options)"',
'build_mac_app # alias for "build_app (only macOS options)"'
]
end
def self.category
:building
end
def self.show_xcode_9_warning
return unless Helper.xcode_at_least?("9.0")
UI.message("You passed a path to a custom plist file for exporting the binary.")
UI.message("Make sure to include information about what provisioning profiles to use with Xcode 9")
UI.message("More information: https://docs.fastlane.tools/codesigning/xcode-project/#xcode-9-and-up")
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/version_get_podspec.rb | fastlane/lib/fastlane/actions/version_get_podspec.rb | module Fastlane
module Actions
module SharedValues
PODSPEC_VERSION_NUMBER ||= :PODSPEC_VERSION_NUMBER # originally defined in VersionBumpPodspecAction
end
class VersionGetPodspecAction < Action
def self.run(params)
podspec_path = params[:path]
UI.user_error!("Could not find podspec file at path '#{podspec_path}'") unless File.exist?(podspec_path)
version_podspec_file = Helper::PodspecHelper.new(podspec_path, params[:require_variable_prefix])
Actions.lane_context[SharedValues::PODSPEC_VERSION_NUMBER] = version_podspec_file.version_value
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Receive the version number from a podspec file"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_VERSION_PODSPEC_PATH",
description: "You must specify the path to the podspec file",
code_gen_sensitive: true,
default_value: Dir["*.podspec"].last,
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Please pass a path to the `version_get_podspec` action") if value.length == 0
end),
FastlaneCore::ConfigItem.new(key: :require_variable_prefix,
env_name: "FL_VERSION_BUMP_PODSPEC_VERSION_REQUIRE_VARIABLE_PREFIX",
description: "true by default, this is used for non CocoaPods version bumps only",
type: Boolean,
default_value: true)
]
end
def self.output
[
['PODSPEC_VERSION_NUMBER', 'The podspec version number']
]
end
def self.authors
["Liquidsoul", "KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'version = version_get_podspec(path: "TSMessages.podspec")'
]
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/push_git_tags.rb | fastlane/lib/fastlane/actions/push_git_tags.rb | module Fastlane
module Actions
class PushGitTagsAction < Action
def self.run(params)
command = [
'git',
'push',
params[:remote]
]
if params[:tag]
command << "refs/tags/#{params[:tag].shellescape}"
else
command << '--tags'
end
# optionally add the force component
command << '--force' if params[:force]
result = Actions.sh(command.join(' '))
UI.success('Tags pushed to remote')
result
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Push local tags to the remote - this will only push tags"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :force,
env_name: "FL_PUSH_GIT_FORCE",
description: "Force push to remote",
type: Boolean,
default_value: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :remote,
env_name: "FL_GIT_PUSH_REMOTE",
description: "The remote to push tags to",
default_value: "origin",
optional: true),
FastlaneCore::ConfigItem.new(key: :tag,
env_name: "FL_GIT_PUSH_TAG",
description: "The tag to push to remote",
optional: true)
]
end
def self.author
['vittoriom']
end
def self.details
"If you only want to push the tags and nothing else, you can use the `push_git_tags` action"
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'push_git_tags'
]
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/capture_ios_screenshots.rb | fastlane/lib/fastlane/actions/capture_ios_screenshots.rb | module Fastlane
module Actions
module SharedValues
SNAPSHOT_SCREENSHOTS_PATH = :SNAPSHOT_SCREENSHOTS_PATH
end
class CaptureIosScreenshotsAction < Action
def self.run(params)
return nil unless Helper.mac?
require 'snapshot'
Snapshot.config = params
Snapshot::DependencyChecker.check_simulators
Snapshot::Runner.new.work
Actions.lane_context[SharedValues::SNAPSHOT_SCREENSHOTS_PATH] = File.expand_path(params[:output_directory]) # absolute URL
true
end
def self.description
"Generate new localized screenshots on multiple devices (via _snapshot_)"
end
def self.available_options
return [] unless Helper.mac?
require 'snapshot'
Snapshot::Options.available_options
end
def self.output
[
['SNAPSHOT_SCREENSHOTS_PATH', 'The path to the screenshots']
]
end
def self.author
"KrauseFx"
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'capture_ios_screenshots',
'snapshot # alias for "capture_ios_screenshots"',
'capture_ios_screenshots(
skip_open_summary: true,
clean: true
)'
]
end
def self.category
:screenshots
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_submodule_update.rb | fastlane/lib/fastlane/actions/git_submodule_update.rb | module Fastlane
module Actions
class GitSubmoduleUpdateAction < Action
def self.run(params)
commands = ["git submodule update"]
commands += ["--init"] if params[:init]
commands += ["--recursive"] if params[:recursive]
Actions.sh(commands.join(' '))
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Executes a git submodule update command"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :recursive,
description: "Should the submodules be updated recursively?",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :init,
description: "Should the submodules be initiated before update?",
type: Boolean,
default_value: false)
]
end
def self.output
end
def self.return_value
end
def self.authors
["braunico"]
end
def self.is_supported?(platform)
return true
end
def self.example_code
[
'git_submodule_update',
'git_submodule_update(recursive: true)',
'git_submodule_update(init: true)',
'git_submodule_update(recursive: true, init: 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/run_tests.rb | fastlane/lib/fastlane/actions/run_tests.rb | module Fastlane
module Actions
module SharedValues
SCAN_DERIVED_DATA_PATH = :SCAN_DERIVED_DATA_PATH
SCAN_GENERATED_PLIST_FILE = :SCAN_GENERATED_PLIST_FILE
SCAN_GENERATED_PLIST_FILES = :SCAN_GENERATED_PLIST_FILES
SCAN_GENERATED_XCRESULT_PATH = :SCAN_GENERATED_XCRESULT_PATH
SCAN_ZIP_BUILD_PRODUCTS_PATH = :SCAN_ZIP_BUILD_PRODUCTS_PATH
end
class RunTestsAction < Action
def self.run(values)
require 'scan'
manager = Scan::Manager.new
begin
results = manager.work(values)
zip_build_products_path = Scan.cache[:zip_build_products_path]
Actions.lane_context[SharedValues::SCAN_ZIP_BUILD_PRODUCTS_PATH] = zip_build_products_path if zip_build_products_path
return results
rescue FastlaneCore::Interface::FastlaneBuildFailure => ex
# Specifically catching FastlaneBuildFailure to prevent build/compile errors from being
# silenced when :fail_build is set to false
# :fail_build should only suppress testing failures
raise ex
rescue => ex
if values[:fail_build]
raise ex
end
ensure
if Scan.cache && (result_bundle_path = Scan.cache[:result_bundle_path])
Actions.lane_context[SharedValues::SCAN_GENERATED_XCRESULT_PATH] = File.absolute_path(result_bundle_path)
else
Actions.lane_context[SharedValues::SCAN_GENERATED_XCRESULT_PATH] = nil
end
unless values[:derived_data_path].to_s.empty?
plist_files_before = manager.plist_files_before || []
Actions.lane_context[SharedValues::SCAN_DERIVED_DATA_PATH] = values[:derived_data_path]
plist_files_after = manager.test_summary_filenames(values[:derived_data_path])
all_test_summaries = (plist_files_after - plist_files_before)
Actions.lane_context[SharedValues::SCAN_GENERATED_PLIST_FILES] = all_test_summaries
Actions.lane_context[SharedValues::SCAN_GENERATED_PLIST_FILE] = all_test_summaries.last
end
end
end
def self.description
"Easily run tests of your iOS app (via _scan_)"
end
def self.details
"More information: https://docs.fastlane.tools/actions/scan/"
end
def self.return_value
'Outputs hash of results with the following keys: :number_of_tests, :number_of_failures, :number_of_retries, :number_of_tests_excluding_retries, :number_of_failures_excluding_retries'
end
def self.return_type
:hash
end
def self.author
"KrauseFx"
end
def self.available_options
require 'scan'
FastlaneCore::CommanderGenerator.new.generate(Scan::Options.available_options)
end
def self.output
[
['SCAN_DERIVED_DATA_PATH', 'The path to the derived data'],
['SCAN_GENERATED_PLIST_FILE', 'The generated plist file'],
['SCAN_GENERATED_PLIST_FILES', 'The generated plist files'],
['SCAN_GENERATED_XCRESULT_PATH', 'The path to the generated .xcresult'],
['SCAN_ZIP_BUILD_PRODUCTS_PATH', 'The path to the zipped build products']
]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
private_class_method
def self.example_code
[
'run_tests',
'scan # alias for "run_tests"',
'run_tests(
workspace: "App.xcworkspace",
scheme: "MyTests",
clean: false
)',
'# Build For Testing
run_tests(
derived_data_path: "my_folder",
build_for_testing: true
)',
'# run tests using derived data from prev. build
run_tests(
derived_data_path: "my_folder",
test_without_building: true
)',
'# or run it from an existing xctestrun package
run_tests(
xctestrun: "/path/to/mytests.xctestrun"
)'
]
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/import_from_git.rb | fastlane/lib/fastlane/actions/import_from_git.rb | module Fastlane
module Actions
class ImportFromGitAction < Action
def self.run(params)
# this is implemented in the fast_file.rb
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Import another Fastfile from a remote git repository to use its lanes"
end
def self.details
"This is useful if you have shared lanes across multiple apps and you want to store the Fastfile in a remote git repository."
end
def self.available_options
[
# Because the `run` method is actually implemented in `fast_file.rb`,
# and because magic, some of the parameters on `ConfigItem`s (e.g.
# `conflicting_options`, `verify_block`) are completely ignored.
FastlaneCore::ConfigItem.new(key: :url,
description: "The URL of the repository to import the Fastfile from",
optional: true),
FastlaneCore::ConfigItem.new(key: :branch,
description: "The branch or tag to check-out on the repository",
default_value: 'HEAD',
optional: true),
FastlaneCore::ConfigItem.new(key: :dependencies,
description: "The array of additional Fastfiles in the repository",
default_value: [],
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :path,
description: "The path of the Fastfile in the repository",
default_value: 'fastlane/Fastfile',
optional: true),
FastlaneCore::ConfigItem.new(key: :version,
description: "The version to checkout on the repository. Optimistic match operator or multiple conditions can be used to select the latest version within constraints",
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :cache_path,
description: "The path to a directory where the repository should be cloned into. Defaults to `nil`, which causes the repository to be cloned on every call, to a temporary directory",
optional: true),
FastlaneCore::ConfigItem.new(key: :git_extra_headers,
description: "An optional list of custom HTTP headers to access the git repo (`Authorization: Basic <YOUR BASE64 KEY>`, `Cache-Control: no-cache`, etc.)",
default_value: [],
type: Array,
optional: true)
]
end
def self.authors
["fabiomassimo", "KrauseFx", "Liquidsoul"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'import_from_git(
url: "git@github.com:fastlane/fastlane.git", # The URL of the repository to import the Fastfile from.
branch: "HEAD", # The branch to checkout on the repository.
path: "fastlane/Fastfile", # The path of the Fastfile in the repository.
version: "~> 1.0.0" # The version to checkout on the repository. Optimistic match operator can be used to select the latest version within constraints.
)',
'import_from_git(
url: "git@github.com:fastlane/fastlane.git", # The URL of the repository to import the Fastfile from.
branch: "HEAD", # The branch to checkout on the repository.
path: "fastlane/Fastfile", # The path of the Fastfile in the repository.
version: [">= 1.1.0", "< 2.0.0"], # The version to checkout on the repository. Multiple conditions can be used to select the latest version within constraints.
cache_path: "~/.cache/fastlane/imported", # A directory in which the repository will be added, which means that it will not be cloned again on subsequent calls.
git_extra_headers: ["Authorization: Basic <YOUR BASE64 KEY>", "Cache-Control: no-cache"]
)'
]
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_play_store_internal_app_sharing.rb | fastlane/lib/fastlane/actions/upload_to_play_store_internal_app_sharing.rb | module Fastlane
module Actions
class UploadToPlayStoreInternalAppSharingAction < Action
def self.run(params)
require 'supply'
# If no APK params were provided, try to fill in the values from lane context, preferring
# the multiple APKs over the single APK if set.
if params[:apk_paths].nil? && params[:apk].nil?
all_apk_paths = Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS] || []
if all_apk_paths.size > 1
params[:apk_paths] = all_apk_paths
else
params[:apk] = Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
end
end
# If no AAB param was provided, try to fill in the value from lane context.
# First GRADLE_ALL_AAB_OUTPUT_PATHS if only one
# Else from GRADLE_AAB_OUTPUT_PATH
if params[:aab].nil?
all_aab_paths = Actions.lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS] || []
if all_aab_paths.count == 1
params[:aab] = all_aab_paths.first
else
params[:aab] = Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]
end
end
Supply.config = params # we already have the finished config
Supply::Uploader.new.perform_upload_to_internal_app_sharing
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Upload binaries to Google Play Internal App Sharing (via _supply_)"
end
def self.details
"More information: https://docs.fastlane.tools/actions/upload_to_play_store_internal_app_sharing/"
end
def self.available_options
require 'supply'
require 'supply/options'
options = Supply::Options.available_options.clone
# remove all the unnecessary (for this action) options
options_to_keep = [:package_name, :apk, :apk_paths, :aab, :aab_paths, :json_key, :json_key_data, :root_url, :timeout]
options.delete_if { |option| options_to_keep.include?(option.key) == false }
end
def self.return_value
"Returns a string containing the download URL for the uploaded APK/AAB (or array of strings if multiple were uploaded)."
end
def self.authors
["andrewhavens"]
end
def self.is_supported?(platform)
platform == :android
end
def self.example_code
["upload_to_play_store_internal_app_sharing"]
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/version_bump_podspec.rb | fastlane/lib/fastlane/actions/version_bump_podspec.rb | module Fastlane
module Actions
module SharedValues
PODSPEC_VERSION_NUMBER ||= :PODSPEC_VERSION_NUMBER
end
class VersionBumpPodspecAction < Action
def self.run(params)
podspec_path = params[:path]
UI.user_error!("Could not find podspec file at path #{podspec_path}") unless File.exist?(podspec_path)
version_podspec_file = Helper::PodspecHelper.new(podspec_path, params[:require_variable_prefix])
if params[:version_number]
new_version = params[:version_number]
elsif params[:version_appendix]
new_version = version_podspec_file.update_version_appendix(params[:version_appendix])
else
new_version = version_podspec_file.bump_version(params[:bump_type])
end
version_podspec_file.update_podspec(new_version)
Actions.lane_context[SharedValues::PODSPEC_VERSION_NUMBER] = new_version
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Increment or set the version in a podspec file"
end
def self.details
[
"You can use this action to manipulate any 'version' variable contained in a ruby file.",
"For example, you can use it to bump the version of a CocoaPods' podspec file.",
"It also supports versions that are not semantic: `1.4.14.4.1`.",
"For such versions, there is an option to change the appendix (e.g. `4.1`)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_VERSION_BUMP_PODSPEC_PATH",
description: "You must specify the path to the podspec file to update",
code_gen_sensitive: true,
default_value: Dir["*.podspec"].last,
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Please pass a path to the `version_bump_podspec` action") if value.length == 0
end),
FastlaneCore::ConfigItem.new(key: :bump_type,
env_name: "FL_VERSION_BUMP_PODSPEC_BUMP_TYPE",
description: "The type of this version bump. Available: patch, minor, major",
default_value: "patch",
verify_block: proc do |value|
UI.user_error!("Available values are 'patch', 'minor' and 'major'") unless ['patch', 'minor', 'major'].include?(value)
end),
FastlaneCore::ConfigItem.new(key: :version_number,
env_name: "FL_VERSION_BUMP_PODSPEC_VERSION_NUMBER",
description: "Change to a specific version. This will replace the bump type value",
optional: true),
FastlaneCore::ConfigItem.new(key: :version_appendix,
env_name: "FL_VERSION_BUMP_PODSPEC_VERSION_APPENDIX",
description: "Change version appendix to a specific value. For example 1.4.14.4.1 -> 1.4.14.5",
optional: true),
FastlaneCore::ConfigItem.new(key: :require_variable_prefix,
env_name: "FL_VERSION_BUMP_PODSPEC_VERSION_REQUIRE_VARIABLE_PREFIX",
description: "true by default, this is used for non CocoaPods version bumps only",
type: Boolean,
default_value: true)
]
end
def self.output
[
['PODSPEC_VERSION_NUMBER', 'The new podspec version number']
]
end
def self.authors
["Liquidsoul", "KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'version = version_bump_podspec(path: "TSMessages.podspec", bump_type: "patch")',
'version = version_bump_podspec(path: "TSMessages.podspec", version_number: "1.4")'
]
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/download.rb | fastlane/lib/fastlane/actions/download.rb | module Fastlane
module Actions
module SharedValues
DOWNLOAD_CONTENT = :DOWNLOAD_CONTENT
end
class DownloadAction < Action
def self.run(params)
require 'net/http'
begin
result = Net::HTTP.get(URI(params[:url]))
begin
result = JSON.parse(result) # try to parse and see if it's valid JSON data
rescue
# never mind, using standard text data instead
end
Actions.lane_context[SharedValues::DOWNLOAD_CONTENT] = result
rescue => ex
UI.user_error!("Error fetching remote file: #{ex}")
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Download a file from a remote server (e.g. JSON file)"
end
def self.details
[
"Specify the URL to download and get the content as a return value.",
"Automatically parses JSON into a Ruby data structure.",
"For more advanced networking code, use the Ruby functions instead: [http://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html](http://docs.ruby-lang.org/en/2.0.0/Net/HTTP.html)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :url,
env_name: "FL_DOWNLOAD_URL",
description: "The URL that should be downloaded",
verify_block: proc do |value|
UI.important("The URL doesn't start with http or https") unless value.start_with?("http")
end)
]
end
def self.output
[
['DOWNLOAD_CONTENT', 'The content of the file we just downloaded']
]
end
def self.example_code
[
'data = download(url: "https://host.com/api.json")'
]
end
def self.category
:misc
end
def self.authors
["KrauseFx"]
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/onesignal.rb | fastlane/lib/fastlane/actions/onesignal.rb | module Fastlane
module Actions
module SharedValues
ONE_SIGNAL_APP_ID = :ONE_SIGNAL_APP_ID
ONE_SIGNAL_APP_AUTH_KEY = :ONE_SIGNAL_APP_AUTH_KEY
end
class OnesignalAction < Action
def self.run(params)
require 'net/http'
require 'uri'
require 'base64'
app_id = params[:app_id].to_s.strip
auth_token = params[:auth_token]
app_name = params[:app_name].to_s
apns_p12_password = params[:apns_p12_password]
android_token = params[:android_token]
android_gcm_sender_id = params[:android_gcm_sender_id]
organization_id = params[:organization_id]
has_app_id = !app_id.empty?
has_app_name = !app_name.empty?
is_update = has_app_id
UI.user_error!('Please specify the `app_id` or the `app_name` parameters!') if !has_app_id && !has_app_name
UI.message("Parameter App ID: #{app_id}") if has_app_id
UI.message("Parameter App name: #{app_name}") if has_app_name
payload = {}
payload['name'] = app_name if has_app_name
unless params[:apns_p12].nil?
data = File.read(params[:apns_p12])
apns_p12 = Base64.encode64(data)
payload["apns_env"] = params[:apns_env]
payload["apns_p12"] = apns_p12
# we need to have something for the p12 password, even if it's an empty string
payload["apns_p12_password"] = apns_p12_password || ""
end
unless params[:fcm_json].nil?
data = File.read(params[:fcm_json])
fcm_json = Base64.strict_encode64(data)
payload["fcm_v1_service_account_json"] = fcm_json
end
payload["gcm_key"] = android_token unless android_token.nil?
payload["android_gcm_sender_id"] = android_gcm_sender_id unless android_gcm_sender_id.nil?
payload["organization_id"] = organization_id unless organization_id.nil?
# here's the actual lifting - POST or PUT to OneSignal
json_headers = { 'Content-Type' => 'application/json', 'Authorization' => "Key #{auth_token}" }
url = +'https://api.onesignal.com/apps'
url << '/' + app_id if is_update
uri = URI.parse(url)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
if is_update
response = http.put(uri.path, payload.to_json, json_headers)
else
response = http.post(uri.path, payload.to_json, json_headers)
end
response_body = JSON.parse(response.body)
Actions.lane_context[SharedValues::ONE_SIGNAL_APP_ID] = response_body["id"]
Actions.lane_context[SharedValues::ONE_SIGNAL_APP_AUTH_KEY] = response_body["basic_auth_key"]
check_response_code(response, is_update)
end
def self.check_response_code(response, is_update)
case response.code.to_i
when 200, 204
UI.success("Successfully #{is_update ? 'updated' : 'created new'} OneSignal app")
else
UI.user_error!("Unexpected #{response.code} with response: #{response.body}")
end
end
def self.description
"Create or update a new [OneSignal](https://onesignal.com/) application"
end
def self.details
"You can use this action to automatically create or update a OneSignal application. You can also upload a `.p12` with password, a GCM key, or both."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :app_id,
env_name: "ONE_SIGNAL_APP_ID",
sensitive: true,
description: "OneSignal App ID. Setting this updates an existing app",
optional: true),
FastlaneCore::ConfigItem.new(key: :auth_token,
env_name: "ONE_SIGNAL_AUTH_KEY",
sensitive: true,
description: "OneSignal Authorization Key",
verify_block: proc do |value|
if value.to_s.empty?
UI.error("Please add 'ENV[\"ONE_SIGNAL_AUTH_KEY\"] = \"your token\"' to your Fastfile's `before_all` section.")
UI.user_error!("No ONE_SIGNAL_AUTH_KEY given.")
end
end),
FastlaneCore::ConfigItem.new(key: :app_name,
env_name: "ONE_SIGNAL_APP_NAME",
description: "OneSignal App Name. This is required when creating an app (in other words, when `:app_id` is not set, and optional when updating an app",
optional: true),
FastlaneCore::ConfigItem.new(key: :android_token,
env_name: "ANDROID_TOKEN",
description: "ANDROID GCM KEY",
sensitive: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :android_gcm_sender_id,
env_name: "ANDROID_GCM_SENDER_ID",
description: "GCM SENDER ID",
sensitive: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :fcm_json,
env_name: "FCM_JSON",
description: "FCM Service Account JSON File (in .json format)",
optional: true),
FastlaneCore::ConfigItem.new(key: :apns_p12,
env_name: "APNS_P12",
description: "APNS P12 File (in .p12 format)",
optional: true),
FastlaneCore::ConfigItem.new(key: :apns_p12_password,
env_name: "APNS_P12_PASSWORD",
sensitive: true,
description: "APNS P12 password",
optional: true),
FastlaneCore::ConfigItem.new(key: :apns_env,
env_name: "APNS_ENV",
description: "APNS environment",
optional: true,
default_value: 'production'),
FastlaneCore::ConfigItem.new(key: :organization_id,
env_name: "ONE_SIGNAL_ORGANIZATION_ID",
sensitive: true,
description: "OneSignal Organization ID",
optional: true)
]
end
def self.output
[
['ONE_SIGNAL_APP_ID', 'The app ID of the newly created or updated app'],
['ONE_SIGNAL_APP_AUTH_KEY', 'The auth token for the newly created or updated app']
]
end
def self.authors
["timothybarraclough", "smartshowltd"]
end
def self.is_supported?(platform)
[:ios, :android].include?(platform)
end
def self.example_code
[
'onesignal(
auth_token: "Your OneSignal Auth Token",
app_name: "Name for OneSignal App",
android_token: "Your Android GCM key (optional)",
android_gcm_sender_id: "Your Android GCM Sender ID (optional)",
fcm_json: "Path to FCM Service Account JSON File (optional)",
apns_p12: "Path to Apple .p12 file (optional)",
apns_p12_password: "Password for .p12 file (optional)",
apns_env: "production/sandbox (defaults to production)",
organization_id: "Onesignal organization id (optional)"
)',
'onesignal(
app_id: "Your OneSignal App ID",
auth_token: "Your OneSignal Auth Token",
app_name: "New Name for OneSignal App",
android_token: "Your Android GCM key (optional)",
android_gcm_sender_id: "Your Android GCM Sender ID (optional)",
fcm_json: "Path to FCM Service Account JSON File (optional)",
apns_p12: "Path to Apple .p12 file (optional)",
apns_p12_password: "Password for .p12 file (optional)",
apns_env: "production/sandbox (defaults to production)",
organization_id: "Onesignal organization id (optional)"
)'
]
end
def self.category
:push
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_plist.rb | fastlane/lib/fastlane/actions/update_plist.rb | module Fastlane
module Actions
module SharedValues
end
class UpdatePlistAction < Action
def self.run(params)
require 'xcodeproj'
if params[:plist_path].nil?
UI.user_error!("You must specify a plist path")
end
# Read existing plist file
plist_path = params[:plist_path]
UI.user_error!("Couldn't find plist file at path '#{plist_path}'") unless File.exist?(plist_path)
plist = Xcodeproj::Plist.read_from_path(plist_path)
params[:block].call(plist) if params[:block]
# Write changes to file
Xcodeproj::Plist.write_to_path(plist, plist_path)
UI.success("Updated #{params[:plist_path]} πΎ.")
File.read(plist_path)
end
#####################################################
# @!group Documentation
#####################################################
def self.is_supported?(platform)
[:ios].include?(platform)
end
def self.description
'Update a plist file'
end
def self.details
"This action allows you to modify any value inside any `plist` file."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :plist_path,
env_name: "FL_UPDATE_PLIST_PATH",
description: "Path to plist file",
optional: true),
FastlaneCore::ConfigItem.new(key: :block,
type: :string_callback,
description: 'A block to process plist with custom logic')
]
end
def self.author
["rishabhtayal", "matthiaszarzecki"]
end
def self.example_code
[
'update_plist( # Updates the CLIENT_ID and GOOGLE_APP_ID string entries in the plist-file
plist_path: "path/to/your_plist_file.plist",
block: proc do |plist|
plist[:CLIENT_ID] = "new_client_id"
plist[:GOOGLE_APP_ID] = "new_google_app_id"
end
)',
'update_plist( # Sets a boolean entry
plist_path: "path/to/your_plist_file.plist",
block: proc do |plist|
plist[:boolean_entry] = true
end
)',
'update_plist( # Sets a number entry
plist_path: "path/to/your_plist_file.plist",
block: proc do |plist|
plist[:number_entry] = 13
end
)',
'update_plist( # Sets an array-entry with multiple sub-types
plist_path: "path/to/your_plist_file.plist",
block: proc do |plist|
plist[:array_entry] = ["entry_01", true, 1243]
end
)',
'update_plist( # The block can contain logic too
plist_path: "path/to/your_plist_file.plist",
block: proc do |plist|
if options[:environment] == "production"
plist[:CLIENT_ID] = "new_client_id_production"
else
plist[:CLIENT_ID] = "new_client_id_development"
end
end
)',
'update_plist( # Advanced processing: find URL scheme for particular key and replace value
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/delete_keychain.rb | fastlane/lib/fastlane/actions/delete_keychain.rb | require 'shellwords'
module Fastlane
module Actions
class DeleteKeychainAction < Action
def self.run(params)
original = Actions.lane_context[Actions::SharedValues::ORIGINAL_DEFAULT_KEYCHAIN]
if params[:keychain_path]
if File.exist?(params[:keychain_path])
keychain_path = params[:keychain_path]
else
UI.user_error!("Unable to find the specified keychain.")
end
elsif params[:name]
keychain_path = FastlaneCore::Helper.keychain_path(params[:name])
else
UI.user_error!("You either have to set :name or :keychain_path")
end
Fastlane::Actions.sh("security default-keychain -s #{original}", log: false) unless original.nil?
Fastlane::Actions.sh("security delete-keychain #{keychain_path.shellescape}", log: false)
end
def self.details
"Keychains can be deleted after being created with `create_keychain`"
end
def self.description
"Delete keychains and remove them from the search list"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :name,
env_name: "KEYCHAIN_NAME",
description: "Keychain name",
conflicting_options: [:keychain_path],
optional: true),
FastlaneCore::ConfigItem.new(key: :keychain_path,
env_name: "KEYCHAIN_PATH",
description: "Keychain path",
conflicting_options: [:name],
optional: true)
]
end
def self.example_code
[
'delete_keychain(name: "KeychainName")',
'delete_keychain(keychain_path: "/keychains/project.keychain")'
]
end
def self.category
:misc
end
def self.authors
["gin0606", "koenpunt"]
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/increment_version_number.rb | fastlane/lib/fastlane/actions/increment_version_number.rb | module Fastlane
module Actions
module SharedValues
VERSION_NUMBER ||= :VERSION_NUMBER
end
class IncrementVersionNumberAction < Action
require 'shellwords'
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.run(params)
# More information about how to set up your project and how it works:
# https://developer.apple.com/library/ios/qa/qa1827/_index.html
folder = params[:xcodeproj] ? File.join(params[:xcodeproj], '..') : '.'
command_prefix = [
'cd',
File.expand_path(folder).shellescape,
'&&'
].join(' ')
begin
current_version = Actions
.sh("#{command_prefix} agvtool what-marketing-version -terse1", log: FastlaneCore::Globals.verbose?)
.split("\n")
.last
.strip
rescue
current_version = ''
end
if params[:version_number]
UI.verbose(version_format_error(current_version)) unless current_version =~ version_regex
# Specific version
next_version_number = params[:version_number]
else
UI.user_error!(version_format_error(current_version)) unless current_version =~ version_regex
version_array = current_version.split(".").map(&:to_i)
case params[:bump_type]
when "bump"
version_array[-1] = version_array[-1] + 1
next_version_number = version_array.join(".")
when "patch"
UI.user_error!(version_token_error) if version_array.count < 3
version_array[2] = version_array[2] + 1
next_version_number = version_array.join(".")
when "minor"
UI.user_error!(version_token_error) if version_array.count < 2
version_array[1] = version_array[1] + 1
version_array[2] = 0 if version_array[2]
next_version_number = version_array.join(".")
when "major"
UI.user_error!(version_token_error) if version_array.count == 0
version_array[0] = version_array[0] + 1
version_array[1] = 0 if version_array[1]
version_array[2] = 0 if version_array[2]
next_version_number = version_array.join(".")
when "specific_version"
next_version_number = specific_version_number
end
end
command = [
command_prefix,
"agvtool new-marketing-version #{next_version_number.to_s.strip}"
].join(' ')
if Helper.test?
Actions.lane_context[SharedValues::VERSION_NUMBER] = command
else
Actions.sh(command)
Actions.lane_context[SharedValues::VERSION_NUMBER] = next_version_number
end
return Actions.lane_context[SharedValues::VERSION_NUMBER]
rescue => ex
UI.error('Before 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')
raise ex
end
def self.version_regex
/^\d+(\.\d+){0,2}$/
end
def self.version_format_error(version)
"Your current version (#{version}) does not respect the format A or A.B or A.B.C"
end
def self.version_token_error
"Can't increment version"
end
def self.description
"Increment the version number of your project"
end
def self.details
[
"This action will increment the version number.",
"You first have to set up your Xcode project, if you haven't done it already: [https://developer.apple.com/library/ios/qa/qa1827/_index.html](https://developer.apple.com/library/ios/qa/qa1827/_index.html)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :bump_type,
env_name: "FL_VERSION_NUMBER_BUMP_TYPE",
description: "The type of this version bump. Available: patch, minor, major",
default_value: "bump",
verify_block: proc do |value|
UI.user_error!("Available values are 'patch', 'minor' and 'major'") unless ['bump', 'patch', 'minor', 'major'].include?(value)
end),
FastlaneCore::ConfigItem.new(key: :version_number,
env_name: "FL_VERSION_NUMBER_VERSION_NUMBER",
description: "Change to a specific version. This will replace the bump type value",
optional: true),
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "FL_VERSION_NUMBER_PROJECT",
description: "optional, you must specify the path to your main Xcode project if it is not in the project root directory",
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,
optional: true)
]
end
def self.output
[
['VERSION_NUMBER', 'The new version number']
]
end
def self.return_type
:string
end
def self.return_value
"The new version number"
end
def self.author
"serluca"
end
def self.example_code
[
'increment_version_number # Automatically increment version number',
'increment_version_number(
bump_type: "patch" # Automatically increment patch version number
)',
'increment_version_number(
bump_type: "minor" # Automatically increment minor version number
)',
'increment_version_number(
bump_type: "major" # Automatically increment major version number
)',
'increment_version_number(
version_number: "2.1.1" # Set a specific version number
)',
'increment_version_number(
version_number: "2.1.1", # specify specific version number (optional, omitting it increments patch version number)
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)
)',
'version = increment_version_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/notarize.rb | fastlane/lib/fastlane/actions/notarize.rb | module Fastlane
module Actions
class NotarizeAction < Action
# rubocop:disable Metrics/PerceivedComplexity
def self.run(params)
package_path = params[:package]
bundle_id = params[:bundle_id]
skip_stapling = params[:skip_stapling]
try_early_stapling = params[:try_early_stapling]
print_log = params[:print_log]
verbose = params[:verbose]
# 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
api_key = Spaceship::ConnectAPI::Token.from(hash: params[:api_key], filepath: params[:api_key_path])
use_notarytool = params[:use_notarytool]
# Compress and read bundle identifier only for .app bundle.
compressed_package_path = nil
if File.extname(package_path) == '.app'
compressed_package_path = "#{package_path}.zip"
Actions.sh(
"ditto -c -k --rsrc --keepParent \"#{package_path}\" \"#{compressed_package_path}\"",
log: verbose
)
unless bundle_id
info_plist_path = File.join(package_path, 'Contents', 'Info.plist')
bundle_id = Actions.sh(
"/usr/libexec/PlistBuddy -c \"Print :CFBundleIdentifier\" \"#{info_plist_path}\"",
log: verbose
).strip
end
end
UI.user_error!('Could not read bundle identifier, provide as a parameter') unless bundle_id
if use_notarytool
notarytool(params, package_path, bundle_id, skip_stapling, print_log, verbose, api_key, compressed_package_path)
else
altool(params, package_path, bundle_id, try_early_stapling, skip_stapling, print_log, verbose, api_key, compressed_package_path)
end
end
def self.notarytool(params, package_path, bundle_id, skip_stapling, print_log, verbose, api_key, compressed_package_path)
temp_file = nil
# Create authorization part of command with either API Key or Apple ID
auth_parts = []
if api_key
# Writes key contents to temporary file for command
require 'tempfile'
temp_file = Tempfile.new
api_key.write_key_to_file(temp_file.path)
auth_parts << "--key #{temp_file.path}"
auth_parts << "--key-id #{api_key.key_id}"
auth_parts << "--issuer #{api_key.issuer_id}"
else
auth_parts << "--apple-id #{params[:username]}"
auth_parts << "--password #{ENV['FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD']}"
auth_parts << "--team-id #{params[:asc_provider]}"
end
# Submits package and waits for processing using `xcrun notarytool submit --wait`
submit_parts = [
"xcrun notarytool submit",
(compressed_package_path || package_path).shellescape,
"--output-format json",
"--wait"
] + auth_parts
if verbose
submit_parts << "--verbose"
end
submit_command = submit_parts.join(' ')
submit_response = Actions.sh(
submit_command,
log: verbose,
error_callback: lambda { |msg|
UI.error("Error polling for notarization info: #{msg}")
}
)
notarization_info = JSON.parse(submit_response)
# Staple
submission_id = notarization_info["id"]
case notarization_info['status']
when 'Accepted'
UI.success("Successfully uploaded package to notarization service with request identifier #{submission_id}")
if skip_stapling
UI.success("Successfully notarized artifact")
else
UI.message('Stapling package')
self.staple(package_path, verbose)
UI.success("Successfully notarized and stapled package")
end
when 'Invalid'
if submission_id && print_log
log_request_parts = [
"xcrun notarytool log #{submission_id}"
] + auth_parts
log_request_command = log_request_parts.join(' ')
log_request_response = Actions.sh(
log_request_command,
log: verbose,
error_callback: lambda { |msg|
UI.error("Error requesting the notarization log: #{msg}")
}
)
UI.user_error!("Could not notarize package with message '#{log_request_response}'")
else
UI.user_error!("Could not notarize package. To see the error, please set 'print_log' to true.")
end
else
UI.crash!("Could not notarize package with status '#{notarization_info['status']}'")
end
ensure
temp_file.delete if temp_file
end
def self.altool(params, package_path, bundle_id, try_early_stapling, skip_stapling, print_log, verbose, api_key, compressed_package_path)
UI.message('Uploading package to notarization service, might take a while')
notarization_upload_command = "xcrun altool --notarize-app -t osx -f \"#{compressed_package_path || package_path}\" --primary-bundle-id #{bundle_id} --output-format xml"
notarization_info = {}
with_notarize_authenticator(params, api_key) do |notarize_authenticator|
notarization_upload_command << " --asc-provider \"#{params[:asc_provider]}\"" if params[:asc_provider] && api_key.nil?
notarization_upload_response = Actions.sh(
notarize_authenticator.call(notarization_upload_command),
log: verbose
)
FileUtils.rm_rf(compressed_package_path) if compressed_package_path
notarization_upload_plist = Plist.parse_xml(notarization_upload_response)
if notarization_upload_plist.key?('product-errors') && notarization_upload_plist['product-errors'].any?
UI.important("π« Could not upload package to notarization service! Here are the reasons:")
notarization_upload_plist['product-errors'].each { |product_error| UI.error("#{product_error['message']} (#{product_error['code']})") }
UI.user_error!("Package upload to notarization service cancelled. Please check the error messages above.")
end
notarization_request_id = notarization_upload_plist['notarization-upload']['RequestUUID']
UI.success("Successfully uploaded package to notarization service with request identifier #{notarization_request_id}")
while notarization_info.empty? || (notarization_info['Status'] == 'in progress')
if notarization_info.empty?
UI.message('Waiting to query request status')
elsif try_early_stapling && !skip_stapling
UI.message('Request in progress, trying early staple')
begin
self.staple(package_path, verbose)
UI.message('Successfully notarized and early stapled package.')
return
rescue
UI.message('Early staple failed, waiting to query again')
end
end
sleep(30)
UI.message('Querying request status')
# As of July 2020, the request UUID might not be available for polling yet which returns an error code
# This is now handled with the error_callback (which prevents an error from being raised)
# Catching this error allows for polling to continue until the notarization is complete
error = false
notarization_info_response = Actions.sh(
notarize_authenticator.call("xcrun altool --notarization-info #{notarization_request_id} --output-format xml"),
log: verbose,
error_callback: lambda { |msg|
error = true
UI.error("Error polling for notarization info: #{msg}")
}
)
unless error
notarization_info_plist = Plist.parse_xml(notarization_info_response)
notarization_info = notarization_info_plist['notarization-info']
end
end
end
# rubocop:enable Metrics/PerceivedComplexity
log_url = notarization_info['LogFileURL']
ENV['FL_NOTARIZE_LOG_FILE_URL'] = log_url
log_suffix = ''
if log_url && print_log
log_response = Net::HTTP.get(URI(log_url))
log_json_object = JSON.parse(log_response)
log_suffix = ", with log:\n#{JSON.pretty_generate(log_json_object)}"
end
case notarization_info['Status']
when 'success'
if skip_stapling
UI.success("Successfully notarized artifact#{log_suffix}")
else
UI.message('Stapling package')
self.staple(package_path, verbose)
UI.success("Successfully notarized and stapled package#{log_suffix}")
end
when 'invalid'
UI.user_error!("Could not notarize package with message '#{notarization_info['Status Message']}'#{log_suffix}")
else
UI.crash!("Could not notarize package with status '#{notarization_info['Status']}'#{log_suffix}")
end
ensure
ENV.delete('FL_NOTARIZE_PASSWORD')
end
def self.staple(package_path, verbose)
Actions.sh(
"xcrun stapler staple #{package_path.shellescape}",
log: verbose
)
end
def self.with_notarize_authenticator(params, api_key)
if api_key
# From xcrun altool for --apiKey:
# This option will search the following directories in sequence for a private key file with the name of 'AuthKey_<api_key>.p8': './private_keys', '~/private_keys', '~/.private_keys', and '~/.appstoreconnect/private_keys'.
api_key_folder_path = File.expand_path('~/.appstoreconnect/private_keys')
api_key_file_path = File.join(api_key_folder_path, "AuthKey_#{api_key.key_id}.p8")
directory_exists = File.directory?(api_key_folder_path)
file_exists = File.exist?(api_key_file_path)
begin
FileUtils.mkdir_p(api_key_folder_path) unless directory_exists
api_key.write_key_to_file(api_key_file_path) unless file_exists
yield(proc { |command| "#{command} --apiKey #{api_key.key_id} --apiIssuer #{api_key.issuer_id}" })
ensure
FileUtils.rm(api_key_file_path) unless file_exists
FileUtils.rm_r(api_key_folder_path) unless directory_exists
end
else
apple_id_account = CredentialsManager::AccountManager.new(user: params[:username])
# Add password as a temporary environment variable for altool.
# Use app specific password if specified.
ENV['FL_NOTARIZE_PASSWORD'] = ENV['FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD'] || apple_id_account.password
yield(proc { |command| "#{command} -u #{apple_id_account.user} -p @env:FL_NOTARIZE_PASSWORD" })
end
end
def self.description
'Notarizes a macOS app'
end
def self.authors
['zeplin']
end
def self.available_options
username = CredentialsManager::AppfileConfig.try_fetch_value(:apple_dev_portal_id)
username ||= CredentialsManager::AppfileConfig.try_fetch_value(:apple_id)
asc_provider = CredentialsManager::AppfileConfig.try_fetch_value(:itc_team_id)
[
FastlaneCore::ConfigItem.new(key: :package,
env_name: 'FL_NOTARIZE_PACKAGE',
description: 'Path to package to notarize, e.g. .app bundle or disk image',
verify_block: proc do |value|
UI.user_error!("Could not find package at '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :use_notarytool,
env_name: 'FL_NOTARIZE_USE_NOTARYTOOL',
description: 'Whether to `xcrun notarytool` or `xcrun altool`',
default_value: Helper.mac? && Helper.xcode_at_least?("13.0"), # Notary tool added in Xcode 13
default_value_dynamic: true,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :try_early_stapling,
env_name: 'FL_NOTARIZE_TRY_EARLY_STAPLING',
description: 'Whether to try early stapling while the notarization request is in progress',
optional: true,
conflicting_options: [:skip_stapling],
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :skip_stapling,
env_name: 'FL_NOTARIZE_SKIP_STAPLING',
description: 'Do not staple the notarization ticket to the artifact; useful for single file executables and ZIP archives',
optional: true,
conflicting_options: [:try_early_stapling],
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :bundle_id,
env_name: 'FL_NOTARIZE_BUNDLE_ID',
description: 'Bundle identifier to uniquely identify the package',
optional: true),
FastlaneCore::ConfigItem.new(key: :username,
env_name: 'FL_NOTARIZE_USERNAME',
description: 'Apple ID username',
default_value: username,
optional: true,
conflicting_options: [:api_key_path, :api_key],
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :asc_provider,
env_name: 'FL_NOTARIZE_ASC_PROVIDER',
description: 'Provider short name for accounts associated with multiple providers',
optional: true,
default_value: asc_provider),
FastlaneCore::ConfigItem.new(key: :print_log,
env_name: 'FL_NOTARIZE_PRINT_LOG',
description: 'Whether to print notarization log file, listing issues on failure and warnings on success',
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: 'FL_NOTARIZE_VERBOSE',
description: 'Whether to log requests',
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :api_key_path,
env_names: ['FL_NOTARIZE_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: [:username, :api_key],
verify_block: proc do |value|
UI.user_error!("API Key not found at '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_names: ['FL_NOTARIZE_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)",
optional: true,
conflicting_options: [:username, :api_key_path],
sensitive: true,
type: Hash)
]
end
def self.is_supported?(platform)
platform == :mac
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/commit_version_bump.rb | fastlane/lib/fastlane/actions/commit_version_bump.rb | require 'pathname'
module Fastlane
module Actions
module SharedValues
MODIFIED_FILES = :MODIFIED_FILES
end
class << self
# Add an array of paths relative to the repo root or absolute paths that have been modified by
# an action.
#
# :files: An array of paths relative to the repo root or absolute paths
def add_modified_files(files)
modified_files = lane_context[SharedValues::MODIFIED_FILES] || Set.new
modified_files += files
lane_context[SharedValues::MODIFIED_FILES] = modified_files
end
end
# Commits the current changes in the repo as a version bump, checking to make sure only files which contain version information have been changed.
class CommitVersionBumpAction < Action
def self.run(params)
require 'xcodeproj'
require 'set'
require 'shellwords'
xcodeproj_path = params[:xcodeproj] ? File.expand_path(File.join('.', params[:xcodeproj])) : nil
# find the repo root path
repo_path = Actions.sh('git rev-parse --show-toplevel').strip
repo_pathname = Pathname.new(repo_path)
if xcodeproj_path
# ensure that the xcodeproj passed in was OK
UI.user_error!("Could not find the specified xcodeproj: #{xcodeproj_path}") unless File.directory?(xcodeproj_path)
else
# find an xcodeproj (ignoring dependencies)
xcodeproj_paths = Fastlane::Helper::XcodeprojHelper.find(repo_path)
# no projects found: error
UI.user_error!('Could not find a .xcodeproj in the current repository\'s working directory.') if xcodeproj_paths.count == 0
# too many projects found: error
if xcodeproj_paths.count > 1
relative_projects = xcodeproj_paths.map { |e| Pathname.new(e).relative_path_from(repo_pathname).to_s }.join("\n")
UI.user_error!("Found multiple .xcodeproj projects in the current repository's working directory. Please specify your app's main project: \n#{relative_projects}")
end
# one project found: great
xcodeproj_path = xcodeproj_paths.first
end
# find the pbxproj path, relative to git directory
pbxproj_pathname = Pathname.new(File.join(xcodeproj_path, 'project.pbxproj'))
pbxproj_path = pbxproj_pathname.relative_path_from(repo_pathname).to_s
# find the info_plist files
project = Xcodeproj::Project.open(xcodeproj_path)
info_plist_files = project.objects.select do |object|
object.isa == 'XCBuildConfiguration'
end.map(&:to_hash).map do |object_hash|
object_hash['buildSettings']
end.select do |build_settings|
build_settings.key?('INFOPLIST_FILE')
end.map do |build_settings|
build_settings['INFOPLIST_FILE']
end.uniq.map do |info_plist_path|
Pathname.new(File.expand_path(File.join(xcodeproj_path, '..', info_plist_path))).relative_path_from(repo_pathname).to_s
end
# Removes .plist files that matched the given expression in the 'ignore' parameter
ignore_expression = params[:ignore]
if ignore_expression
info_plist_files.reject! do |info_plist_file|
info_plist_file.match(ignore_expression)
end
end
extra_files = params[:include]
extra_files += modified_files_relative_to_repo_root(repo_path)
# create our list of files that we expect to have changed, they should all be relative to the project root, which should be equal to the git workdir root
expected_changed_files = extra_files
expected_changed_files << pbxproj_path
expected_changed_files << info_plist_files
if params[:settings]
settings_plists_from_param(params[:settings]).each do |file|
settings_file_pathname = Pathname.new(settings_bundle_file_path(project, file))
expected_changed_files << settings_file_pathname.relative_path_from(repo_pathname).to_s
end
end
expected_changed_files.flatten!.uniq!
# get the list of files that have actually changed in our git workdir
git_dirty_files = Actions.sh('git diff --name-only HEAD').split("\n") + Actions.sh('git ls-files --other --exclude-standard').split("\n")
# little user hint
UI.user_error!("No file changes picked up. Make sure you run the `increment_build_number` action first.") if git_dirty_files.empty?
# check if the files changed are the ones we expected to change (these should be only the files that have version info in them)
changed_files_as_expected = Set.new(git_dirty_files.map(&:downcase)).subset?(Set.new(expected_changed_files.map(&:downcase)))
unless changed_files_as_expected
unless params[:force]
error = [
"Found unexpected uncommitted changes in the working directory. Expected these files to have ",
"changed: \n#{expected_changed_files.join("\n")}.\nBut found these actual changes: ",
"#{git_dirty_files.join("\n")}.\nMake sure you have cleaned up the build artifacts and ",
"are only left with the changed version files at this stage in your lane, and don't touch the ",
"working directory while your lane is running. You can also use the :force option to bypass this ",
"check, and always commit a version bump regardless of the state of the working directory."
].join("\n")
UI.user_error!(error)
end
end
# get the absolute paths to the files
git_add_paths = expected_changed_files.map do |path|
updated = path.gsub("$(SRCROOT)", ".").gsub("${SRCROOT}", ".")
File.expand_path(File.join(repo_pathname, updated))
end
# then create a commit with a message
Actions.sh("git add #{git_add_paths.map(&:shellescape).join(' ')}")
begin
command = build_git_command(params)
Actions.sh(command)
UI.success("Committed \"#{params[:message]}\" πΎ.")
rescue => ex
UI.error(ex)
UI.important("Didn't commit any changes.")
end
end
def self.description
"Creates a 'Version Bump' commit. Run after `increment_build_number`"
end
def self.output
[
['MODIFIED_FILES', 'The list of paths of modified files']
]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :message,
env_name: "FL_COMMIT_BUMP_MESSAGE",
description: "The commit message when committing the version bump",
optional: true),
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "FL_BUILD_NUMBER_PROJECT",
description: "The path to your project file (Not the workspace). If you have only one, this is optional",
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: :force,
env_name: "FL_FORCE_COMMIT",
description: "Forces the commit, even if other files than the ones containing the version number have been modified",
type: Boolean,
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :settings,
env_name: "FL_COMMIT_INCLUDE_SETTINGS",
description: "Include Settings.bundle/Root.plist with version bump",
skip_type_validation: true, # allows Boolean, String, Array
optional: true,
default_value: false),
FastlaneCore::ConfigItem.new(key: :ignore,
description: "A regular expression used to filter matched plist files to be modified",
skip_type_validation: true, # allows Regex
optional: true),
FastlaneCore::ConfigItem.new(key: :include,
description: "A list of extra files to be included in the version bump (string array or comma-separated string)",
optional: true,
default_value: [],
type: Array),
FastlaneCore::ConfigItem.new(key: :no_verify,
env_name: "FL_GIT_PUSH_USE_NO_VERIFY",
description: "Whether or not to use --no-verify",
type: Boolean,
default_value: false)
]
end
def self.details
list = <<-LIST.markdown_list
All `.plist` files
The `.xcodeproj/project.pbxproj` file
LIST
[
"This action will create a 'Version Bump' commit in your repo. Useful in conjunction with `increment_build_number`.",
"It checks the repo to make sure that only the relevant files have changed. These are the files that `increment_build_number` (`agvtool`) touches:".markdown_preserve_newlines,
list,
"Then commits those files to the repo.",
"Customize the message with the `:message` option. It defaults to 'Version Bump'.",
"If you have other uncommitted changes in your repo, this action will fail. If you started off in a clean repo, and used the _ipa_ and or _sigh_ actions, then you can use the [clean_build_artifacts](https://docs.fastlane.tools/actions/clean_build_artifacts/) action to clean those temporary files up before running this action."
].join("\n")
end
def self.author
"lmirosevic"
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'commit_version_bump',
'commit_version_bump(
message: "Version Bump", # create a commit with a custom message
xcodeproj: "./path/to/MyProject.xcodeproj" # optional, if you have multiple Xcode project files, you must specify your main project here
)',
'commit_version_bump(
settings: true # Include Settings.bundle/Root.plist
)',
'commit_version_bump(
settings: "About.plist" # Include Settings.bundle/About.plist
)',
'commit_version_bump(
settings: %w[About.plist Root.plist] # Include more than one plist from Settings.bundle
)',
'commit_version_bump(
include: %w[package.json custom.cfg] # include other updated files as part of the version bump
)',
'commit_version_bump(
ignore: /OtherProject/ # ignore files matching a regular expression
)',
'commit_version_bump(
no_verify: true # optional, default: false
)'
]
end
def self.category
:source_control
end
class << self
def settings_plists_from_param(param)
if param.kind_of?(String)
# commit_version_bump settings: "About.plist"
return [param]
elsif param.kind_of?(Array)
# commit_version_bump settings: ["Root.plist", "About.plist"]
return param
else
# commit_version_bump settings: true # Root.plist
return ["Root.plist"]
end
end
def settings_bundle_file_path(project, settings_file_name)
settings_bundle = project.files.find { |f| f.path =~ /Settings.bundle/ }
raise "No Settings.bundle in project" if settings_bundle.nil?
return File.join(settings_bundle.real_path, settings_file_name)
end
def modified_files_relative_to_repo_root(repo_root)
return [] if Actions.lane_context[SharedValues::MODIFIED_FILES].nil?
root_pathname = Pathname.new(repo_root)
all_modified_files = Actions.lane_context[SharedValues::MODIFIED_FILES].map do |path|
next path unless path =~ %r{^/}
Pathname.new(path).relative_path_from(root_pathname).to_s
end
return all_modified_files.uniq
end
def build_git_command(params)
build_number = Actions.lane_context[Actions::SharedValues::BUILD_NUMBER]
params[:message] ||= (build_number ? "Version Bump to #{build_number}" : "Version Bump")
command = [
'git',
'commit',
'-m',
"'#{params[:message]}'"
]
command << '--no-verify' if params[:no_verify]
return command.join(' ')
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/actions/skip_docs.rb | fastlane/lib/fastlane/actions/skip_docs.rb | module Fastlane
module Actions
class SkipDocsAction < Action
def self.run(params)
ENV["FASTLANE_SKIP_DOCS"] = "1"
end
def self.step_text
nil
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Skip the creation of the fastlane/README.md file when running fastlane"
end
def self.available_options
end
def self.output
end
def self.return_value
end
def self.details
"Tell _fastlane_ to not automatically create a `fastlane/README.md` when running _fastlane_. You can always trigger the creation of this file manually by running `fastlane docs`."
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'skip_docs'
]
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/rsync.rb | fastlane/lib/fastlane/actions/rsync.rb |
module Fastlane
module Actions
module SharedValues
end
class RsyncAction < Action
def self.run(params)
rsync_cmd = ["rsync"]
rsync_cmd << params[:extra]
rsync_cmd << params[:source]
rsync_cmd << params[:destination]
Actions.sh(rsync_cmd.join(" "))
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Rsync files from :source to :destination"
end
def self.details
"A wrapper around `rsync`, which is a tool that lets you synchronize files, including permissions and so on. For a more detailed information about `rsync`, please see [rsync(1) man page](https://linux.die.net/man/1/rsync)."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :extra,
short_option: "-X",
env_name: "FL_RSYNC_EXTRA", # The name of the environment variable
description: "Port", # a short description of this parameter
optional: true,
default_value: "-av"),
FastlaneCore::ConfigItem.new(key: :source,
short_option: "-S",
env_name: "FL_RSYNC_SRC", # The name of the environment variable
description: "source file/folder", # a short description of this parameter
optional: false),
FastlaneCore::ConfigItem.new(key: :destination,
short_option: "-D",
env_name: "FL_RSYNC_DST", # The name of the environment variable
description: "destination file/folder", # a short description of this parameter
optional: false)
]
end
def self.authors
["hjanuschka"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'rsync(
source: "root@host:/tmp/1.txt",
destination: "/tmp/local_file.txt"
)'
]
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/reset_git_repo.rb | fastlane/lib/fastlane/actions/reset_git_repo.rb | require 'shellwords'
module Fastlane
module Actions
# Does a hard reset and clean on the repo
class ResetGitRepoAction < Action
def self.run(params)
if params[:force] || Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START]
paths = params[:files]
return paths if Helper.test?
if paths.nil?
Actions.sh('git reset --hard HEAD')
clean_options = ['q', 'f', 'd']
clean_options << 'x' if params[:disregard_gitignore]
clean_command = 'git clean' + ' -' + clean_options.join
# we want to make sure that we have an array of patterns, and no nil values
unless params[:exclude].kind_of?(Enumerable)
params[:exclude] = [params[:exclude]].compact
end
# attach our exclude patterns to the command
clean_command += ' ' + params[:exclude].map { |exclude| '-e ' + exclude.shellescape }.join(' ') unless params[:exclude].count == 0
Actions.sh(clean_command) unless params[:skip_clean]
UI.success('Git repo was reset and cleaned back to a pristine state.')
else
paths.each do |path|
UI.important("Couldn't find file at path '#{path}'") unless File.exist?(path)
Actions.sh("git checkout -- '#{path}'")
end
UI.success("Git cleaned up #{paths.count} files.")
end
else
UI.user_error!('This is a destructive and potentially dangerous action. To protect from data loss, please add the `ensure_git_status_clean` action to the beginning of your lane, or if you\'re absolutely sure of what you\'re doing then call this action with the :force option.')
end
end
def self.description
"Resets git repo to a clean state by discarding uncommitted changes"
end
def self.details
list = <<-LIST.markdown_list
You have called the `ensure_git_status_clean` action prior to calling this action. This ensures that your repo started off in a clean state, so the only things that will get destroyed by this action are files that are created as a byproduct of the fastlane run.
LIST
[
"This action will reset your git repo to a clean state, discarding any uncommitted and untracked changes. Useful in case you need to revert the repo back to a clean state, e.g. after running _fastlane_.",
"Untracked files like `.env` will also be deleted, unless `:skip_clean` is true.",
"It's a pretty drastic action so it comes with a sort of safety latch. It will only proceed with the reset if this condition is met:".markdown_preserve_newlines,
list
].join("\n")
end
def self.example_code
[
'reset_git_repo',
'reset_git_repo(force: true) # If you don\'t care about warnings and are absolutely sure that you want to discard all changes. This will reset the repo even if you have valuable uncommitted changes, so use with care!',
'reset_git_repo(skip_clean: true) # If you want "git clean" to be skipped, thus NOT deleting untracked files like ".env". Optional, defaults to false.',
'reset_git_repo(
force: true,
files: [
"./file.txt"
]
)'
]
end
def self.category
:source_control
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :files,
env_name: "FL_RESET_GIT_FILES",
description: "Array of files the changes should be discarded. If not given, all files will be discarded",
optional: true,
type: Array),
FastlaneCore::ConfigItem.new(key: :force,
env_name: "FL_RESET_GIT_FORCE",
description: "Skip verifying of previously clean state of repo. Only recommended in combination with `files` option",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :skip_clean,
env_name: "FL_RESET_GIT_SKIP_CLEAN",
description: "Skip 'git clean' to avoid removing untracked files like `.env`",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :disregard_gitignore,
env_name: "FL_RESET_GIT_DISREGARD_GITIGNORE",
description: "Setting this to true will clean the whole repository, ignoring anything in your local .gitignore. Set this to true if you want the equivalent of a fresh clone, and for all untracked and ignore files to also be removed",
type: Boolean,
optional: true,
default_value: true),
FastlaneCore::ConfigItem.new(key: :exclude,
env_name: "FL_RESET_GIT_EXCLUDE",
description: "You can pass a string, or array of, file pattern(s) here which you want to have survive the cleaning process, and remain on disk, e.g. to leave the `artifacts` directory you would specify `exclude: 'artifacts'`. Make sure this pattern is also in your gitignore! See the gitignore documentation for info on patterns",
skip_type_validation: true, # allows String, Array, Regex
optional: true)
]
end
def self.author
'lmirosevic'
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/register_devices.rb | fastlane/lib/fastlane/actions/register_devices.rb | require 'credentials_manager'
module Fastlane
module Actions
class RegisterDevicesAction < Action
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.file_column_headers
['Device ID', 'Device Name', 'Device Platform']
end
def self.run(params)
platform = Spaceship::ConnectAPI::BundleIdPlatform.map(params[:platform])
if params[:devices]
new_devices = params[:devices].map do |name, udid|
[udid, name]
end
elsif params[:devices_file]
require 'csv'
devices_file = CSV.read(File.expand_path(File.join(params[:devices_file])), col_sep: "\t")
unless devices_file.first == file_column_headers.first(2) || devices_file.first == file_column_headers
UI.user_error!("Please provide a file according to the Apple Sample UDID file (https://developer.apple.com/account/resources/downloads/Multiple-Upload-Samples.zip)")
end
new_devices = devices_file.drop(1).map do |row|
if row.count == 1
UI.user_error!("Invalid device line, ensure you are using tabs (NOT spaces). See Apple's sample/spec here: https://developer.apple.com/account/resources/downloads/Multiple-Upload-Samples.zip")
elsif !(2..3).cover?(row.count)
UI.user_error!("Invalid device line, please provide a file according to the Apple Sample UDID file (https://developer.apple.com/account/resources/downloads/Multiple-Upload-Samples.zip)")
end
row
end
else
UI.user_error!("You must pass either a valid `devices` or `devices_file`. Please check the readme.")
end
require 'spaceship'
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
UI.message("Fetching list of currently registered devices...")
existing_devices = Spaceship::ConnectAPI::Device.all
device_objs = new_devices.map do |device|
if existing_devices.map(&:udid).map(&:downcase).include?(device[0].downcase)
UI.verbose("UDID #{device[0]} already exists - Skipping...")
next
end
device_platform = platform
device_platform_supported = !device[2].nil? && self.is_supported?(device[2].to_sym)
if device_platform_supported
if device[2] == "mac"
device_platform = Spaceship::ConnectAPI::BundleIdPlatform::MAC_OS
else
device_platform = Spaceship::ConnectAPI::BundleIdPlatform::IOS
end
end
try_create_device(name: device[1], platform: device_platform, udid: device[0])
end
UI.success("Successfully registered new devices.")
return device_objs
end
def self.try_create_device(name: nil, platform: nil, udid: nil)
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}, UDID: #{udid})")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Registers new devices 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: :devices,
env_name: "FL_REGISTER_DEVICES_DEVICES",
description: "A hash of devices, with the name as key and the UDID as value",
type: Hash,
optional: true),
FastlaneCore::ConfigItem.new(key: :devices_file,
env_name: "FL_REGISTER_DEVICES_FILE",
description: "Provide a path to a file with the devices to register. For the format of the file see the examples",
optional: true,
verify_block: proc do |value|
UI.user_error!("Could not find file '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :api_key_path,
env_names: ["FL_REGISTER_DEVICES_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_DEVICES_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_DEVICES_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_DEVICES_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),
FastlaneCore::ConfigItem.new(key: :platform,
env_name: "REGISTER_DEVICES_PLATFORM",
description: "The platform to use (optional)",
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)
]
end
def self.details
[
"This will register iOS/Mac devices with the Developer Portal so that you can include them in your provisioning profiles.",
"This is an optimistic action, in that it will only ever add new devices to the member center, and never remove devices. If a device which has already been registered within the member center is not passed to this action, it will be left alone in the member center and continue to work.",
"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, or by setting the env variable `ENV['DELIVER_USER']`."
].join("\n")
end
def self.author
"lmirosevic"
end
def self.example_code
[
'register_devices(
devices: {
"Luka iPhone 6" => "1234567890123456789012345678901234567890",
"Felix iPad Air 2" => "abcdefghijklmnopqrstvuwxyzabcdefghijklmn"
}
) # Simply provide a list of devices as a Hash',
'register_devices(
devices_file: "./devices.txt"
) # Alternatively provide a standard UDID export .txt file, see the Apple Sample (http://devimages.apple.com/downloads/devices/Multiple-Upload-Samples.zip)',
'register_devices(
devices_file: "./devices.txt", # You must pass in either `devices_file` or `devices`.
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.
)',
'register_devices(
devices: {
"Luka MacBook" => "12345678-1234-1234-1234-123456789012",
"Felix MacBook Pro" => "ABCDEFGH-ABCD-ABCD-ABCD-ABCDEFGHIJKL"
},
platform: "mac"
) # Register devices for Mac'
]
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/sigh.rb | fastlane/lib/fastlane/actions/sigh.rb | module Fastlane
module Actions
require 'fastlane/actions/get_provisioning_profile'
class SighAction < GetProvisioningProfileAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `get_provisioning_profile` 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/artifactory.rb | fastlane/lib/fastlane/actions/artifactory.rb | module Fastlane
module Actions
module SharedValues
ARTIFACTORY_DOWNLOAD_URL = :ARTIFACTORY_DOWNLOAD_URL
ARTIFACTORY_DOWNLOAD_SIZE = :ARTIFACTORY_DOWNLOAD_SIZE
end
class ArtifactoryAction < Action
def self.run(params)
Actions.verify_gem!('artifactory')
require 'artifactory'
UI.user_error!("Cannot connect to Artifactory - 'username' was provided but it's missing 'password'") if params[:username] && !params[:password]
UI.user_error!("Cannot connect to Artifactory - 'password' was provided but it's missing 'username'") if !params[:username] && params[:password]
UI.user_error!("Cannot connect to Artifactory - either 'api_key', or 'username' and 'password' must be provided") if !params[:api_key] && !params[:username]
file_path = File.absolute_path(params[:file])
if File.exist?(file_path)
client = connect_to_artifactory(params)
artifact = Artifactory::Resource::Artifact.new
artifact.client = client
artifact.local_path = file_path
artifact.checksums = {
"sha1" => Digest::SHA1.file(file_path),
"md5" => Digest::MD5.file(file_path)
}
UI.message("Uploading file: #{artifact.local_path} ...")
upload = artifact.upload(params[:repo], params[:repo_path], params[:properties])
Actions.lane_context[SharedValues::ARTIFACTORY_DOWNLOAD_URL] = upload.uri
Actions.lane_context[SharedValues::ARTIFACTORY_DOWNLOAD_SIZE] = upload.size
UI.message("Uploaded Artifact:")
UI.message("Repo: #{upload.repo}")
UI.message("URI: #{upload.uri}")
UI.message("Size: #{upload.size}")
UI.message("SHA1: #{upload.sha1}")
else
UI.message("File not found: '#{file_path}'")
end
end
def self.connect_to_artifactory(params)
config_keys = [:endpoint, :username, :password, :api_key, :ssl_pem_file, :ssl_verify, :proxy_username, :proxy_password, :proxy_address, :proxy_port, :read_timeout]
config = params.values.select do |key|
config_keys.include?(key)
end
Artifactory::Client.new(config)
end
def self.description
'This action uploads an artifact to artifactory'
end
def self.details
'Connect to the artifactory server using either a username/password or an api_key'
end
def self.is_supported?(platform)
true
end
def self.author
["koglinjg", "tommeier"]
end
def self.output
[
['ARTIFACTORY_DOWNLOAD_URL', 'The download url for file uploaded'],
['ARTIFACTORY_DOWNLOAD_SIZE', 'The reported file size for file uploaded']
]
end
def self.example_code
[
'artifactory(
username: "username",
password: "password",
endpoint: "https://artifactory.example.com/artifactory/",
file: "example.ipa", # File to upload
repo: "mobile_artifacts", # Artifactory repo
repo_path: "/ios/appname/example-major.minor.ipa" # Path to place the artifact including its filename
)',
'artifactory(
api_key: "api_key",
endpoint: "https://artifactory.example.com/artifactory/",
file: "example.ipa", # File to upload
repo: "mobile_artifacts", # Artifactory repo
repo_path: "/ios/appname/example-major.minor.ipa" # Path to place the artifact including its filename
)'
]
end
def self.category
:misc
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :file,
env_name: "FL_ARTIFACTORY_FILE",
description: "File to be uploaded to artifactory",
optional: false),
FastlaneCore::ConfigItem.new(key: :repo,
env_name: "FL_ARTIFACTORY_REPO",
description: "Artifactory repo to put the file in",
optional: false),
FastlaneCore::ConfigItem.new(key: :repo_path,
env_name: "FL_ARTIFACTORY_REPO_PATH",
description: "Path to deploy within the repo, including filename",
optional: false),
FastlaneCore::ConfigItem.new(key: :endpoint,
env_name: "FL_ARTIFACTORY_ENDPOINT",
description: "Artifactory endpoint",
optional: false),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FL_ARTIFACTORY_USERNAME",
description: "Artifactory username",
optional: true,
conflicting_options: [:api_key],
conflict_block: proc do |value|
UI.user_error!("You can't use option '#{value.key}' along with 'username'")
end),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_ARTIFACTORY_PASSWORD",
description: "Artifactory password",
sensitive: true,
code_gen_sensitive: true,
optional: true,
conflicting_options: [:api_key],
conflict_block: proc do |value|
UI.user_error!("You can't use option '#{value.key}' along with 'password'")
end),
FastlaneCore::ConfigItem.new(key: :api_key,
env_name: "FL_ARTIFACTORY_API_KEY",
description: "Artifactory API key",
sensitive: true,
code_gen_sensitive: true,
optional: true,
conflicting_options: [:username, :password],
conflict_block: proc do |value|
UI.user_error!("You can't use option '#{value.key}' along with 'api_key'")
end),
FastlaneCore::ConfigItem.new(key: :properties,
env_name: "FL_ARTIFACTORY_PROPERTIES",
description: "Artifact properties hash",
type: Hash,
default_value: {},
optional: true),
FastlaneCore::ConfigItem.new(key: :ssl_pem_file,
env_name: "FL_ARTIFACTORY_SSL_PEM_FILE",
description: "Location of pem file to use for ssl verification",
default_value: nil,
optional: true),
FastlaneCore::ConfigItem.new(key: :ssl_verify,
env_name: "FL_ARTIFACTORY_SSL_VERIFY",
description: "Verify SSL",
type: Boolean,
default_value: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_username,
env_name: "FL_ARTIFACTORY_PROXY_USERNAME",
description: "Proxy username",
default_value: nil,
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_password,
env_name: "FL_ARTIFACTORY_PROXY_PASSWORD",
description: "Proxy password",
sensitive: true,
code_gen_sensitive: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_address,
env_name: "FL_ARTIFACTORY_PROXY_ADDRESS",
description: "Proxy address",
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_port,
env_name: "FL_ARTIFACTORY_PROXY_PORT",
description: "Proxy port",
optional: true),
FastlaneCore::ConfigItem.new(key: :read_timeout,
env_name: "FL_ARTIFACTORY_READ_TIMEOUT",
description: "Read timeout",
optional: 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/last_git_commit.rb | fastlane/lib/fastlane/actions/last_git_commit.rb | module Fastlane
module Actions
class LastGitCommitAction < Action
def self.run(params)
Actions.last_git_commit_dict
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Return last git commit hash, abbreviated commit hash, commit message and author"
end
def self.return_value
"Returns the following dict: {commit_hash: \"commit hash\", abbreviated_commit_hash: \"abbreviated commit hash\" author: \"Author\", author_email: \"author email\", message: \"commit message\"}"
end
def self.return_type
:hash_of_strings
end
def self.author
"ngutman"
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'commit = last_git_commit
pilot(changelog: commit[:message]) # message of commit
author = commit[:author] # author of the commit
author_email = commit[:author_email] # email of the author of the commit
hash = commit[:commit_hash] # long sha of commit
short_hash = commit[:abbreviated_commit_hash] # short sha of commit'
]
end
def self.category
:source_control
end
def self.sample_return_value
{
message: "message",
author: "author",
author_email: "author_email",
commit_hash: "commit_hash",
abbreviated_commit_hash: "short_hash"
}
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_build_number.rb | fastlane/lib/fastlane/actions/get_build_number.rb | module Fastlane
module Actions
module SharedValues
BUILD_NUMBER ||= :BUILD_NUMBER # originally defined in IncrementBuildNumberAction
end
class GetBuildNumberAction < Action
require 'shellwords'
def self.run(params)
# More information about how to set up your project and how it works:
# https://developer.apple.com/library/ios/qa/qa1827/_index.html
folder = params[:xcodeproj] ? File.join(params[:xcodeproj], '..') : '.'
command_prefix = [
'cd',
File.expand_path(folder).shellescape,
'&&'
].join(' ')
command = [
command_prefix,
'agvtool',
'what-version',
'-terse'
].join(' ')
if Helper.test?
Actions.lane_context[SharedValues::BUILD_NUMBER] = command
else
build_number = Actions.sh(command).split("\n").last.strip
# Store the number in the shared hash
Actions.lane_context[SharedValues::BUILD_NUMBER] = build_number
end
return build_number
rescue => ex
return false if params[:hide_error_when_versioning_disabled]
UI.error('Before 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')
raise ex
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Get the build number of your project"
end
def self.details
[
"This action will return the current build number set on your project.",
"You first have to set up your Xcode project, if you haven't done it already: [https://developer.apple.com/library/ios/qa/qa1827/_index.html](https://developer.apple.com/library/ios/qa/qa1827/_index.html)."
].join("\n")
end
def self.available_options
[
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),
FastlaneCore::ConfigItem.new(key: :hide_error_when_versioning_disabled,
env_name: "FL_BUILD_NUMBER_HIDE_ERROR_WHEN_VERSIONING_DISABLED",
description: "Used during `fastlane init` to hide the error message",
default_value: false,
type: Boolean)
]
end
def self.output
[
['BUILD_NUMBER', 'The build number']
]
end
def self.authors
["Liquidsoul"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'build_number = get_build_number(xcodeproj: "Project.xcodeproj")'
]
end
def self.return_type
:string
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/update_urban_airship_configuration.rb | fastlane/lib/fastlane/actions/update_urban_airship_configuration.rb | module Fastlane
module Actions
class UpdateUrbanAirshipConfigurationAction < Action
def self.run(params)
require "plist"
begin
path = File.expand_path(params[:plist_path])
plist = Plist.parse_xml(path)
plist['developmentAppKey'] = params[:development_app_key] unless params[:development_app_key].nil?
plist['developmentAppSecret'] = params[:development_app_secret] unless params[:development_app_secret].nil?
plist['productionAppKey'] = params[:production_app_key] unless params[:production_app_key].nil?
plist['productionAppSecret'] = params[:production_app_secret] unless params[:production_app_secret].nil?
plist['detectProvisioningMode'] = params[:detect_provisioning_mode] unless params[:detect_provisioning_mode].nil?
new_plist = plist.to_plist
File.write(path, new_plist)
rescue => ex
UI.error(ex)
UI.error("Unable to update Urban Airship configuration for plist file at '#{path}'")
end
end
def self.description
"Set [Urban Airship](https://www.urbanairship.com/) plist configuration values"
end
def self.details
"This action updates the `AirshipConfig.plist` needed to configure the Urban Airship SDK at runtime, allowing keys and secrets to easily be set for the Enterprise and Production versions of the application."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :plist_path,
env_name: "URBAN_AIRSHIP_PLIST_PATH",
description: "Path to Urban Airship configuration Plist",
verify_block: proc do |value|
UI.user_error!("Could not find Urban Airship plist file") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :development_app_key,
optional: true,
env_name: "URBAN_AIRSHIP_DEVELOPMENT_APP_KEY",
sensitive: true,
description: "The development app key"),
FastlaneCore::ConfigItem.new(key: :development_app_secret,
optional: true,
env_name: "URBAN_AIRSHIP_DEVELOPMENT_APP_SECRET",
sensitive: true,
description: "The development app secret"),
FastlaneCore::ConfigItem.new(key: :production_app_key,
optional: true,
env_name: "URBAN_AIRSHIP_PRODUCTION_APP_KEY",
sensitive: true,
description: "The production app key"),
FastlaneCore::ConfigItem.new(key: :production_app_secret,
optional: true,
env_name: "URBAN_AIRSHIP_PRODUCTION_APP_SECRET",
sensitive: true,
description: "The production app secret"),
FastlaneCore::ConfigItem.new(key: :detect_provisioning_mode,
env_name: "URBAN_AIRSHIP_DETECT_PROVISIONING_MODE",
type: Boolean,
optional: true,
description: "Automatically detect provisioning mode")
]
end
def self.authors
["kcharwood"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'update_urban_airship_configuration(
plist_path: "AirshipConfig.plist",
production_app_key: "PRODKEY",
production_app_secret: "PRODSECRET"
)'
]
end
def self.category
:push
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/xcode_server_get_assets.rb | fastlane/lib/fastlane/actions/xcode_server_get_assets.rb | module Fastlane
module Actions
module SharedValues
XCODE_SERVER_GET_ASSETS_PATH = :XCODE_SERVER_GET_ASSETS_PATH
XCODE_SERVER_GET_ASSETS_ARCHIVE_PATH = :XCODE_SERVER_GET_ASSETS_ARCHIVE_PATH
end
class XcodeServerGetAssetsAction < Action
require 'excon'
require 'json'
require 'fileutils'
def self.run(params)
host = params[:host]
bot_name = params[:bot_name]
integration_number_override = params[:integration_number]
target_folder = params[:target_folder]
keep_all_assets = params[:keep_all_assets]
username = params[:username]
password = params[:password]
trust_self_signed_certs = params[:trust_self_signed_certs]
# setup (not)trusting self signed certificates.
# it's normal to have a self signed certificate on your Xcode Server
Excon.defaults[:ssl_verify_peer] = !trust_self_signed_certs # for self-signed certificates
# create Xcode Server config
xcs = XcodeServer.new(host, username, password)
bots = xcs.fetch_all_bots
UI.important("Fetched #{bots.count} Bots from Xcode Server at #{host}.")
# pull out names
bot_names = bots.map { |bot| bot['name'] }
# match the bot name with a found bot, otherwise fail
found_bots = bots.select { |bot| bot['name'] == bot_name }
UI.user_error!("Failed to find a Bot with name #{bot_name} on server #{host}, only available Bots: #{bot_names}") if found_bots.count == 0
bot = found_bots[0]
UI.success("Found Bot with name #{bot_name} with id #{bot['_id']}.")
# we have our bot, get finished integrations, sorted from newest to oldest
integrations = xcs.fetch_integrations(bot['_id']).select { |i| i['currentStep'] == 'completed' }
UI.user_error!("Failed to find any completed integration for Bot \"#{bot_name}\"") if (integrations || []).count == 0
# if no integration number is specified, pick the newest one (this is sorted from newest to oldest)
if integration_number_override
integration = integrations.find { |i| i['number'] == integration_number_override }
UI.user_error!("Specified integration number #{integration_number_override} does not exist.") unless integration
else
integration = integrations.first
end
# consider: only taking the last successful one? or allow failing tests? warnings?
UI.important("Using integration #{integration['number']}.")
# fetch assets for this integration
assets_path = xcs.fetch_assets(integration['_id'], target_folder, self)
UI.user_error!("Failed to fetch assets for integration #{integration['number']}.") unless assets_path
asset_entries = Dir.entries(assets_path).map { |i| File.join(assets_path, i) }
UI.success("Successfully downloaded #{asset_entries.count} assets to file #{assets_path}!")
# now find the archive and unzip it
zipped_archive_path = asset_entries.find { |i| i.end_with?('xcarchive.zip') }
if zipped_archive_path
UI.important("Found an archive in the assets folder...")
archive_file_path = File.basename(zipped_archive_path, File.extname(zipped_archive_path))
archive_dir_path = File.dirname(zipped_archive_path)
archive_path = File.join(archive_dir_path, archive_file_path)
if File.exist?(archive_path)
# we already have the archive, skip
UI.important("Archive #{archive_path} already exists, not unzipping again...")
else
# unzip the archive
sh("unzip -q \"#{zipped_archive_path}\" -d \"#{archive_dir_path}\"")
end
# reload asset entries to also contain the xcarchive file
asset_entries = Dir.entries(assets_path).map { |i| File.join(assets_path, i) }
# optionally delete everything except for the archive
unless keep_all_assets
files_to_delete = asset_entries.select do |i|
File.extname(i) != '.xcarchive' && ![".", ".."].include?(File.basename(i))
end
files_to_delete.each do |i|
FileUtils.rm_rf(i)
end
end
Actions.lane_context[SharedValues::XCODE_SERVER_GET_ASSETS_ARCHIVE_PATH] = archive_path
end
Actions.lane_context[SharedValues::XCODE_SERVER_GET_ASSETS_PATH] = assets_path
return assets_path
end
class XcodeServer
def initialize(host, username, password)
@host = host.start_with?('https://') ? host : "https://#{host}"
@username = username
@password = password
end
def fetch_all_bots
response = get_endpoint('/bots')
UI.user_error!("You are unauthorized to access data on #{@host}, please check that you're passing in a correct username and password.") if response.status == 401
UI.user_error!("Failed to fetch Bots from Xcode Server at #{@host}, response: #{response.status}: #{response.body}.") if response.status != 200
JSON.parse(response.body)['results']
end
def fetch_integrations(bot_id)
response = get_endpoint("/bots/#{bot_id}/integrations?last=10")
UI.user_error!("Failed to fetch Integrations for Bot #{bot_id} from Xcode Server at #{@host}, response: #{response.status}: #{response.body}") if response.status != 200
JSON.parse(response.body)['results']
end
def fetch_assets(integration_id, target_folder, action)
# create a temp folder and a file, stream the download into it
Dir.mktmpdir do |dir|
temp_file = File.join(dir, "tmp_download.#{rand(1_000_000)}")
f = open(temp_file, 'w')
streamer = lambda do |chunk, remaining_bytes, total_bytes|
if remaining_bytes && total_bytes
UI.important("Downloading: #{100 - (100 * remaining_bytes.to_f / total_bytes.to_f).to_i}%")
else
UI.error(chunk.to_s)
end
f.write(chunk)
end
response = self.get_endpoint("/integrations/#{integration_id}/assets", streamer)
f.close
UI.user_error!("Integration doesn't have any assets (it probably never ran).") if response.status == 500
UI.user_error!("Failed to fetch Assets zip for Integration #{integration_id} from Xcode Server at #{@host}, response: #{response.status}: #{response.body}") if response.status != 200
# unzip it, it's a .tar.gz file
out_folder = File.join(dir, "out_#{rand(1_000_000)}")
FileUtils.mkdir_p(out_folder)
action.sh("cd \"#{out_folder}\"; cat \"#{temp_file}\" | gzip -d | tar -x")
# then pull the real name from headers
asset_filename = response.headers['Content-Disposition'].split(';')[1].split('=')[1].delete('"')
asset_foldername = asset_filename.split('.')[0]
# rename the folder in out_folder to asset_foldername
found_folder = Dir.entries(out_folder).select { |item| item != '.' && item != '..' }[0]
UI.user_error!("Internal error, couldn't find unzipped folder") if found_folder.nil?
unzipped_folder_temp_name = File.join(out_folder, found_folder)
unzipped_folder = File.join(out_folder, asset_foldername)
# rename to destination name
FileUtils.mv(unzipped_folder_temp_name, unzipped_folder)
target_folder = File.absolute_path(target_folder)
# create target folder if it doesn't exist
FileUtils.mkdir_p(target_folder)
# and move+rename it to the destination place
FileUtils.cp_r(unzipped_folder, target_folder)
out = File.join(target_folder, asset_foldername)
return out
end
return nil
end
def headers
require 'base64'
headers = {
'User-Agent' => 'fastlane-xcode_server_get_assets', # XCS wants user agent. for some API calls. not for others. sigh.
'X-XCSAPIVersion' => 1 # XCS API version with this API, Xcode needs this otherwise it explodes in a 500 error fire. Currently Xcode 7 Beta 5 is on Version 5.
}
if @username && @password
userpass = "#{@username}:#{@password}"
headers['Authorization'] = "Basic #{Base64.strict_encode64(userpass)}"
end
return headers
end
def get_endpoint(endpoint, response_block = nil)
url = url_for_endpoint(endpoint)
headers = self.headers || {}
if response_block
response = Excon.get(url, response_block: response_block, headers: headers)
else
response = Excon.get(url, headers: headers)
end
return response
end
private
def url_for_endpoint(endpoint)
"#{@host}:20343/api#{endpoint}"
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Downloads Xcode Bot assets like the `.xcarchive` and logs"
end
def self.details
[
"This action downloads assets from your Xcode Server Bot (works with Xcode Server using Xcode 6 and 7. By default, this action downloads all assets, unzips them and deletes everything except for the `.xcarchive`.",
"If you'd like to keep all downloaded assets, pass `keep_all_assets: true`.",
"This action returns the path to the downloaded assets folder and puts into shared values the paths to the asset folder and to the `.xcarchive` inside it."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :host,
env_name: "FL_XCODE_SERVER_GET_ASSETS_HOST",
description: "IP Address/Hostname of Xcode Server",
optional: false),
FastlaneCore::ConfigItem.new(key: :bot_name,
env_name: "FL_XCODE_SERVER_GET_ASSETS_BOT_NAME",
description: "Name of the Bot to pull assets from",
optional: false),
FastlaneCore::ConfigItem.new(key: :integration_number,
env_name: "FL_XCODE_SERVER_GET_ASSETS_INTEGRATION_NUMBER",
description: "Optionally you can override which integration's assets should be downloaded. If not provided, the latest integration is used",
type: Integer,
optional: true),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FL_XCODE_SERVER_GET_ASSETS_USERNAME",
description: "Username for your Xcode Server",
optional: true,
default_value: ""),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_XCODE_SERVER_GET_ASSETS_PASSWORD",
description: "Password for your Xcode Server",
sensitive: true,
optional: true,
default_value: ""),
FastlaneCore::ConfigItem.new(key: :target_folder,
env_name: "FL_XCODE_SERVER_GET_ASSETS_TARGET_FOLDER",
description: "Relative path to a folder into which to download assets",
optional: true,
default_value: './xcs_assets'),
FastlaneCore::ConfigItem.new(key: :keep_all_assets,
env_name: "FL_XCODE_SERVER_GET_ASSETS_KEEP_ALL_ASSETS",
description: "Whether to keep all assets or let the script delete everything except for the .xcarchive",
optional: true,
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :trust_self_signed_certs,
env_name: "FL_XCODE_SERVER_GET_ASSETS_TRUST_SELF_SIGNED_CERTS",
description: "Whether to trust self-signed certs on your Xcode Server",
optional: true,
type: Boolean,
default_value: true)
]
end
def self.output
[
['XCODE_SERVER_GET_ASSETS_PATH', 'Absolute path to the downloaded assets folder'],
['XCODE_SERVER_GET_ASSETS_ARCHIVE_PATH', 'Absolute path to the downloaded xcarchive file']
]
end
def self.return_type
:array_of_strings
end
def self.authors
["czechboy0"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'xcode_server_get_assets(
host: "10.99.0.59", # Specify Xcode Server\'s Host or IP Address
bot_name: "release-1.3.4" # Specify the particular Bot
)'
]
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/gcovr.rb | fastlane/lib/fastlane/actions/gcovr.rb | module Fastlane
module Actions
# --object-directory=OBJDIR Specify the directory that contains the gcov data files.
# -o OUTPUT, --output=OUTPUT Print output to this filename Keep the temporary *.gcov files generated by gcov.
# -k, --keep Keep the temporary *.gcov files generated by gcov.
# -d, --delete Delete the coverage files after they are processed.
# -f FILTER, --filter=FILTER Keep only the data files that match this regular expression
# -e EXCLUDE, --exclude=EXCLUDE Exclude data files that match this regular expression
# --gcov-filter=GCOV_FILTER Keep only gcov data files that match this regular expression
# --gcov-exclude=GCOV_EXCLUDE Exclude gcov data files that match this regular expression
# -r ROOT, --root=ROOT Defines the root directory for source files.
# -x, --xml Generate XML instead of the normal tabular output.
# --xml-pretty Generate pretty XML instead of the normal dense format.
# --html Generate HTML instead of the normal tabular output.
# --html-details Generate HTML output for source file coverage.
# --html-absolute-paths Set the paths in the HTML report to be absolute instead of relative
# -b, --branches Tabulate the branch coverage instead of the line coverage.
# -u, --sort-uncovered Sort entries by increasing number of uncovered lines.
# -p, --sort-percentage Sort entries by decreasing percentage of covered lines.
# --gcov-executable=GCOV_CMD Defines the name/path to the gcov executable [defaults to the GCOV environment variable, if present; else 'gcov'].
# --exclude-unreachable-branches Exclude from coverage branches which are marked to be excluded by LCOV/GCOV markers or are determined to be from lines containing only compiler-generated "dead" code.
# -g, --use-gcov-files Use preprocessed gcov files for analysis.
# -s, --print-summary Prints a small report to stdout with line & branch percentage coverage
class GcovrAction < Action
ARGS_MAP = {
object_directory: "--object-directory",
output: "-o",
keep: "-k",
delete: "-d",
filter: "-f",
exclude: "-e",
gcov_filter: "--gcov-filter",
gcov_exclude: "--gcov-exclude",
root: "-r",
xml: "-x",
xml_pretty: "--xml-pretty",
html: "--html",
html_details: "--html-details",
html_absolute_paths: "--html-absolute-paths",
branches: "-b",
sort_uncovered: "-u",
sort_percentage: "-p",
gcov_executable: "--gcov-executable",
exclude_unreachable_branches: "--exclude-unreachable-branches",
use_gcov_files: "-g",
print_summary: "-s"
}
def self.is_supported?(platform)
platform == :ios
end
def self.run(params)
unless Helper.test?
UI.user_error!("gcovr not installed") if `which gcovr`.length == 0
end
# The args we will build with
gcovr_args = nil
# Allows for a whole variety of configurations
if params.kind_of?(Hash)
params_hash = params
# Check if an output path was given
if params_hash.key?(:output)
create_output_dir_if_not_exists(params_hash[:output])
end
# Maps parameter hash to CLI args
gcovr_args = params_hash_to_cli_args(params_hash)
else
gcovr_args = params
end
# Joins args into space delimited string
gcovr_args = gcovr_args.join(" ")
command = "gcovr #{gcovr_args}"
UI.success("Generating code coverage.")
UI.verbose(command)
Actions.sh(command)
end
def self.create_output_dir_if_not_exists(output_path)
output_dir = File.dirname(output_path)
# If the output directory doesn't exist, create it
unless Dir.exist?(output_dir)
FileUtils.mkpath(output_dir)
end
end
def self.params_hash_to_cli_args(params)
# Remove nil value params
params = params.delete_if { |_, v| v.nil? }
# Maps nice developer param names to CLI arguments
params.map do |k, v|
v ||= ""
args = ARGS_MAP[k]
if args
value = (v != true && v.to_s.length > 0 ? "\"#{v}\"" : "")
"#{args} #{value}".strip
end
end.compact
end
def self.description
"Runs test coverage reports for your Xcode project"
end
def self.available_options
[
['object_directory', 'Specify the directory that contains the gcov data files.'],
['output', 'Print output to this filename Keep the temporary *.gcov files generated by gcov.'],
['keep', 'Keep the temporary *.gcov files generated by gcov.'],
['delete', 'Delete the coverage files after they are processed.'],
['filter', 'Keep only the data files that match this regular expression'],
['exclude', 'Exclude data files that match this regular expression'],
['gcov_filter', 'Keep only gcov data files that match this regular expression'],
['gcov_exclude', 'Exclude gcov data files that match this regular expression'],
['root', 'Defines the root directory for source files.'],
['xml', 'Generate XML instead of the normal tabular output.'],
['xml_pretty', 'Generate pretty XML instead of the normal dense format.'],
['html', 'Generate HTML instead of the normal tabular output.'],
['html_details', 'Generate HTML output for source file coverage.'],
['html_absolute_paths', 'Set the paths in the HTML report to be absolute instead of relative'],
['branches', 'Tabulate the branch coverage instead of the line coverage.'],
['sort_uncovered', 'Sort entries by increasing number of uncovered lines.'],
['sort_percentage', 'Sort entries by decreasing percentage of covered lines.'],
['gcov_executable', 'Defines the name/path to the gcov executable].'],
['exclude_unreachable_branches', 'Exclude from coverage branches which are marked to be excluded by LCOV/GCOV markers'],
['use_gcov_files', 'Use preprocessed gcov files for analysis.'],
['print_summary', 'Prints a small report to stdout with line & branch percentage coverage']
]
end
def self.author
"dtrenz"
end
def self.example_code
[
'gcovr(
html: true,
html_details: true,
output: "./code-coverage/report.html"
)'
]
end
def self.details
"Generate summarized code coverage reports using [gcovr](http://gcovr.com/)"
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/hg_add_tag.rb | fastlane/lib/fastlane/actions/hg_add_tag.rb | module Fastlane
module Actions
# Adds a hg tag to the current commit
class HgAddTagAction < Action
def self.run(options)
tag = options[:tag]
UI.message("Adding mercurial tag '#{tag}' π―.")
command = "hg tag \"#{tag}\""
return command if Helper.test?
Actions.sh(command)
end
def self.description
"This will add a hg tag to the current branch"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :tag,
env_name: "FL_HG_TAG_TAG",
description: "Tag to create")
]
end
def self.author
# credits to lmirosevic for original git version
"sjrmanning"
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'hg_add_tag(tag: "1.3")'
]
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/verify_build.rb | fastlane/lib/fastlane/actions/verify_build.rb | require 'plist'
module Fastlane
module Actions
class VerifyBuildAction < Action
def self.run(params)
Dir.mktmpdir do |dir|
app_path = self.app_path(params, dir)
values = self.gather_cert_info(app_path)
values = self.update_with_profile_info(app_path, values)
self.print_values(values)
self.evaluate(params, values)
end
end
def self.app_path(params, dir)
build_path = params[:ipa_path] || params[:build_path] || Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] || ''
UI.user_error!("Unable to find file '#{build_path}'") unless File.exist?(build_path)
build_path = File.expand_path(build_path)
case File.extname(build_path)
when ".ipa", ".zip"
`unzip #{build_path.shellescape} -d #{dir.shellescape} -x '__MACOSX/*' '*.DS_Store' 2>&1`
UI.user_error!("Unable to unzip ipa") unless $? == 0
# Adding extra ** for edge-case ipas where Payload directory is nested.
app_path = Dir["#{dir}/**/Payload/*.app"].first
when ".xcarchive"
app_path = Dir["#{build_path}/Products/Applications/*.app"].first
else
app_path = build_path # Assume that input is an app file.
end
UI.user_error!("Unable to find app file") unless app_path && File.exist?(app_path)
app_path
end
def self.gather_cert_info(app_path)
cert_info = `codesign -vv -d #{app_path.shellescape} 2>&1`
UI.user_error!("Unable to verify code signing") unless $? == 0
values = {}
parts = cert_info.strip.split(/\r?\n/)
parts.each do |part|
if part =~ /\AAuthority=(iPhone|iOS|Apple)\s(Distribution|Development)/
type = part.split('=')[1].split(':')[0]
values['provisioning_type'] = type.downcase =~ /distribution/i ? "distribution" : "development"
end
if part.start_with?("Authority")
values['authority'] ||= []
values['authority'] << part.split('=')[1]
end
if part.start_with?("TeamIdentifier")
values['team_identifier'] = part.split('=')[1]
end
if part.start_with?("Identifier")
values['bundle_identifier'] = part.split('=')[1]
end
end
values
end
def self.update_with_profile_info(app_path, values)
provision_profile_path = "#{app_path}/embedded.mobileprovision"
UI.user_error!("Unable to find embedded profile in #{provision_profile_path}") unless File.exist?(provision_profile_path)
profile = `cat #{provision_profile_path.shellescape} | security cms -D`
UI.user_error!("Unable to extract profile") unless $? == 0
plist = Plist.parse_xml(profile)
values['app_name'] = plist['AppIDName']
values['provisioning_uuid'] = plist['UUID']
values['team_name'] = plist['TeamName']
values['team_identifier'] = plist['TeamIdentifier'].first
application_identifier_prefix = plist['ApplicationIdentifierPrefix'][0]
full_bundle_identifier = "#{application_identifier_prefix}.#{values['bundle_identifier']}"
UI.user_error!("Inconsistent identifier found; #{plist['Entitlements']['application-identifier']}, found in the embedded.mobileprovision file, should match #{full_bundle_identifier}, which is embedded in the codesign identity") unless plist['Entitlements']['application-identifier'] == full_bundle_identifier
UI.user_error!("Inconsistent identifier found") unless plist['Entitlements']['com.apple.developer.team-identifier'] == values['team_identifier']
values
end
def self.print_values(values)
FastlaneCore::PrintTable.print_values(config: values,
title: "Summary for verify_build #{Fastlane::VERSION}")
end
def self.evaluate(params, values)
if params[:provisioning_type]
UI.user_error!("Mismatched provisioning_type. Required: '#{params[:provisioning_type]}'; Found: '#{values['provisioning_type']}'") unless params[:provisioning_type] == values['provisioning_type']
end
if params[:provisioning_uuid]
UI.user_error!("Mismatched provisioning_uuid. Required: '#{params[:provisioning_uuid]}'; Found: '#{values['provisioning_uuid']}'") unless params[:provisioning_uuid] == values['provisioning_uuid']
end
if params[:team_identifier]
UI.user_error!("Mismatched team_identifier. Required: '#{params[:team_identifier]}'; Found: '#{values['team_identifier']}'") unless params[:team_identifier] == values['team_identifier']
end
if params[:team_name]
UI.user_error!("Mismatched team_name. Required: '#{params[:team_name]}'; Found: '#{values['team_name']}'") unless params[:team_name] == values['team_name']
end
if params[:app_name]
UI.user_error!("Mismatched app_name. Required: '#{params[:app_name]}'; Found: '#{values['app_name']}'") unless params[:app_name] == values['app_name']
end
if params[:bundle_identifier]
UI.user_error!("Mismatched bundle_identifier. Required: '#{params[:bundle_identifier]}'; Found: '#{values['bundle_identifier']}'") unless params[:bundle_identifier] == values['bundle_identifier']
end
UI.success("Build is verified, have a πͺ.")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Able to verify various settings in ipa file"
end
def self.details
"Verifies that the built app was built using the expected build resources. This is relevant for people who build on machines that are used to build apps with different profiles, certificates and/or bundle identifiers to guard against configuration mistakes."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :provisioning_type,
env_name: "FL_VERIFY_BUILD_PROVISIONING_TYPE",
description: "Required type of provisioning",
optional: true,
verify_block: proc do |value|
av = %w(distribution development)
UI.user_error!("Unsupported provisioning_type, must be: #{av}") unless av.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :provisioning_uuid,
env_name: "FL_VERIFY_BUILD_PROVISIONING_UUID",
description: "Required UUID of provisioning profile",
optional: true),
FastlaneCore::ConfigItem.new(key: :team_identifier,
env_name: "FL_VERIFY_BUILD_TEAM_IDENTIFIER",
description: "Required team identifier",
optional: true),
FastlaneCore::ConfigItem.new(key: :team_name,
env_name: "FL_VERIFY_BUILD_TEAM_NAME",
description: "Required team name",
optional: true),
FastlaneCore::ConfigItem.new(key: :app_name,
env_name: "FL_VERIFY_BUILD_APP_NAME",
description: "Required app name",
optional: true),
FastlaneCore::ConfigItem.new(key: :bundle_identifier,
env_name: "FL_VERIFY_BUILD_BUNDLE_IDENTIFIER",
description: "Required bundle identifier",
optional: true),
FastlaneCore::ConfigItem.new(key: :ipa_path,
env_name: "FL_VERIFY_BUILD_IPA_PATH",
description: "Explicitly set the ipa path",
conflicting_options: [:build_path],
optional: true),
FastlaneCore::ConfigItem.new(key: :build_path,
env_name: "FL_VERIFY_BUILD_BUILD_PATH",
description: "Explicitly set the ipa, app or xcarchive path",
conflicting_options: [:ipa_path],
optional: true)
]
end
def self.output
end
def self.return_value
end
def self.authors
["CodeReaper"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'verify_build(
provisioning_type: "distribution",
bundle_identifier: "com.example.myapp"
)'
]
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_fastlane.rb | fastlane/lib/fastlane/actions/update_fastlane.rb | require 'rubygems/spec_fetcher'
require 'rubygems/command_manager'
module Fastlane
module Actions
# Makes sure fastlane tools are up-to-date when running fastlane
class UpdateFastlaneAction < Action
ALL_TOOLS = ["fastlane"]
def self.run(options)
return if options[:no_update] # this is used to update itself
tools_to_update = ALL_TOOLS
UI.message("Looking for updates for #{tools_to_update.join(', ')}...")
updater = Gem::CommandManager.instance[:update]
cleaner = Gem::CommandManager.instance[:cleanup]
gem_dir = ENV['GEM_HOME'] || Gem.dir
sudo_needed = !File.writable?(gem_dir)
if sudo_needed
UI.important("It seems that your Gem directory is not writable by your current user.")
UI.important("fastlane would need sudo rights to update itself, however, running 'sudo fastlane' is not recommended.")
UI.important("If you still want to use this action, please read the documentation on how to set this up:")
UI.important("https://docs.fastlane.tools/actions/update_fastlane/")
return
end
unless updater.respond_to?(:highest_installed_gems)
UI.important("The update_fastlane action requires rubygems version 2.1.0 or greater.")
UI.important("Please update your version of ruby gems before proceeding.")
UI.command "gem install rubygems-update"
UI.command "update_rubygems"
UI.command "gem update --system"
return
end
highest_versions = updater.highest_installed_gems.keep_if { |key| tools_to_update.include?(key) }
update_needed = updater.which_to_update(highest_versions, tools_to_update)
if update_needed.count == 0
UI.success("Nothing to update β
")
return
end
# suppress updater output - very noisy
Gem::DefaultUserInteraction.ui = Gem::SilentUI.new unless FastlaneCore::Globals.verbose?
update_needed.each do |tool_info|
tool = self.get_gem_name(tool_info)
local_version = Gem::Version.new(highest_versions[tool].version)
latest_official_version = FastlaneCore::UpdateChecker.fetch_latest(tool)
UI.message("Updating #{tool} from #{local_version.to_s.yellow} to #{latest_official_version.to_s.yellow}... π")
if Helper.homebrew?
Helper.backticks('brew upgrade fastlane')
else
# Approximate_recommendation will create a string like "~> 0.10" from a version 0.10.0, e.g. one that is valid for versions >= 0.10 and <1.0
requirement_version = local_version.approximate_recommendation
updater.update_gem(tool, Gem::Requirement.new(requirement_version))
end
UI.success("Finished updating #{tool}")
end
unless Helper.homebrew?
UI.message("Cleaning up old versions...")
cleaner.options[:args] = tools_to_update
cleaner.execute
end
if FastlaneCore::FastlaneFolder.swift?
upgrader = SwiftRunnerUpgrader.new
upgrader.upgrade_if_needed!
end
UI.message("fastlane.tools successfully updated! I will now restart myself... π΄")
# Set no_update to true so we don't try to update again
exec("FL_NO_UPDATE=true #{$PROGRAM_NAME} #{ARGV.join(' ')}")
end
def self.get_gem_name(tool_info)
if tool_info.kind_of?(Array)
return tool_info[0]
elsif tool_info.respond_to?(:name) # Gem::NameTuple in RubyGems >= 3.1.0
return tool_info.name
else
UI.crash!("Unknown gem update information returned from RubyGems. Please file a new issue for this... π€·")
end
end
def self.description
"Makes sure fastlane-tools are up-to-date when running fastlane"
end
def self.details
sample = <<-SAMPLE.markdown_sample
```bash
export GEM_HOME=~/.gems
export PATH=$PATH:~/.gems/bin
```
SAMPLE
[
"This action will update fastlane to the most recent version - major version updates will not be performed automatically, as they might include breaking changes. If an update was performed, fastlane will be restarted before the run continues.",
"",
"If you are using rbenv or rvm, everything should be good to go. However, if you are using the system's default ruby, some additional setup is needed for this action to work correctly. In short, fastlane needs to be able to access your gem library without running in `sudo` mode.",
"",
"The simplest possible fix for this is putting the following lines into your `~/.bashrc` or `~/.zshrc` file:".markdown_preserve_newlines,
sample,
"After the above changes, restart your terminal, then run `mkdir $GEM_HOME` to create the new gem directory. After this, you're good to go!",
"",
"Recommended usage of the `update_fastlane` action is at the top inside of the `before_all` block, before running any other action."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :no_update,
env_name: "FL_NO_UPDATE",
description: "Don't update during this run. This is used internally",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :nightly,
env_name: "FL_UPDATE_FASTLANE_NIGHTLY",
description: "Opt-in to install and use nightly fastlane builds",
type: Boolean,
default_value: false,
deprecated: "Nightly builds are no longer being made available")
]
end
def self.authors
["milch", "KrauseFx"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'before_all do
update_fastlane
# ...
end'
]
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/get_info_plist_value.rb | fastlane/lib/fastlane/actions/get_info_plist_value.rb | module Fastlane
module Actions
module SharedValues
GET_INFO_PLIST_VALUE_CUSTOM_VALUE = :GET_INFO_PLIST_VALUE_CUSTOM_VALUE
end
class GetInfoPlistValueAction < Action
def self.run(params)
require "plist"
begin
path = File.expand_path(params[:path])
plist = File.open(path) { |f| Plist.parse_xml(f) }
value = plist[params[:key]]
Actions.lane_context[SharedValues::GET_INFO_PLIST_VALUE_CUSTOM_VALUE] = value
return value
rescue => ex
UI.error(ex)
end
end
def self.description
"Returns value from Info.plist of your project as native Ruby data structures"
end
def self.details
"Get a value from a plist file, which can be used to fetch the app identifier and more information about your app"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :key,
env_name: "FL_GET_INFO_PLIST_PARAM_NAME",
description: "Name of parameter",
optional: false),
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_GET_INFO_PLIST_PATH",
description: "Path to plist file you want to read",
optional: false,
verify_block: proc do |value|
UI.user_error!("Couldn't find plist file at path '#{value}'") unless File.exist?(value)
end)
]
end
def self.output
[
['GET_INFO_PLIST_VALUE_CUSTOM_VALUE', 'The value of the last plist file that was parsed']
]
end
def self.authors
["kohtenko"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'identifier = get_info_plist_value(path: "./Info.plist", key: "CFBundleIdentifier")'
]
end
def self.return_type
:string
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/installr.rb | fastlane/lib/fastlane/actions/installr.rb | module Fastlane
module Actions
module SharedValues
INSTALLR_BUILD_INFORMATION = :INSTALLR_BUILD_INFORMATION
end
class InstallrAction < Action
INSTALLR_API = "https://www.installrapp.com/apps.json"
def self.run(params)
UI.success('Upload to Installr has been started. This may take some time.')
response = self.upload_build(params)
case response.status
when 200...300
Actions.lane_context[SharedValues::INSTALLR_BUILD_INFORMATION] = response.body
UI.success('Build successfully uploaded to Installr!')
else
UI.user_error!("Error when trying to upload build file to Installr: #{response.body}")
end
end
def self.upload_build(params)
require 'faraday'
require 'faraday_middleware'
url = INSTALLR_API
connection = Faraday.new(url) do |builder|
builder.request(:multipart)
builder.request(:url_encoded)
builder.response(:json, content_type: /\bjson$/)
builder.use(FaradayMiddleware::FollowRedirects)
builder.adapter(:net_http)
end
options = {}
options[:qqfile] = Faraday::UploadIO.new(params[:ipa], 'application/octet-stream')
if params[:notes]
options[:releaseNotes] = params[:notes]
end
if params[:notify]
options[:notify] = params[:notify]
end
if params[:add]
options[:add] = params[:add]
end
post_request = connection.post do |req|
req.headers['X-InstallrAppToken'] = params[:api_token]
req.body = options
end
post_request.on_complete do |env|
yield(env[:status], env[:body]) if block_given?
end
end
def self.description
"Upload a new build to [Installr](http://installrapp.com/)"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :api_token,
env_name: "INSTALLR_API_TOKEN",
sensitive: true,
description: "API Token for Installr Access",
verify_block: proc do |value|
UI.user_error!("No API token for Installr given, pass using `api_token: 'token'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :ipa,
env_name: "INSTALLR_IPA_PATH",
description: "Path to your IPA file. Optional if you use the _gym_ or _xcodebuild_ action",
default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Couldn't find build file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :notes,
env_name: "INSTALLR_NOTES",
description: "Release notes",
optional: true),
FastlaneCore::ConfigItem.new(key: :notify,
env_name: "INSTALLR_NOTIFY",
description: "Groups to notify (e.g. 'dev,qa')",
optional: true),
FastlaneCore::ConfigItem.new(key: :add,
env_name: "INSTALLR_ADD",
description: "Groups to add (e.g. 'exec,ops')",
optional: true)
]
end
def self.output
[
['INSTALLR_BUILD_INFORMATION', 'Contains release info like :appData. See http://help.installrapp.com/api/']
]
end
def self.authors
["scottrhoyt"]
end
def self.is_supported?(platform)
[:ios].include?(platform)
end
def self.example_code
[
'installr(
api_token: "...",
ipa: "test.ipa",
notes: "The next great version of the app!",
notify: "dev,qa",
add: "exec,ops"
)'
]
end
def self.category
:beta
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/last_git_tag.rb | fastlane/lib/fastlane/actions/last_git_tag.rb | module Fastlane
module Actions
class LastGitTagAction < Action
def self.run(params)
Actions.last_git_tag_name(true, params[:pattern])
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Get the most recent git tag"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :pattern,
description: "Pattern to filter tags when looking for last one. Limit tags to ones matching given shell glob. If pattern lacks ?, *, or [, * at the end is implied",
default_value: nil,
optional: true)
]
end
def self.output
[]
end
def self.return_type
:string
end
def self.authors
["KrauseFx", "wedkarz"]
end
def self.is_supported?(platform)
true
end
def self.details
[
"If you are using this action on a **shallow clone**, *the default with some CI systems like Bamboo*, you need to ensure that you have also pulled all the git tags appropriately. Assuming your git repo has the correct remote set you can issue `sh('git fetch --tags')`.",
"Pattern parameter allows you to filter to a subset of tags."
].join("\n")
end
def self.example_code
[
'last_git_tag',
'last_git_tag(pattern: "release/v1.0/")'
]
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/appledoc.rb | fastlane/lib/fastlane/actions/appledoc.rb | module Fastlane
module Actions
module SharedValues
APPLEDOC_DOCUMENTATION_OUTPUT = :APPLEDOC_DOCUMENTATION_OUTPUT
end
class AppledocAction < Action
ARGS_MAP = {
input: "",
output: "--output",
templates: "--templates",
docset_install_path: "--docset-install-path",
include: "--include",
ignore: "--ignore",
exclude_output: "--exclude-output",
index_desc: "--index-desc",
project_name: "--project-name",
project_version: "--project-version",
project_company: "--project-company",
company_id: "--company-id",
create_html: "--create-html",
create_docset: "--create-docset",
install_docset: "--install-docset",
publish_docset: "--publish-docset",
no_create_docset: "--no-create-docset",
html_anchors: "--html-anchors",
clean_output: "--clean-output",
docset_bundle_id: "--docset-bundle-id",
docset_bundle_name: "--docset-bundle-name",
docset_desc: "--docset-desc",
docset_copyright: "--docset-copyright",
docset_feed_name: "--docset-feed-name",
docset_feed_url: "--docset-feed-url",
docset_feed_formats: "--docset-feed-formats",
docset_package_url: "--docset-package-url",
docset_fallback_url: "--docset-fallback-url",
docset_publisher_id: "--docset-publisher-id",
docset_publisher_name: "--docset-publisher-name",
docset_min_xcode_version: "--docset-min-xcode-version",
docset_platform_family: "--docset-platform-family",
docset_cert_issuer: "--docset-cert-issuer",
docset_cert_signer: "--docset-cert-signer",
docset_bundle_filename: "--docset-bundle-filename",
docset_atom_filename: "--docset-atom-filename",
docset_xml_filename: "--docset-xml-filename",
docset_package_filename: "--docset-package-filename",
options: "",
crossref_format: "--crossref-format",
exit_threshold: "--exit-threshold",
docs_section_title: "--docs-section-title",
warnings: "",
logformat: "--logformat",
verbose: "--verbose"
}
def self.run(params)
unless Helper.test?
UI.message("Install using `brew install appledoc`")
UI.user_error!("appledoc not installed") if `which appledoc`.length == 0
end
params_hash = params.values
# Check if an output path was given
if params_hash[:output]
Actions.lane_context[SharedValues::APPLEDOC_DOCUMENTATION_OUTPUT] = File.expand_path(params_hash[:output])
create_output_dir_if_not_exists(params_hash[:output])
end
# Maps parameter hash to CLI args
appledoc_args = params_hash_to_cli_args(params_hash)
UI.success("Generating documentation.")
cli_args = appledoc_args.join(' ')
input_cli_arg = Array(params_hash[:input]).map(&:shellescape).join(' ')
command = "appledoc #{cli_args}".strip + " " + input_cli_arg
UI.verbose(command)
Actions.sh(command)
end
def self.params_hash_to_cli_args(params)
# Remove nil and false value params
params = params.delete_if { |_, v| v.nil? || v == false }
cli_args = []
params.each do |key, value|
args = ARGS_MAP[key]
if args.empty?
if key != :input
cli_args << value
end
elsif value.kind_of?(Array)
value.each do |v|
cli_args << cli_param(args, v)
end
else
cli_args << cli_param(args, value)
end
end
return cli_args
end
def self.cli_param(k, v)
value = (v != true && v.to_s.length > 0 ? "\"#{v}\"" : "")
"#{k} #{value}".strip
end
def self.create_output_dir_if_not_exists(output_path)
output_dir = File.dirname(output_path)
# If the output directory doesn't exist, create it
unless Dir.exist?(output_dir)
FileUtils.mkpath(output_dir)
end
end
def self.description
"Generate Apple-like source code documentation from the source code"
end
def self.details
"Runs `appledoc [OPTIONS] <paths to source dirs or files>` for the project"
end
def self.available_options
[
# PATHS
FastlaneCore::ConfigItem.new(key: :input, env_name: "FL_APPLEDOC_INPUT", description: "Path(s) to source file directories or individual source files. Accepts a single path or an array of paths", type: Array),
FastlaneCore::ConfigItem.new(key: :output, env_name: "FL_APPLEDOC_OUTPUT", description: "Output path", optional: true),
FastlaneCore::ConfigItem.new(key: :templates, env_name: "FL_APPLEDOC_TEMPLATES", description: "Template files path", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_install_path, env_name: "FL_APPLEDOC_DOCSET_INSTALL_PATH", description: "DocSet installation path", optional: true),
FastlaneCore::ConfigItem.new(key: :include, env_name: "FL_APPLEDOC_INCLUDE", description: "Include static doc(s) at path", optional: true),
FastlaneCore::ConfigItem.new(key: :ignore, env_name: "FL_APPLEDOC_IGNORE", description: "Ignore given path", type: Array, optional: true),
FastlaneCore::ConfigItem.new(key: :exclude_output, env_name: "FL_APPLEDOC_EXCLUDE_OUTPUT", description: "Exclude given path from output", type: Array, optional: true),
FastlaneCore::ConfigItem.new(key: :index_desc, env_name: "FL_APPLEDOC_INDEX_DESC", description: "File including main index description", optional: true),
# PROJECT INFO
FastlaneCore::ConfigItem.new(key: :project_name, env_name: "FL_APPLEDOC_PROJECT_NAME", description: "Project name"),
FastlaneCore::ConfigItem.new(key: :project_version, env_name: "FL_APPLEDOC_PROJECT_VERSION", description: "Project version", optional: true),
FastlaneCore::ConfigItem.new(key: :project_company, env_name: "FL_APPLEDOC_PROJECT_COMPANY", description: "Project company"),
FastlaneCore::ConfigItem.new(key: :company_id, env_name: "FL_APPLEDOC_COMPANY_ID", description: "Company UTI (i.e. reverse DNS name)", optional: true),
# OUTPUT GENERATION
FastlaneCore::ConfigItem.new(key: :create_html, env_name: "FL_APPLEDOC_CREATE_HTML", description: "Create HTML", type: Boolean, default_value: false),
FastlaneCore::ConfigItem.new(key: :create_docset, env_name: "FL_APPLEDOC_CREATE_DOCSET", description: "Create documentation set", type: Boolean, default_value: false),
FastlaneCore::ConfigItem.new(key: :install_docset, env_name: "FL_APPLEDOC_INSTALL_DOCSET", description: "Install documentation set to Xcode", type: Boolean, default_value: false),
FastlaneCore::ConfigItem.new(key: :publish_docset, env_name: "FL_APPLEDOC_PUBLISH_DOCSET", description: "Prepare DocSet for publishing", type: Boolean, default_value: false),
FastlaneCore::ConfigItem.new(key: :no_create_docset, env_name: "FL_APPLEDOC_NO_CREATE_DOCSET", description: "Create HTML and skip creating a DocSet", type: Boolean, default_value: false),
FastlaneCore::ConfigItem.new(key: :html_anchors, env_name: "FL_APPLEDOC_HTML_ANCHORS", description: "The html anchor format to use in DocSet HTML", optional: true),
FastlaneCore::ConfigItem.new(key: :clean_output, env_name: "FL_APPLEDOC_CLEAN_OUTPUT", description: "Remove contents of output path before starting", type: Boolean, default_value: false),
# DOCUMENTATION SET INFO
FastlaneCore::ConfigItem.new(key: :docset_bundle_id, env_name: "FL_APPLEDOC_DOCSET_BUNDLE_ID", description: "DocSet bundle identifier", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_bundle_name, env_name: "FL_APPLEDOC_DOCSET_BUNDLE_NAME", description: "DocSet bundle name", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_desc, env_name: "FL_APPLEDOC_DOCSET_DESC", description: "DocSet description", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_copyright, env_name: "FL_APPLEDOC_DOCSET_COPYRIGHT", description: "DocSet copyright message", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_feed_name, env_name: "FL_APPLEDOC_DOCSET_FEED_NAME", description: "DocSet feed name", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_feed_url, env_name: "FL_APPLEDOC_DOCSET_FEED_URL", description: "DocSet feed URL", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_feed_formats, env_name: "FL_APPLEDOC_DOCSET_FEED_FORMATS", description: "DocSet feed formats. Separated by a comma [atom,xml]", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_package_url, env_name: "FL_APPLEDOC_DOCSET_PACKAGE_URL", description: "DocSet package (.xar) URL", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_fallback_url, env_name: "FL_APPLEDOC_DOCSET_FALLBACK_URL", description: "DocSet fallback URL", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_publisher_id, env_name: "FL_APPLEDOC_DOCSET_PUBLISHER_ID", description: "DocSet publisher identifier", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_publisher_name, env_name: "FL_APPLEDOC_DOCSET_PUBLISHER_NAME", description: "DocSet publisher name", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_min_xcode_version, env_name: "FL_APPLEDOC_DOCSET_MIN_XCODE_VERSION", description: "DocSet min. Xcode version", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_platform_family, env_name: "FL_APPLEDOC_DOCSET_PLATFORM_FAMILY", description: "DocSet platform family", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_cert_issuer, env_name: "FL_APPLEDOC_DOCSET_CERT_ISSUER", description: "DocSet certificate issuer", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_cert_signer, env_name: "FL_APPLEDOC_DOCSET_CERT_SIGNER", description: "DocSet certificate signer", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_bundle_filename, env_name: "FL_APPLEDOC_DOCSET_BUNDLE_FILENAME", description: "DocSet bundle filename", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_atom_filename, env_name: "FL_APPLEDOC_DOCSET_ATOM_FILENAME", description: "DocSet atom feed filename", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_xml_filename, env_name: "FL_APPLEDOC_DOCSET_XML_FILENAME", description: "DocSet xml feed filename", optional: true),
FastlaneCore::ConfigItem.new(key: :docset_package_filename, env_name: "FL_APPLEDOC_DOCSET_PACKAGE_FILENAME", description: "DocSet package (.xar,.tgz) filename", optional: true),
# OPTIONS
FastlaneCore::ConfigItem.new(key: :options, env_name: "FL_APPLEDOC_OPTIONS", description: "Documentation generation options", optional: true),
FastlaneCore::ConfigItem.new(key: :crossref_format, env_name: "FL_APPLEDOC_OPTIONS_CROSSREF_FORMAT", description: "Cross reference template regex", optional: true),
FastlaneCore::ConfigItem.new(key: :exit_threshold, env_name: "FL_APPLEDOC_OPTIONS_EXIT_THRESHOLD", description: "Exit code threshold below which 0 is returned", type: Integer, default_value: 2, optional: true),
FastlaneCore::ConfigItem.new(key: :docs_section_title, env_name: "FL_APPLEDOC_OPTIONS_DOCS_SECTION_TITLE", description: "Title of the documentation section (defaults to \"Programming Guides\"", optional: true),
# WARNINGS
FastlaneCore::ConfigItem.new(key: :warnings, env_name: "FL_APPLEDOC_WARNINGS", description: "Documentation generation warnings", optional: true),
# MISCELLANEOUS
FastlaneCore::ConfigItem.new(key: :logformat, env_name: "FL_APPLEDOC_LOGFORMAT", description: "Log format [0-3]", type: Integer, optional: true),
FastlaneCore::ConfigItem.new(key: :verbose, env_name: "FL_APPLEDOC_VERBOSE", description: "Log verbosity level [0-6,xcode]", skip_type_validation: true, optional: true) # allow Integer, String
]
end
def self.output
[
['APPLEDOC_DOCUMENTATION_OUTPUT', 'Documentation set output path']
]
end
def self.authors
["alexmx"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.category
:documentation
end
def self.example_code
[
'appledoc(
project_name: "MyProjectName",
project_company: "Company Name",
input: [
"MyProjectSources",
"MyProjectSourceFile.h"
],
ignore: [
"ignore/path/1",
"ignore/path/2"
],
options: "--keep-intermediate-files --search-undocumented-doc",
warnings: "--warn-missing-output-path --warn-missing-company-id"
)'
]
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_project_code_signing.rb | fastlane/lib/fastlane/actions/update_project_code_signing.rb | module Fastlane
module Actions
module SharedValues
end
class UpdateProjectCodeSigningAction < Action
def self.run(params)
UI.message("You shouldn't use update_project_code_signing")
UI.message("Have you considered using the recommended way to do code signing?")
UI.message("https://docs.fastlane.tools/codesigning/getting-started/")
path = params[:path]
path = File.join(path, "project.pbxproj")
UI.user_error!("Could not find path to project config '#{path}'. Pass the path to your project (not workspace)!") unless File.exist?(path)
uuid = params[:uuid] || params[:udid]
UI.message("Updating provisioning profile UUID (#{uuid}) for the given project '#{path}'")
p = File.read(path)
File.write(path, p.gsub(/PROVISIONING_PROFILE = ".*";/, "PROVISIONING_PROFILE = \"#{uuid}\";"))
UI.success("Successfully updated project settings to use UUID '#{uuid}'")
end
def self.description
"Updated code signing settings from 'Automatic' to a specific profile"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_PROJECT_SIGNING_PROJECT_PATH",
description: "Path to your Xcode project",
verify_block: proc do |value|
UI.user_error!("Path is invalid") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :udid,
deprecated: "Use `:uuid` instead",
env_name: "FL_PROJECT_SIGNING_UDID",
code_gen_sensitive: true,
default_value: ENV["SIGH_UUID"],
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :uuid,
env_name: "FL_PROJECT_SIGNING_UUID",
description: "The UUID of the provisioning profile you want to use",
code_gen_sensitive: true,
default_value: ENV["SIGH_UUID"],
default_value_dynamic: true)
]
end
def self.author
"KrauseFx"
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
nil
end
def self.category
:deprecated
end
def self.deprecated_notes
[
"You shouldn't use `update_project_code_signing`.",
"Have you considered using the recommended way to do code signing: [https://docs.fastlane.tools/codesigning/getting-started/](https://docs.fastlane.tools/codesigning/getting-started/)?"
].join("\n")
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/oclint.rb | fastlane/lib/fastlane/actions/oclint.rb | module Fastlane
module Actions
module SharedValues
FL_OCLINT_REPORT_PATH = :FL_OCLINT_REPORT_PATH
end
class OclintAction < Action
# rubocop:disable Metrics/PerceivedComplexity
def self.run(params)
oclint_path = params[:oclint_path]
if `which #{oclint_path}`.to_s.empty? && !Helper.test?
UI.user_error!("You have to install oclint or provide path to oclint binary. Fore more details: ") + "http://docs.oclint.org/en/stable/intro/installation.html".yellow
end
compile_commands = params[:compile_commands]
compile_commands_dir = params[:compile_commands]
UI.user_error!("Could not find json compilation database at path '#{compile_commands}'") unless File.exist?(compile_commands)
# We'll attempt to sort things out so that we support receiving either a path to a
# 'compile_commands.json' file (as our option asks for), or a path to a directory
# *containing* a 'compile_commands.json' file (as oclint actually wants)
if File.file?(compile_commands_dir)
compile_commands_dir = File.dirname(compile_commands_dir)
else
compile_commands = File.join(compile_commands_dir, 'compile_commands.json')
end
if params[:select_reqex]
UI.important("'select_reqex' parameter is deprecated. Please use 'select_regex' instead.")
select_regex = params[:select_reqex]
end
select_regex = params[:select_regex] if params[:select_regex] # Overwrite deprecated select_reqex
select_regex = ensure_regex_is_not_string!(select_regex)
exclude_regex = params[:exclude_regex]
exclude_regex = ensure_regex_is_not_string!(exclude_regex)
files = JSON.parse(File.read(compile_commands)).map do |compile_command|
file = compile_command['file']
File.exist?(file) ? file : File.join(compile_command['directory'], file)
end
files.uniq!
files.select! do |file|
file_ruby = file.gsub('\ ', ' ')
File.exist?(file_ruby) and
(!select_regex or file_ruby =~ select_regex) and
(!exclude_regex or file_ruby !~ exclude_regex)
end
command_prefix = [
'cd',
File.expand_path('.').shellescape,
'&&'
].join(' ')
report_type = params[:report_type]
report_path = params[:report_path] ? params[:report_path] : 'oclint_report.' + report_type
oclint_args = ["-report-type=#{report_type}", "-o=#{report_path}"]
oclint_args << "-list-enabled-rules" if params[:list_enabled_rules]
if params[:rc]
UI.important("It's recommended to use 'thresholds' instead of deprecated 'rc' parameter")
oclint_args << "-rc=#{params[:rc]}" if params[:rc] # Deprecated
end
oclint_args << ensure_array_is_not_string!(params[:thresholds]).map { |t| "-rc=#{t}" } if params[:thresholds]
# Escape ' in rule names with \' when passing on to shell command
oclint_args << params[:enable_rules].map { |r| "-rule #{r.shellescape}" } if params[:enable_rules]
oclint_args << params[:disable_rules].map { |r| "-disable-rule #{r.shellescape}" } if params[:disable_rules]
oclint_args << "-max-priority-1=#{params[:max_priority_1]}" if params[:max_priority_1]
oclint_args << "-max-priority-2=#{params[:max_priority_2]}" if params[:max_priority_2]
oclint_args << "-max-priority-3=#{params[:max_priority_3]}" if params[:max_priority_3]
oclint_args << "-enable-clang-static-analyzer" if params[:enable_clang_static_analyzer]
oclint_args << "-enable-global-analysis" if params[:enable_global_analysis]
oclint_args << "-allow-duplicated-violations" if params[:allow_duplicated_violations]
oclint_args << "-p #{compile_commands_dir.shellescape}"
oclint_args << "-extra-arg=#{params[:extra_arg]}" if params[:extra_arg]
command = [
command_prefix,
oclint_path,
oclint_args,
'"' + files.join('" "') + '"'
].join(' ')
Actions.lane_context[SharedValues::FL_OCLINT_REPORT_PATH] = File.expand_path(report_path)
return Action.sh(command)
end
# return a proper regex object if regex string is single-quoted
def self.ensure_regex_is_not_string!(regex)
return regex unless regex.kind_of?(String)
Regexp.new(regex)
end
# return a proper array of strings if array string is single-quoted
def self.ensure_array_is_not_string!(array)
return array unless array.kind_of?(String)
array.split(',')
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Lints implementation files with OCLint"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :oclint_path,
env_name: 'FL_OCLINT_PATH',
description: 'The path to oclint binary',
default_value: 'oclint',
optional: true),
FastlaneCore::ConfigItem.new(key: :compile_commands,
env_name: 'FL_OCLINT_COMPILE_COMMANDS',
description: 'The json compilation database, use xctool reporter \'json-compilation-database\'',
default_value: 'compile_commands.json',
optional: true),
FastlaneCore::ConfigItem.new(key: :select_reqex,
env_name: 'FL_OCLINT_SELECT_REQEX',
description: 'Select all files matching this reqex',
skip_type_validation: true, # allows Regex
deprecated: "Use `:select_regex` instead",
optional: true),
FastlaneCore::ConfigItem.new(key: :select_regex,
env_name: 'FL_OCLINT_SELECT_REGEX',
description: 'Select all files matching this regex',
skip_type_validation: true, # allows Regex
optional: true),
FastlaneCore::ConfigItem.new(key: :exclude_regex,
env_name: 'FL_OCLINT_EXCLUDE_REGEX',
description: 'Exclude all files matching this regex',
skip_type_validation: true, # allows Regex
optional: true),
FastlaneCore::ConfigItem.new(key: :report_type,
env_name: 'FL_OCLINT_REPORT_TYPE',
description: 'The type of the report (default: html)',
default_value: 'html',
optional: true),
FastlaneCore::ConfigItem.new(key: :report_path,
env_name: 'FL_OCLINT_REPORT_PATH',
description: 'The reports file path',
optional: true),
FastlaneCore::ConfigItem.new(key: :list_enabled_rules,
env_name: "FL_OCLINT_LIST_ENABLED_RULES",
description: "List enabled rules",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :rc,
env_name: 'FL_OCLINT_RC',
description: 'Override the default behavior of rules',
optional: true),
FastlaneCore::ConfigItem.new(key: :thresholds,
env_name: 'FL_OCLINT_THRESHOLDS',
description: 'List of rule thresholds to override the default behavior of rules',
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :enable_rules,
env_name: 'FL_OCLINT_ENABLE_RULES',
description: 'List of rules to pick explicitly',
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :disable_rules,
env_name: 'FL_OCLINT_DISABLE_RULES',
description: 'List of rules to disable',
type: Array,
optional: true),
FastlaneCore::ConfigItem.new(key: :max_priority_1,
env_names: ["FL_OCLINT_MAX_PRIOTITY_1", "FL_OCLINT_MAX_PRIORITY_1"], # The version with typo must be deprecated
description: 'The max allowed number of priority 1 violations',
type: Integer,
optional: true),
FastlaneCore::ConfigItem.new(key: :max_priority_2,
env_names: ["FL_OCLINT_MAX_PRIOTITY_2", "FL_OCLINT_MAX_PRIORITY_2"], # The version with typo must be deprecated
description: 'The max allowed number of priority 2 violations',
type: Integer,
optional: true),
FastlaneCore::ConfigItem.new(key: :max_priority_3,
env_names: ["FL_OCLINT_MAX_PRIOTITY_3", "FL_OCLINT_MAX_PRIORITY_3"], # The version with typo must be deprecated
description: 'The max allowed number of priority 3 violations',
type: Integer,
optional: true),
FastlaneCore::ConfigItem.new(key: :enable_clang_static_analyzer,
env_name: "FL_OCLINT_ENABLE_CLANG_STATIC_ANALYZER",
description: "Enable Clang Static Analyzer, and integrate results into OCLint report",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :enable_global_analysis,
env_name: "FL_OCLINT_ENABLE_GLOBAL_ANALYSIS",
description: "Compile every source, and analyze across global contexts (depends on number of source files, could results in high memory load)",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :allow_duplicated_violations,
env_name: "FL_OCLINT_ALLOW_DUPLICATED_VIOLATIONS",
description: "Allow duplicated violations in the OCLint report",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :extra_arg,
env_name: 'FL_OCLINT_EXTRA_ARG',
description: 'Additional argument to append to the compiler command line',
optional: true)
]
end
# rubocop:enable Metrics/PerceivedComplexity
def self.output
[
['FL_OCLINT_REPORT_PATH', 'The reports file path']
]
end
def self.author
'HeEAaD'
end
def self.is_supported?(platform)
true
end
def self.details
"Run the static analyzer tool [OCLint](http://oclint.org) for your project. You need to have a `compile_commands.json` file in your _fastlane_ directory or pass a path to your file."
end
def self.example_code
[
'oclint(
compile_commands: "commands.json", # The JSON compilation database, use xctool reporter "json-compilation-database"
select_regex: /ViewController.m/, # Select all files matching this regex
exclude_regex: /Test.m/, # Exclude all files matching this regex
report_type: "pmd", # The type of the report (default: html)
max_priority_1: 10, # The max allowed number of priority 1 violations
max_priority_2: 100, # The max allowed number of priority 2 violations
max_priority_3: 1000, # The max allowed number of priority 3 violations
thresholds: [ # Override the default behavior of rules
"LONG_LINE=200",
"LONG_METHOD=200"
],
enable_rules: [ # List of rules to pick explicitly
"DoubleNegative",
"SwitchStatementsDon\'TNeedDefaultWhenFullyCovered"
],
disable_rules: ["GotoStatement"], # List of rules to disable
list_enabled_rules: true, # List enabled rules
enable_clang_static_analyzer: true, # Enable Clang Static Analyzer, and integrate results into OCLint report
enable_global_analysis: true, # Compile every source, and analyze across global contexts (depends on number of source files, could results in high memory load)
allow_duplicated_violations: true, # Allow duplicated violations in the OCLint report
extra_arg: "-Wno-everything" # Additional argument to append to the compiler command line
)'
]
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/build_ios_app.rb | fastlane/lib/fastlane/actions/build_ios_app.rb | module Fastlane
module Actions
require 'fastlane/actions/build_app'
class BuildIosAppAction < BuildAppAction
# Gym::Options.available_options keys that don't apply to ios apps.
REJECT_OPTIONS = [
:pkg,
:skip_package_pkg,
:catalyst_platform,
:installer_cert_name
]
def self.run(params)
# Adding reject options back in so gym has everything it needs
params.available_options += Gym::Options.available_options.select do |option|
REJECT_OPTIONS.include?(option.key)
end
# Defaulting to ios specific values
params[:catalyst_platform] = "ios"
super(params)
end
#####################################################
# @!group Documentation
#####################################################
def self.available_options
require 'gym'
require 'gym/options'
Gym::Options.available_options.reject do |option|
REJECT_OPTIONS.include?(option.key)
end
end
def self.is_supported?(platform)
[:ios].include?(platform)
end
def self.description
"Alias for the `build_app` action but only for iOS"
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/println.rb | fastlane/lib/fastlane/actions/println.rb | module Fastlane
module Actions
require 'fastlane/actions/puts'
class PrintlnAction < PutsAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `puts` 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/nexus_upload.rb | fastlane/lib/fastlane/actions/nexus_upload.rb | module Fastlane
module Actions
class NexusUploadAction < Action
def self.run(params)
command = []
command << "curl"
command << verbose(params)
command << "--fail"
command += ssl_options(params)
command += proxy_options(params)
command += upload_options(params)
command << upload_url(params)
Fastlane::Actions.sh(command.join(' '), log: params[:verbose])
end
def self.upload_url(params)
url = "#{params[:endpoint]}#{params[:mount_path]}"
if params[:nexus_version] == 2
url << "/service/local/artifact/maven/content"
else
file_extension = File.extname(params[:file]).shellescape
url << "/repository/#{params[:repo_id]}"
url << "/#{params[:repo_group_id].gsub('.', '/')}"
url << "/#{params[:repo_project_name]}"
url << "/#{params[:repo_project_version]}"
url << "/#{params[:repo_project_name]}-#{params[:repo_project_version]}"
url << "-#{params[:repo_classifier]}" if params[:repo_classifier]
url << file_extension.to_s
end
url.shellescape
end
def self.verbose(params)
params[:verbose] ? "--verbose" : "--silent"
end
def self.upload_options(params)
file_path = File.expand_path(params[:file]).shellescape
file_extension = file_path.split('.').last.shellescape
options = []
if params[:nexus_version] == 2
options << "-F p=zip"
options << "-F hasPom=false"
options << "-F r=#{params[:repo_id].shellescape}"
options << "-F g=#{params[:repo_group_id].shellescape}"
options << "-F a=#{params[:repo_project_name].shellescape}"
options << "-F v=#{params[:repo_project_version].shellescape}"
if params[:repo_classifier]
options << "-F c=#{params[:repo_classifier].shellescape}"
end
options << "-F e=#{file_extension}"
options << "-F file=@#{file_path}"
else
options << "--upload-file #{file_path}"
end
options << "-u #{params[:username].shellescape}:#{params[:password].shellescape}"
options
end
def self.ssl_options(params)
options = []
unless params[:ssl_verify]
options << "--insecure"
end
options
end
def self.proxy_options(params)
options = []
if params[:proxy_address] && params[:proxy_port] && params[:proxy_username] && params[:proxy_password]
options << "-x #{params[:proxy_address].shellescape}:#{params[:proxy_port].shellescape}"
options << "--proxy-user #{params[:proxy_username].shellescape}:#{params[:proxy_password].shellescape}"
end
options
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Upload a file to [Sonatype Nexus platform](https://www.sonatype.com)"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :file,
env_name: "FL_NEXUS_FILE",
description: "File to be uploaded to Nexus",
optional: false,
verify_block: proc do |value|
file_path = File.expand_path(value)
UI.user_error!("Couldn't find file at path '#{file_path}'") unless File.exist?(file_path)
end),
FastlaneCore::ConfigItem.new(key: :repo_id,
env_name: "FL_NEXUS_REPO_ID",
description: "Nexus repository id e.g. artefacts",
optional: false),
FastlaneCore::ConfigItem.new(key: :repo_group_id,
env_name: "FL_NEXUS_REPO_GROUP_ID",
description: "Nexus repository group id e.g. com.company",
optional: false),
FastlaneCore::ConfigItem.new(key: :repo_project_name,
env_name: "FL_NEXUS_REPO_PROJECT_NAME",
description: "Nexus repository commandect name. Only letters, digits, underscores(_), hyphens(-), and dots(.) are allowed",
optional: false),
FastlaneCore::ConfigItem.new(key: :repo_project_version,
env_name: "FL_NEXUS_REPO_PROJECT_VERSION",
description: "Nexus repository commandect version",
optional: false),
FastlaneCore::ConfigItem.new(key: :repo_classifier,
env_name: "FL_NEXUS_REPO_CLASSIFIER",
description: "Nexus repository artifact classifier (optional)",
optional: true),
FastlaneCore::ConfigItem.new(key: :endpoint,
env_name: "FL_NEXUS_ENDPOINT",
description: "Nexus endpoint e.g. http://nexus:8081",
optional: false),
FastlaneCore::ConfigItem.new(key: :mount_path,
env_name: "FL_NEXUS_MOUNT_PATH",
description: "Nexus mount path (Nexus 3 instances have this configured as empty by default)",
default_value: "/nexus",
optional: true),
FastlaneCore::ConfigItem.new(key: :username,
env_name: "FL_NEXUS_USERNAME",
description: "Nexus username",
optional: false),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_NEXUS_PASSWORD",
description: "Nexus password",
sensitive: true,
optional: false),
FastlaneCore::ConfigItem.new(key: :ssl_verify,
env_name: "FL_NEXUS_SSL_VERIFY",
description: "Verify SSL",
type: Boolean,
default_value: true,
optional: true),
FastlaneCore::ConfigItem.new(key: :nexus_version,
env_name: "FL_NEXUS_MAJOR_VERSION",
description: "Nexus major version",
type: Integer,
default_value: 2,
optional: true,
verify_block: proc do |value|
min_version = 2
max_version = 3
UI.user_error!("Unsupported version (#{value}) min. supported version: #{min_version}") unless value >= min_version
UI.user_error!("Unsupported version (#{value}) max. supported version: #{max_version}") unless value <= max_version
end),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: "FL_NEXUS_VERBOSE",
description: "Make detailed output",
type: Boolean,
default_value: false,
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_username,
env_name: "FL_NEXUS_PROXY_USERNAME",
description: "Proxy username",
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_password,
env_name: "FL_NEXUS_PROXY_PASSWORD",
sensitive: true,
description: "Proxy password",
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_address,
env_name: "FL_NEXUS_PROXY_ADDRESS",
description: "Proxy address",
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy_port,
env_name: "FL_NEXUS_PROXY_PORT",
description: "Proxy port",
optional: true)
]
end
def self.authors
["xfreebird", "mdio"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'# for Nexus 2
nexus_upload(
file: "/path/to/file.ipa",
repo_id: "artefacts",
repo_group_id: "com.fastlane",
repo_project_name: "ipa",
repo_project_version: "1.13",
repo_classifier: "dSYM", # Optional
endpoint: "http://localhost:8081",
username: "admin",
password: "admin123"
)',
'# for Nexus 3
nexus_upload(
nexus_version: 3,
mount_path: "",
file: "/path/to/file.ipa",
repo_id: "artefacts",
repo_group_id: "com.fastlane",
repo_project_name: "ipa",
repo_project_version: "1.13",
repo_classifier: "dSYM", # Optional
endpoint: "http://localhost:8081",
username: "admin",
password: "admin123"
)'
]
end
def self.category
:beta
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/echo.rb | fastlane/lib/fastlane/actions/echo.rb | module Fastlane
module Actions
require 'fastlane/actions/puts'
class EchoAction < PutsAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `puts` 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/flock.rb | fastlane/lib/fastlane/actions/flock.rb | module Fastlane
module Actions
class FlockAction < Action
BASE_URL = 'https://api.flock.co/hooks/sendMessage'.freeze
def self.run(options)
require 'net/http'
require 'uri'
require 'json'
notify_incoming_message_webhook(options[:base_url], options[:message], options[:token])
end
def self.notify_incoming_message_webhook(base_url, message, token)
uri = URI.join(base_url + '/', token)
response = Net::HTTP.start(
uri.host, uri.port, use_ssl: uri.scheme == 'https'
) do |http|
request = Net::HTTP::Post.new(uri.path)
request.content_type = 'application/json'
request.body = JSON.generate("text" => message)
http.request(request)
end
if response.kind_of?(Net::HTTPSuccess)
UI.success('Message sent to Flock.')
else
UI.error("HTTP request to '#{uri}' with message '#{message}' failed with a #{response.code} response.")
UI.user_error!('Error sending message to Flock. Please verify the Flock webhook token.')
end
end
def self.description
"Send a message to a [Flock](https://flock.com/) group"
end
def self.details
"To obtain the token, create a new [incoming message webhook](https://dev.flock.co/wiki/display/FlockAPI/Incoming+Webhooks) in your Flock admin panel."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :message,
env_name: 'FL_FLOCK_MESSAGE',
description: 'Message text'),
FastlaneCore::ConfigItem.new(key: :token,
env_name: 'FL_FLOCK_TOKEN',
sensitive: true,
description: 'Token for the Flock incoming webhook'),
FastlaneCore::ConfigItem.new(key: :base_url,
env_name: 'FL_FLOCK_BASE_URL',
description: 'Base URL of the Flock incoming message webhook',
optional: true,
default_value: BASE_URL,
verify_block: proc do |value|
UI.user_error!('Invalid https URL') unless value.start_with?('https://')
end)
]
end
def self.author
"Manav"
end
def self.example_code
[
'flock(
message: "Hello",
token: "xxx"
)'
]
end
def self.category
:notifications
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/supply.rb | fastlane/lib/fastlane/actions/supply.rb | module Fastlane
module Actions
require 'fastlane/actions/upload_to_play_store'
class SupplyAction < UploadToPlayStoreAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `upload_to_play_store` 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/default_platform.rb | fastlane/lib/fastlane/actions/default_platform.rb | module Fastlane
module Actions
module SharedValues
DEFAULT_PLATFORM = :DEFAULT_PLATFORM
end
class DefaultPlatformAction < Action
def self.run(params)
UI.user_error!("You forgot to pass the default platform") if params.first.nil?
platform = params.first.to_sym
SupportedPlatforms.verify!(platform)
Actions.lane_context[SharedValues::DEFAULT_PLATFORM] = platform
end
def self.description
"Defines a default platform to not have to specify the platform"
end
def self.output
[
['DEFAULT_PLATFORM', 'The default platform']
]
end
def self.example_code
[
'default_platform(:android)'
]
end
def self.category
:misc
end
def self.author
"KrauseFx"
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/appstore.rb | fastlane/lib/fastlane/actions/appstore.rb | module Fastlane
module Actions
require 'fastlane/actions/upload_to_app_store'
class AppstoreAction < UploadToAppStoreAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `upload_to_app_store` 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/git_remote_branch.rb | fastlane/lib/fastlane/actions/git_remote_branch.rb | module Fastlane
module Actions
class GitRemoteBranchAction < Action
def self.run(params)
Actions.git_remote_branch_name(params[:remote_name])
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Returns the name of the current git remote default branch"
end
def self.details
"If no default remote branch could be found, this action will return nil. This is a wrapper for the internal action Actions.git_default_remote_branch_name"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :remote_name,
env_name: "FL_REMOTE_REPOSITORY_NAME",
description: "The remote repository to check",
optional: true)
]
end
def self.output
[]
end
def self.authors
["SeanMcNeil"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'git_remote_branch # Query git for first available remote name',
'git_remote_branch(remote_name:"upstream") # Provide a remote name'
]
end
def self.return_type
:string
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/appetize_viewing_url_generator.rb | fastlane/lib/fastlane/actions/appetize_viewing_url_generator.rb | module Fastlane
module Actions
module SharedValues
end
class AppetizeViewingUrlGeneratorAction < Action
def self.run(params)
link = "#{params[:base_url]}/#{params[:public_key]}"
if params[:scale].nil? # sensible default values for scaling
case params[:device].downcase.to_sym
when :iphone6splus, :iphone6plus
params[:scale] = "50"
when :ipadair, :ipadair2
params[:scale] = "50"
else
params[:scale] = "75"
end
end
url_params = []
url_params << "autoplay=true"
url_params << "orientation=#{params[:orientation]}"
url_params << "device=#{params[:device]}"
url_params << "deviceColor=#{params[:color]}"
url_params << "scale=#{params[:scale]}"
url_params << "launchUrl=#{params[:launch_url]}" if params[:launch_url]
url_params << "language=#{params[:language]}" if params[:language]
url_params << "osVersion=#{params[:os_version]}" if params[:os_version]
url_params << "params=#{CGI.escape(params[:params])}" if params[:params]
url_params << "proxy=#{CGI.escape(params[:proxy])}" if params[:proxy]
return link + "?" + url_params.join("&")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Generate an URL for appetize simulator"
end
def self.details
"Check out the [device_grid guide](https://github.com/fastlane/fastlane/blob/master/fastlane/lib/fastlane/actions/device_grid/README.md) for more information"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :public_key,
env_name: "APPETIZE_PUBLICKEY",
description: "Public key of the app you wish to update",
sensitive: true,
default_value: Actions.lane_context[SharedValues::APPETIZE_PUBLIC_KEY],
default_value_dynamic: true,
optional: false,
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: :base_url,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_BASE",
description: "Base URL of Appetize service",
default_value: "https://appetize.io/embed",
optional: true),
FastlaneCore::ConfigItem.new(key: :device,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_DEVICE",
description: "Device type: iphone4s, iphone5s, iphone6, iphone6plus, ipadair, iphone6s, iphone6splus, ipadair2, nexus5, nexus7 or nexus9",
default_value: "iphone5s"),
FastlaneCore::ConfigItem.new(key: :scale,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_SCALE",
description: "Scale of the simulator",
optional: true,
verify_block: proc do |value|
available = ["25", "50", "75", "100"]
UI.user_error!("Invalid scale, available: #{available.join(', ')}") unless available.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :orientation,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_ORIENTATION",
description: "Device orientation",
default_value: "portrait",
verify_block: proc do |value|
available = ["portrait", "landscape"]
UI.user_error!("Invalid device, available: #{available.join(', ')}") unless available.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :language,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_LANGUAGE",
description: "Device language in ISO 639-1 language code, e.g. 'de'",
optional: true),
FastlaneCore::ConfigItem.new(key: :color,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_COLOR",
description: "Color of the device",
default_value: "black",
verify_block: proc do |value|
available = ["black", "white", "silver", "gray"]
UI.user_error!("Invalid device color, available: #{available.join(', ')}") unless available.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :launch_url,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_LAUNCH_URL",
description: "Specify a deep link to open when your app is launched",
optional: true),
FastlaneCore::ConfigItem.new(key: :os_version,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_OS_VERSION",
description: "The operating system version on which to run your app, e.g. 10.3, 8.0",
optional: true),
FastlaneCore::ConfigItem.new(key: :params,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_PARAMS",
description: "Specify params value to be passed to Appetize",
optional: true),
FastlaneCore::ConfigItem.new(key: :proxy,
env_name: "APPETIZE_VIEWING_URL_GENERATOR_PROXY",
description: "Specify a HTTP proxy to be passed to Appetize",
optional: true)
]
end
def self.category
:misc
end
def self.return_value
"The URL to preview the iPhone app"
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
[:ios].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/app_store_build_number.rb | fastlane/lib/fastlane/actions/app_store_build_number.rb | require 'ostruct'
module Fastlane
module Actions
module SharedValues
LATEST_BUILD_NUMBER = :LATEST_BUILD_NUMBER
LATEST_VERSION = :LATEST_VERSION
end
class AppStoreBuildNumberAction < Action
def self.run(params)
build_v, build_nr = get_build_version_and_number(params)
Actions.lane_context[SharedValues::LATEST_BUILD_NUMBER] = build_nr
Actions.lane_context[SharedValues::LATEST_VERSION] = build_v
return build_nr
end
def self.get_build_version_and_number(params)
require 'spaceship'
result = get_build_info(params)
build_nr = result.build_nr
# Convert build_nr to int (for legacy use) if no "." in string
if build_nr.kind_of?(String) && !build_nr.include?(".")
build_nr = build_nr.to_i
end
return result.build_v, build_nr
end
def self.get_build_info(params)
# 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
# Username is now optional since addition of App Store Connect API Key
# Force asking for username to prompt user if not already set
params.fetch(:username, force_ask: true)
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
platform = Spaceship::ConnectAPI::Platform.map(params[:platform])
app = Spaceship::ConnectAPI::App.find(params[:app_identifier])
UI.user_error!("Could not find an app on App Store Connect with app_identifier: #{params[:app_identifier]}") unless app
if params[:live]
UI.message("Fetching the latest build number for live-version")
live_version = app.get_live_app_store_version(platform: platform)
UI.user_error!("Could not find a live-version of #{params[:app_identifier]} on App Store Connect") unless live_version
build_nr = live_version.build.version
UI.message("Latest upload for live-version #{live_version.version_string} is build: #{build_nr}")
return OpenStruct.new({ build_nr: build_nr, build_v: live_version.version_string })
else
version_number = params[:version]
platform = params[:platform]
# Create filter for get_builds with optional version number
filter = { app: app.id }
if version_number
filter["preReleaseVersion.version"] = version_number
version_number_message = "version #{version_number}"
else
version_number_message = "any version"
end
if platform
filter["preReleaseVersion.platform"] = Spaceship::ConnectAPI::Platform.map(platform)
platform_message = "#{platform} platform"
else
platform_message = "any platform"
end
UI.message("Fetching the latest build number for #{version_number_message}")
# Get latest build for optional version number and return build number if found
build = Spaceship::ConnectAPI.get_builds(filter: filter, sort: "-uploadedDate", includes: "preReleaseVersion", limit: 1).first
if build
build_nr = build.version
UI.message("Latest upload for version #{build.app_version} on #{platform_message} is build: #{build_nr}")
return OpenStruct.new({ build_nr: build_nr, build_v: build.app_version })
end
# Let user know that build couldn't be found
UI.important("Could not find a build for #{version_number_message} on #{platform_message} on App Store Connect")
if params[:initial_build_number].nil?
UI.user_error!("Could not find a build on App Store Connect - and 'initial_build_number' option is not set")
else
build_nr = params[:initial_build_number]
UI.message("Using initial build number of #{build_nr}")
return OpenStruct.new({ build_nr: build_nr, build_v: version_number })
end
end
end
def self.order_versions(versions)
versions.map(&:to_s).sort_by { |v| Gem::Version.new(v) }
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Returns the current build_number of either live or edit version"
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: ["APPSTORE_BUILD_NUMBER_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: ["APPSTORE_BUILD_NUMBER_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: :initial_build_number,
env_name: "INITIAL_BUILD_NUMBER",
description: "sets the build number to given value if no build is in current train",
skip_type_validation: true), # as we also allow integers, which we convert to strings anyway
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: "ITUNESCONNECT_USER",
description: "Your Apple ID Username",
optional: true,
default_value: user,
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :team_id,
short_option: "-k",
env_name: "APPSTORE_BUILD_NUMBER_LIVE_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: :live,
short_option: "-l",
env_name: "APPSTORE_BUILD_NUMBER_LIVE",
description: "Query the live version (ready-for-sale)",
optional: true,
type: Boolean,
default_value: true),
FastlaneCore::ConfigItem.new(key: :version,
env_name: "LATEST_VERSION",
description: "The version number whose latest build number we want",
optional: true),
FastlaneCore::ConfigItem.new(key: :platform,
short_option: "-j",
env_name: "APPSTORE_PLATFORM",
description: "The platform to use (optional)",
optional: true,
default_value: "ios",
verify_block: proc do |value|
UI.user_error!("The platform can only be ios, appletvos/tvos, xros or osx") unless %w(ios appletvos tvos xros osx).include?(value)
end),
FastlaneCore::ConfigItem.new(key: :team_name,
short_option: "-e",
env_name: "LATEST_TESTFLIGHT_BUILD_NUMBER_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)
]
end
def self.output
[
['LATEST_BUILD_NUMBER', 'The latest build number of either live or testflight version'],
['LATEST_VERSION', 'The version of the latest build number']
]
end
def self.details
[
"Returns the current build number of either the live or testflight version - it is useful for getting the build_number of the current or ready-for-sale app version, and it also works on non-live testflight version.",
"If you need to handle more build-trains please see `latest_testflight_build_number`."
].join("\n")
end
def self.example_code
[
'app_store_build_number',
'app_store_build_number(
app_identifier: "app.identifier",
username: "user@host.com"
)',
'app_store_build_number(
live: false,
app_identifier: "app.identifier",
version: "1.2.9"
)',
'api_key = app_store_connect_api_key(
key_id: "MyKeyID12345",
issuer_id: "00000000-0000-0000-0000-000000000000",
key_filepath: "./AuthKey.p8"
)
build_num = app_store_build_number(
api_key: api_key
)'
]
end
def self.authors
["hjanuschka"]
end
def self.category
:app_store_connect
end
def self.is_supported?(platform)
[:ios, :mac].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/hg_ensure_clean_status.rb | fastlane/lib/fastlane/actions/hg_ensure_clean_status.rb | module Fastlane
module Actions
module SharedValues
HG_REPO_WAS_CLEAN_ON_START = :HG_REPO_WAS_CLEAN_ON_START
end
# Raises an exception and stop the lane execution if the repo is not in a clean state
class HgEnsureCleanStatusAction < Action
def self.run(params)
repo_clean = `hg status`.empty?
if repo_clean
UI.success('Mercurial status is clean, all good! π')
Actions.lane_context[SharedValues::HG_REPO_WAS_CLEAN_ON_START] = true
else
UI.user_error!('Mercurial repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first.')
end
end
def self.description
"Raises an exception if there are uncommitted hg changes"
end
def self.details
"Along the same lines as the [ensure_git_status_clean](https://docs.fastlane.tools/actions/ensure_git_status_clean/) action, this is a sanity check to ensure the working mercurial repo is clean. Especially useful to put at the beginning of your Fastfile in the `before_all` block."
end
def self.output
[
['HG_REPO_WAS_CLEAN_ON_START', 'Stores the fact that the hg repo was clean at some point']
]
end
def self.author
# credits to lmirosevic for original git version
"sjrmanning"
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'hg_ensure_clean_status'
]
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/typetalk.rb | fastlane/lib/fastlane/actions/typetalk.rb | module Fastlane
module Actions
class TypetalkAction < Action
def self.run(params)
options = {
message: nil,
note_path: nil,
success: true,
topic_id: nil,
typetalk_token: nil
}.merge(params || {})
[:message, :topic_id, :typetalk_token].each do |key|
UI.user_error!("No #{key} given.") unless options[key]
end
emoticon = (options[:success] ? ':smile:' : ':rage:')
message = "#{emoticon} #{options[:message]}"
note_path = File.expand_path(options[:note_path]) if options[:note_path]
if note_path && File.exist?(note_path)
contents = File.read(note_path)
message += "\n\n```\n#{contents}\n```"
end
topic_id = options[:topic_id]
typetalk_token = options[:typetalk_token]
self.post_to_typetalk(message, topic_id, typetalk_token)
UI.success('Successfully sent Typetalk notification')
end
def self.post_to_typetalk(message, topic_id, typetalk_token)
require 'net/http'
require 'uri'
uri = URI.parse("https://typetalk.in/api/v1/topics/#{topic_id}")
response = Net::HTTP.post_form(uri, { 'message' => message,
'typetalkToken' => typetalk_token })
self.check_response(response)
end
def self.check_response(response)
case response.code.to_i
when 200, 204
true
else
UI.user_error!("Could not sent Typetalk notification")
end
end
def self.description
"Post a message to [Typetalk](https://www.typetalk.com/)"
end
def self.available_options
[
['message', 'The message to post'],
['note_path', 'Path to an additional note'],
['topic_id', 'Typetalk topic id'],
['success', 'Successful build?'],
['typetalk_token', 'typetalk token']
]
end
def self.author
"Nulab Inc."
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'typetalk(
message: "App successfully released!",
note_path: "ChangeLog.md",
topicId: 1,
success: true,
typetalk_token: "Your Typetalk 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/set_build_number_repository.rb | fastlane/lib/fastlane/actions/set_build_number_repository.rb | module Fastlane
module Actions
module SharedValues
end
class SetBuildNumberRepositoryAction < Action
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.run(params)
build_number = Fastlane::Actions::GetBuildNumberRepositoryAction.run(
use_hg_revision_number: params[:use_hg_revision_number]
)
Fastlane::Actions::IncrementBuildNumberAction.run(
build_number: build_number,
xcodeproj: params[:xcodeproj]
)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Set the build number from the current repository"
end
def self.details
[
"This action will set the **build number** according to what the SCM HEAD reports.",
"Currently supported SCMs are svn (uses root revision), git-svn (uses svn revision) and git (uses short hash) and mercurial (uses short hash or revision number).",
"There is an option, `:use_hg_revision_number`, which allows to use mercurial revision number instead of hash."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :use_hg_revision_number,
env_name: "USE_HG_REVISION_NUMBER",
description: "Use hg revision number instead of hash (ignored for non-hg repos)",
optional: true,
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "XCODEPROJ_PATH",
description: "explicitly specify which xcodeproj to use",
optional: true,
verify_block: proc do |value|
path = File.expand_path(value)
UI.user_error!("Please pass the path to the project, not the workspace") if path.end_with?(".xcworkspace")
UI.user_error!("Could not find Xcode project at #{path}") unless Helper.test? || File.exist?(path)
end)
]
end
def self.authors
["pbrooks", "armadsen", "AndrewSB"]
end
def self.example_code
[
'set_build_number_repository',
'set_build_number_repository(
xcodeproj: "./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/xcversion.rb | fastlane/lib/fastlane/actions/xcversion.rb | module Fastlane
module Actions
class XcversionAction < Action
def self.run(params)
Actions.verify_gem!('xcode-install')
version = params[:version]
xcode = Helper::XcversionHelper.find_xcode(version)
UI.user_error!("Cannot find an installed Xcode satisfying '#{version}'") if xcode.nil?
UI.verbose("Found Xcode version #{xcode.version} at #{xcode.path} satisfying requirement #{version}")
UI.message("Setting Xcode version to #{xcode.path} for all build steps")
ENV["DEVELOPER_DIR"] = File.join(xcode.path, "/Contents/Developer")
end
def self.description
"Select an Xcode to use by version specifier"
end
def self.details
[
"Finds and selects a version of an installed Xcode that best matches the provided [`Gem::Version` requirement specifier](http://www.rubydoc.info/github/rubygems/rubygems/Gem/Version)",
"You can either manually provide a specific version using `version:` or you make use of the `.xcode-version` file."
].join("\n")
end
def self.authors
["oysta", "rogerluan"]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :version,
env_name: "FL_XCODE_VERSION",
description: "The version of Xcode to select specified as a Gem::Version requirement string (e.g. '~> 7.1.0'). Defaults to the value specified in the .xcode-version file ",
default_value: Helper::XcodesHelper.read_xcode_version_file,
default_value_dynamic: true,
verify_block: Helper::XcodesHelper::Verify.method(:requirement))
]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'xcversion(version: "8.1") # Selects Xcode 8.1.0',
'xcversion(version: "~> 8.1.0") # Selects the latest installed version from the 8.1.x set',
'xcversion # When missing, the version value defaults to the value specified in the .xcode-version file'
]
end
def self.category
:deprecated
end
def self.deprecated_notes
"The xcode-install gem, which this action depends on, has been sunset. Please migrate to [xcodes](https://docs.fastlane.tools/actions/xcodes). You can find a migration guide here: [xcpretty/xcode-install/MIGRATION.md](https://github.com/xcpretty/xcode-install/blob/master/MIGRATION.md)"
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_version_number.rb | fastlane/lib/fastlane/actions/get_version_number.rb | module Fastlane
module Actions
module SharedValues
VERSION_NUMBER ||= :VERSION_NUMBER # originally defined in IncrementVersionNumberAction
end
class GetVersionNumberAction < Action
require 'shellwords'
def self.run(params)
xcodeproj_path_or_dir = params[:xcodeproj] || '.'
xcodeproj_dir = File.extname(xcodeproj_path_or_dir) == ".xcodeproj" ? File.dirname(xcodeproj_path_or_dir) : xcodeproj_path_or_dir
target_name = params[:target]
configuration = params[:configuration]
# Get version_number
project = get_project!(xcodeproj_path_or_dir)
target = get_target!(project, target_name)
plist_file = get_plist!(xcodeproj_dir, target, configuration)
version_number = get_version_number_from_plist!(plist_file)
# Get from build settings (or project settings) if needed (ex: $(MARKETING_VERSION) is default in Xcode 11)
if version_number =~ /\$\(([\w\-]+)\)/
version_number = get_version_number_from_build_settings!(target, $1, configuration) || get_version_number_from_build_settings!(project, $1, configuration)
# ${MARKETING_VERSION} also works
elsif version_number =~ /\$\{([\w\-]+)\}/
version_number = get_version_number_from_build_settings!(target, $1, configuration) || get_version_number_from_build_settings!(project, $1, configuration)
end
# Error out if version_number is not set
if version_number.nil?
UI.user_error!("Unable to find Xcode build setting: #{$1}")
end
# Store the number in the shared hash
Actions.lane_context[SharedValues::VERSION_NUMBER] = version_number
# Return the version number because Swift might need this return value
return version_number
end
def self.get_project!(xcodeproj_path_or_dir)
require 'xcodeproj'
if File.extname(xcodeproj_path_or_dir) == ".xcodeproj"
project_path = xcodeproj_path_or_dir
else
project_path = Dir.glob("#{xcodeproj_path_or_dir}/*.xcodeproj").first
end
if project_path && File.exist?(project_path)
return Xcodeproj::Project.open(project_path)
else
UI.user_error!("Unable to find Xcode project at #{project_path || xcodeproj_path_or_dir}")
end
end
def self.get_target!(project, target_name)
targets = project.targets
# Prompt targets if no name
unless target_name
# Gets non-test targets
non_test_targets = targets.reject do |t|
# Not all targets respond to `test_target_type?`
t.respond_to?(:test_target_type?) && t.test_target_type?
end
# Returns if only one non-test target
if non_test_targets.count == 1
return targets.first
end
options = targets.map(&:name)
target_name = UI.select("What target would you like to use?", options)
end
# Find target
target = targets.find do |t|
t.name == target_name
end
UI.user_error!("Cannot find target named '#{target_name}'") unless target
target
end
def self.get_version_number_from_build_settings!(target, variable, configuration = nil)
target.build_configurations.each do |config|
if configuration.nil? || config.name == configuration
value = config.resolve_build_setting(variable)
return value if value
end
end
return nil
end
def self.get_plist!(folder, target, configuration = nil)
plist_files = target.resolved_build_setting("INFOPLIST_FILE", true)
plist_files_count = plist_files.values.compact.uniq.count
# Get plist file for specified configuration
# Or: Prompt for configuration if plist has different files in each configurations
# Else: Get first(only) plist value
if configuration
plist_file = plist_files[configuration]
elsif plist_files_count > 1
options = plist_files.keys
selected = UI.select("What build configuration would you like to use?", options)
plist_file = plist_files[selected]
elsif plist_files_count > 0
plist_file = plist_files.values.first
else
return nil
end
# $(SRCROOT) is the path of where the XcodeProject is
# We can just set this as empty string since we join with `folder` below
if plist_file.include?("$(SRCROOT)/")
plist_file.gsub!("$(SRCROOT)/", "")
end
# plist_file can be `Relative` or `Absolute` path.
# Make to `Absolute` path when plist_file is `Relative` path
unless File.exist?(plist_file)
plist_file = File.absolute_path(File.join(folder, plist_file))
end
UI.user_error!("Cannot find plist file: #{plist_file}") unless File.exist?(plist_file)
plist_file
end
def self.get_version_number_from_plist!(plist_file)
return '$(MARKETING_VERSION)' if plist_file.nil?
plist = Xcodeproj::Plist.read_from_path(plist_file)
UI.user_error!("Unable to read plist: #{plist_file}") unless plist
return '${MARKETING_VERSION}' if plist["CFBundleShortVersionString"].nil?
plist["CFBundleShortVersionString"]
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Get the version number of your project"
end
def self.details
"This action will return the current version number set on your project. It first looks in the plist and then for '$(MARKETING_VERSION)' in the build settings."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :xcodeproj,
env_name: "FL_VERSION_NUMBER_PROJECT",
description: "Path to the Xcode project to read version number from, or its containing directory, optional. If omitted, or if a directory is passed instead, it will use the first Xcode project found within the given directory, or the project root directory if none is passed",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass the path to the project or its containing directory, not the workspace path") if value.end_with?(".xcworkspace")
UI.user_error!("Could not find file or directory at path '#{File.expand_path(value)}'") unless File.exist?(value)
UI.user_error!("Could not find Xcode project in directory at path '#{File.expand_path(value)}'") if File.extname(value) != ".xcodeproj" && Dir.glob("#{value}/*.xcodeproj").empty?
end),
FastlaneCore::ConfigItem.new(key: :target,
env_name: "FL_VERSION_NUMBER_TARGET",
description: "Target name, optional. Will be needed if you have more than one non-test target to avoid being prompted to select one",
optional: true),
FastlaneCore::ConfigItem.new(key: :configuration,
env_name: "FL_VERSION_NUMBER_CONFIGURATION",
description: "Configuration name, optional. Will be needed if you have altered the configurations from the default or your version number depends on the configuration selected",
optional: true)
]
end
def self.output
[
['VERSION_NUMBER', 'The version number']
]
end
def self.authors
["Liquidsoul", "joshdholtz"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'version = get_version_number(xcodeproj: "Project.xcodeproj")',
'version = get_version_number(
xcodeproj: "Project.xcodeproj",
target: "App"
)'
]
end
def self.return_type
:string
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/is_ci.rb | fastlane/lib/fastlane/actions/is_ci.rb | module Fastlane
module Actions
class IsCiAction < Action
def self.run(params)
Helper.ci?
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Is the current run being executed on a CI system, like Jenkins or Travis"
end
def self.details
"The return value of this method is true if fastlane is currently executed on Travis, Jenkins, Circle or a similar CI service"
end
def self.available_options
[]
end
def self.return_type
:bool
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'if is_ci
puts "I\'m a computer"
else
say "Hi Human!"
end'
]
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/precheck.rb | fastlane/lib/fastlane/actions/precheck.rb | module Fastlane
module Actions
require 'fastlane/actions/check_app_store_metadata'
class PrecheckAction < CheckAppStoreMetadataAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `check_app_store_metadata` 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/install_provisioning_profile.rb | fastlane/lib/fastlane/actions/install_provisioning_profile.rb | require 'shellwords'
module Fastlane
module Actions
class InstallProvisioningProfileAction < Action
def self.run(params)
absolute_path = File.expand_path(params[:path])
FastlaneCore::ProvisioningProfile.install(absolute_path)
end
def self.description
"Install provisioning profile from path"
end
def self.details
"Install provisioning profile from path for current user"
end
def self.authors
["SofteqDG"]
end
def self.category
:code_signing
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_INSTALL_PROVISIONING_PROFILE_PATH",
description: "Path to provisioning profile",
optional: false,
type: String,
verify_block: proc do |value|
absolute_path = File.expand_path(value)
unless File.exist?(absolute_path)
UI.user_error!("Could not find provisioning profile at path: '#{value}'")
end
end)
]
end
def self.return_value
"The absolute path to the installed provisioning profile"
end
def self.return_type
:string
end
def self.example_code
[
'install_provisioning_profile(path: "profiles/profile.mobileprovision")'
]
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/spaceship_logs.rb | fastlane/lib/fastlane/actions/spaceship_logs.rb | module Fastlane
module Actions
class SpaceshipLogsAction < Action
def self.run(params)
latest = params[:latest]
print_contents = params[:print_contents]
print_paths = params[:print_paths]
copy_to_path = params[:copy_to_path]
copy_to_clipboard = params[:copy_to_clipboard]
# Get log files
files = Dir.glob("/tmp/spaceship*.log").sort_by { |f| File.mtime(f) }.reverse
if files.size == 0
UI.message("No Spaceship log files found")
return []
end
# Filter to latest
if latest
files = [files.first]
end
# Print contents
if print_contents
files.each do |file|
data = File.read(file)
puts("-----------------------------------------------------------------------------------")
puts(" Spaceship Log Content - #{file}")
puts("-----------------------------------------------------------------------------------")
puts(data)
puts("\n")
end
end
# Print paths
if print_paths
puts("-----------------------------------------------------------------------------------")
puts(" Spaceship Log Paths")
puts("-----------------------------------------------------------------------------------")
files.each do |file|
puts(file)
end
puts("\n")
end
# Copy to a directory
if copy_to_path
require 'fileutils'
FileUtils.mkdir_p(copy_to_path)
files.each do |file|
FileUtils.cp(file, copy_to_path)
end
end
# Copy contents to clipboard
if copy_to_clipboard
string = files.map { |file| File.read(file) }.join("\n")
ClipboardAction.run(value: string)
end
return files
end
def self.description
"Find, print, and copy Spaceship logs"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :latest,
description: "Finds only the latest Spaceshop log file if set to true, otherwise returns all",
default_value: true,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :print_contents,
description: "Prints the contents of the found Spaceship log file(s)",
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :print_paths,
description: "Prints the paths of the found Spaceship log file(s)",
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :copy_to_path,
description: "Copies the found Spaceship log file(s) to a directory",
optional: true),
FastlaneCore::ConfigItem.new(key: :copy_to_clipboard,
description: "Copies the contents of the found Spaceship log file(s) to the clipboard",
default_value: false,
type: Boolean)
]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'spaceship_logs',
'spaceship_logs(
copy_to_path: "/tmp/artifacts"
)',
'spaceship_logs(
copy_to_clipboard: true
)',
'spaceship_logs(
print_contents: true,
print_paths: true
)',
'spaceship_logs(
latest: false,
print_contents: true,
print_paths: true
)'
]
end
def self.category
:misc
end
def self.return_value
"The array of Spaceship logs"
end
def self.return_type
:array_of_strings
end
def self.author
"joshdholtz"
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/ensure_no_debug_code.rb | fastlane/lib/fastlane/actions/ensure_no_debug_code.rb | module Fastlane
module Actions
class EnsureNoDebugCodeAction < Action
def self.run(params)
command = "grep -RE '#{params[:text]}' '#{File.absolute_path(params[:path])}'"
extensions = []
extensions << params[:extension] unless params[:extension].nil?
if params[:extensions]
params[:extensions].each do |extension|
extension.delete!('.') if extension.include?(".")
extensions << extension
end
end
if extensions.count > 1
command << " --include=\\*.{#{extensions.join(',')}}"
elsif extensions.count > 0
command << " --include=\\*.#{extensions.join(',')}"
end
command << " --exclude #{params[:exclude]}" if params[:exclude]
if params[:exclude_dirs]
params[:exclude_dirs].each do |dir|
command << " --exclude-dir #{dir.shellescape}"
end
end
return command if Helper.test?
UI.important(command)
results = `#{command}` # we don't use `sh` as the return code of grep is wrong for some reason
# Example Output
# ./fastlane.gemspec: spec.add_development_dependency 'my_word'
# ./Gemfile.lock: my_word (0.10.1)
found = []
results.split("\n").each do |current_raw|
found << current_raw.strip
end
UI.user_error!("Found debug code '#{params[:text]}': \n\n#{found.join("\n")}") if found.count > 0
UI.message("No debug code found in code base π")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Ensures the given text is nowhere in the code base"
end
def self.details
[
"You don't want any debug code to slip into production.",
"This can be used to check if there is any debug code still in your codebase or if you have things like `// TO DO` or similar."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :text,
env_name: "FL_ENSURE_NO_DEBUG_CODE_TEXT",
description: "The text that must not be in the code base"),
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_ENSURE_NO_DEBUG_CODE_PATH",
description: "The directory containing all the source files",
default_value: ".",
verify_block: proc do |value|
UI.user_error!("Couldn't find the folder at '#{File.absolute_path(value)}'") unless File.directory?(value)
end),
FastlaneCore::ConfigItem.new(key: :extension,
env_name: "FL_ENSURE_NO_DEBUG_CODE_EXTENSION",
description: "The extension that should be searched for",
optional: true,
verify_block: proc do |value|
value.delete!('.') if value.include?(".")
end),
FastlaneCore::ConfigItem.new(key: :extensions,
env_name: "FL_ENSURE_NO_DEBUG_CODE_EXTENSIONS",
description: "An array of file extensions that should be searched for",
optional: true,
type: Array),
FastlaneCore::ConfigItem.new(key: :exclude,
env_name: "FL_ENSURE_NO_DEBUG_CODE_EXCLUDE",
description: "Exclude a certain pattern from the search",
optional: true),
FastlaneCore::ConfigItem.new(key: :exclude_dirs,
env_name: "FL_ENSURE_NO_DEBUG_CODE_EXCLUDE_DIRS",
description: "An array of dirs that should not be included in the search",
optional: true,
type: Array)
]
end
def self.output
[]
end
def self.authors
["KrauseFx"]
end
def self.example_code
[
'ensure_no_debug_code(text: "// TODO")',
'ensure_no_debug_code(text: "Log.v",
extension: "java")',
'ensure_no_debug_code(text: "NSLog",
path: "./lib",
extension: "m")',
'ensure_no_debug_code(text: "(^#define DEBUG|NSLog)",
path: "./lib",
extension: "m")',
'ensure_no_debug_code(text: "<<<<<<",
extensions: ["m", "swift", "java"])'
]
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/spm.rb | fastlane/lib/fastlane/actions/spm.rb | module Fastlane
module Actions
class SpmAction < Action
def self.run(params)
cmd = ["swift"]
cmd << (package_commands.include?(params[:command]) ? "package" : params[:command])
cmd << "--scratch-path #{params[:scratch_path]}" if params[:scratch_path]
cmd << "--build-path #{params[:build_path]}" if params[:build_path]
cmd << "--package-path #{params[:package_path]}" if params[:package_path]
cmd << "--configuration #{params[:configuration]}" if params[:configuration]
cmd << "--disable-sandbox" if params[:disable_sandbox]
cmd << "--verbose" if params[:verbose]
cmd << "--very-verbose" if params[:very_verbose]
if params[:simulator]
simulator_platform = simulator_platform(simulator: params[:simulator], simulator_arch: params[:simulator_arch])
simulator_sdk = simulator_sdk(simulator: params[:simulator])
simulator_sdk_suffix = simulator_sdk_suffix(simulator: params[:simulator])
simulator_flags = [
"-Xswiftc", "-sdk",
"-Xswiftc", "$(xcrun --sdk #{params[:simulator]} --show-sdk-path)",
"-Xswiftc", "-target",
"-Xswiftc", "#{simulator_platform}#{simulator_sdk}#{simulator_sdk_suffix}"
]
cmd += simulator_flags
end
cmd << params[:command] if package_commands.include?(params[:command])
cmd << "--enable-code-coverage" if params[:enable_code_coverage] && (params[:command] == 'generate-xcodeproj' || params[:command] == 'test')
cmd << "--parallel" if params[:parallel] && params[:command] == 'test'
if params[:xcconfig]
cmd << "--xcconfig-overrides #{params[:xcconfig]}"
end
if params[:xcpretty_output]
cmd += ["2>&1", "|", "xcpretty", "--#{params[:xcpretty_output]}"]
if params[:xcpretty_args]
cmd << (params[:xcpretty_args]).to_s
end
cmd = %w(set -o pipefail &&) + cmd
end
FastlaneCore::CommandExecutor.execute(command: cmd.join(" "),
print_all: true,
print_command: true)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Runs Swift Package Manager on your project"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :command,
env_name: "FL_SPM_COMMAND",
description: "The swift command (one of: #{available_commands.join(', ')})",
default_value: "build",
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: :enable_code_coverage,
env_name: "FL_SPM_ENABLE_CODE_COVERAGE",
description: "Enables code coverage for the generated Xcode project when using the 'generate-xcodeproj' and the 'test' command",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :scratch_path,
env_name: "FL_SPM_SCRATCH_PATH",
description: "Specify build/cache directory [default: ./.build]",
optional: true),
FastlaneCore::ConfigItem.new(key: :parallel,
env_name: "FL_SPM_PARALLEL",
description: "Enables running tests in parallel when using the 'test' command",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :build_path,
env_name: "FL_SPM_BUILD_PATH",
description: "Specify build/cache directory [default: ./.build]",
deprecated: "`build_path` option is deprecated, use `scratch_path` instead",
optional: true),
FastlaneCore::ConfigItem.new(key: :package_path,
env_name: "FL_SPM_PACKAGE_PATH",
description: "Change working directory before any other operation",
optional: true),
FastlaneCore::ConfigItem.new(key: :xcconfig,
env_name: "FL_SPM_XCCONFIG",
description: "Use xcconfig file to override swift package generate-xcodeproj defaults",
optional: true),
FastlaneCore::ConfigItem.new(key: :configuration,
short_option: "-c",
env_name: "FL_SPM_CONFIGURATION",
description: "Build with configuration (debug|release) [default: debug]",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass a valid configuration: (debug|release)") unless valid_configurations.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :disable_sandbox,
env_name: "FL_SPM_DISABLE_SANDBOX",
description: "Disable using the sandbox when executing subprocesses",
optional: true,
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :xcpretty_output,
env_name: "FL_SPM_XCPRETTY_OUTPUT",
description: "Specifies the output type for xcpretty. eg. 'test', or 'simple'",
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass a valid xcpretty output type: (#{xcpretty_output_types.join('|')})") unless xcpretty_output_types.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :xcpretty_args,
env_name: "FL_SPM_XCPRETTY_ARGS",
description: "Pass in xcpretty additional command line arguments (e.g. '--test --no-color' or '--tap --no-utf'), requires xcpretty_output to be specified also",
type: String,
optional: true),
FastlaneCore::ConfigItem.new(key: :verbose,
short_option: "-v",
env_name: "FL_SPM_VERBOSE",
description: "Increase verbosity of informational output",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :very_verbose,
short_option: "-V",
env_name: "FL_SPM_VERY_VERBOSE",
description: "Increase verbosity to include debug output",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :simulator,
env_name: "FL_SPM_SIMULATOR",
description: "Specifies the simulator to pass for Swift Compiler (one of: #{valid_simulators.join(', ')})",
type: String,
optional: true,
verify_block: proc do |value|
UI.user_error!("Please pass a valid simulator. Use one of the following: #{valid_simulators.join(', ')}") unless valid_simulators.include?(value)
end),
FastlaneCore::ConfigItem.new(key: :simulator_arch,
env_name: "FL_SPM_SIMULATOR_ARCH",
description: "Specifies the architecture of the simulator to pass for Swift Compiler (one of: #{valid_architectures.join(', ')}). Requires the simulator option to be specified also, otherwise, it's ignored",
type: String,
optional: false,
default_value: "arm64",
verify_block: proc do |value|
UI.user_error!("Please pass a valid simulator architecture. Use one of the following: #{valid_architectures.join(', ')}") unless valid_architectures.include?(value)
end)
]
end
def self.authors
["fjcaetano", "nxtstep"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'spm',
'spm(
command: "build",
scratch_path: "./build",
configuration: "release"
)',
'spm(
command: "generate-xcodeproj",
xcconfig: "Package.xcconfig"
)',
'spm(
command: "test",
parallel: true
)',
'spm(
simulator: "iphonesimulator"
)',
'spm(
simulator: "macosx",
simulator_arch: "arm64"
)'
]
end
def self.category
:building
end
def self.available_commands
%w(build test) + self.package_commands
end
def self.package_commands
%w(clean reset update resolve generate-xcodeproj init)
end
def self.valid_configurations
%w(debug release)
end
def self.xcpretty_output_types
%w(simple test knock tap)
end
def self.valid_simulators
%w(iphonesimulator macosx)
end
def self.valid_architectures
%w(x86_64 arm64)
end
def self.simulator_platform(params)
platform_suffix = params[:simulator] == "iphonesimulator" ? "ios" : "macosx"
"#{params[:simulator_arch]}-apple-#{platform_suffix}"
end
def self.simulator_sdk(params)
"$(xcrun --sdk #{params[:simulator]} --show-sdk-version | cut -d '.' -f 1)"
end
def self.simulator_sdk_suffix(params)
return "" unless params[:simulator] == "iphonesimulator"
"-simulator"
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/produce.rb | fastlane/lib/fastlane/actions/produce.rb | module Fastlane
module Actions
require 'fastlane/actions/create_app_online'
class ProduceAction < CreateAppOnlineAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `create_app_online` 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/min_fastlane_version.rb | fastlane/lib/fastlane/actions/min_fastlane_version.rb | module Fastlane
module Actions
module SharedValues
end
class MinFastlaneVersionAction < 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 fastlane version as parameter to min_fastlane_version") unless defined_version
if Gem::Version.new(Fastlane::VERSION) < defined_version
FastlaneCore::UpdateChecker.show_update_message('fastlane', Fastlane::VERSION)
error_message = "The Fastfile requires a fastlane version of >= #{defined_version}. You are on #{Fastlane::VERSION}."
UI.user_error!(error_message)
end
UI.message("Your fastlane version #{Fastlane::VERSION} matches the minimum requirement of #{defined_version} β
")
end
def self.step_text
"Verifying fastlane version"
end
def self.author
"KrauseFx"
end
def self.description
"Verifies the minimum fastlane version required"
end
def self.example_code
[
'min_fastlane_version("1.50.0")'
]
end
def self.details
[
"Add this to your `Fastfile` to require a certain version of _fastlane_.",
"Use it if you use an action that just recently came out and you need it."
].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/update_app_group_identifiers.rb | fastlane/lib/fastlane/actions/update_app_group_identifiers.rb | module Fastlane
module Actions
module SharedValues
APP_GROUP_IDENTIFIERS = :APP_GROUP_IDENTIFIERS
end
class UpdateAppGroupIdentifiersAction < Action
require 'plist'
def self.run(params)
UI.message("Entitlements File: #{params[:entitlements_file]}")
UI.message("New App Group Identifiers: #{params[:app_group_identifiers]}")
entitlements_file = params[:entitlements_file]
UI.user_error!("Could not find entitlements file at path '#{entitlements_file}'") unless File.exist?(entitlements_file)
# parse entitlements
result = Plist.parse_xml(entitlements_file)
UI.user_error!("Entitlements file at '#{entitlements_file}' cannot be parsed.") unless result
# get app group field
app_group_field = result['com.apple.security.application-groups']
UI.user_error!("No existing App group field specified. Please specify an App Group in the entitlements file.") unless app_group_field
# set new app group identifiers
UI.message("Old App Group Identifiers: #{app_group_field}")
result['com.apple.security.application-groups'] = params[:app_group_identifiers]
# save entitlements file
result.save_plist(entitlements_file)
UI.message("New App Group Identifiers set: #{result['com.apple.security.application-groups']}")
Actions.lane_context[SharedValues::APP_GROUP_IDENTIFIERS] = result['com.apple.security.application-groups']
end
def self.description
"This action changes the app group identifiers in the entitlements file"
end
def self.details
"Updates the App Group Identifiers in the given Entitlements file, so you can have app groups for the app store build and app groups for an enterprise build."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :entitlements_file,
env_name: "FL_UPDATE_APP_GROUP_IDENTIFIER_ENTITLEMENTS_FILE_PATH", # The name of the environment variable
description: "The path to the entitlement file which contains the app group identifiers", # a short description of this parameter
verify_block: proc do |value|
UI.user_error!("Please pass a path to an entitlements file. ") unless value.include?(".entitlements")
UI.user_error!("Could not find entitlements file") if !File.exist?(value) && !Helper.test?
end),
FastlaneCore::ConfigItem.new(key: :app_group_identifiers,
env_name: "FL_UPDATE_APP_GROUP_IDENTIFIER_APP_GROUP_IDENTIFIERS",
description: "An Array of unique identifiers for the app groups. Eg. ['group.com.test.testapp']",
type: Array)
]
end
def self.output
[
['APP_GROUP_IDENTIFIERS', 'The new App Group Identifiers']
]
end
def self.authors
["mathiasAichinger"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'update_app_group_identifiers(
entitlements_file: "/path/to/entitlements_file.entitlements",
app_group_identifiers: ["group.your.app.group.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/ensure_bundle_exec.rb | fastlane/lib/fastlane/actions/ensure_bundle_exec.rb | module Fastlane
module Actions
module SharedValues
end
# Raises an exception and stop the lane execution if not using bundle exec to run fastlane
class EnsureBundleExecAction < Action
def self.run(params)
return if PluginManager.new.gemfile_path.nil?
if FastlaneCore::Helper.bundler?
UI.success("Using bundled fastlane β
")
else
UI.user_error!("fastlane detected a Gemfile in the current directory. However, it seems like you didn't use `bundle exec`. Use `bundle exec fastlane #{ARGV.join(' ')}` instead.")
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Raises an exception if not using `bundle exec` to run fastlane"
end
def self.details
[
"This action will check if you are using `bundle exec` to run fastlane.",
"You can put it into `before_all` to make sure that fastlane is ran using the `bundle exec fastlane` command."
].join("\n")
end
def self.available_options
[]
end
def self.output
[]
end
def self.author
['rishabhtayal']
end
def self.example_code
[
"ensure_bundle_exec"
]
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/xcodebuild.rb | fastlane/lib/fastlane/actions/xcodebuild.rb | # rubocop:disable all
module Fastlane
module Actions
module SharedValues
XCODEBUILD_ARCHIVE ||= :XCODEBUILD_ARCHIVE
XCODEBUILD_DERIVED_DATA_PATH = :XCODEBUILD_DERIVED_DATA_PATH
end
# xcodebuild man page:
# https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/xcodebuild.1.html
class XcodebuildAction < Action
ARGS_MAP = {
# actions
analyze: "analyze",
archive: "archive",
build: "build",
clean: "clean",
install: "install",
installsrc: "installsrc",
test: "test",
# parameters
alltargets: "-alltargets",
arch: "-arch",
archive_path: "-archivePath",
configuration: "-configuration",
derivedDataPath: "-derivedDataPath",
destination_timeout: "-destination-timeout",
dry_run: "-dry-run",
enableAddressSanitizer: "-enableAddressSanitizer",
enableThreadSanitizer: "-enableThreadSanitizer",
enableCodeCoverage: "-enableCodeCoverage",
export_archive: "-exportArchive",
export_format: "-exportFormat",
export_installer_identity: "-exportInstallerIdentity",
export_options_plist: "-exportOptionsPlist",
export_path: "-exportPath",
export_profile: "-exportProvisioningProfile",
export_signing_identity: "-exportSigningIdentity",
export_with_original_signing_identity: "-exportWithOriginalSigningIdentity",
hide_shell_script_environment: "-hideShellScriptEnvironment",
jobs: "-jobs",
parallelize_targets: "-parallelizeTargets",
project: "-project",
result_bundle_path: "-resultBundlePath",
scheme: "-scheme",
sdk: "-sdk",
skip_unavailable_actions: "-skipUnavailableActions",
target: "-target",
toolchain: "-toolchain",
workspace: "-workspace",
xcconfig: "-xcconfig"
}
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
def self.example_code
[
'xcodebuild(
archive: true,
archive_path: "./build-dir/MyApp.xcarchive",
scheme: "MyApp",
workspace: "MyApp.xcworkspace"
)'
]
end
def self.category
:building
end
def self.run(params)
unless Helper.test?
UI.user_error!("xcodebuild not installed") if `which xcodebuild`.length == 0
end
# The args we will build with
xcodebuild_args = Array[]
# Supported ENV vars
build_path = ENV["XCODE_BUILD_PATH"] || nil
scheme = ENV["XCODE_SCHEME"]
workspace = ENV["XCODE_WORKSPACE"]
project = ENV["XCODE_PROJECT"]
buildlog_path = ENV["XCODE_BUILDLOG_PATH"]
# Set derived data path.
params[:derivedDataPath] ||= ENV["XCODE_DERIVED_DATA_PATH"]
Actions.lane_context[SharedValues::XCODEBUILD_DERIVED_DATA_PATH] = params[:derivedDataPath]
# Append slash to build path, if needed
if build_path && !build_path.end_with?("/")
build_path += "/"
end
# By default we use xcpretty
raw_buildlog = false
# By default we don't pass the utf flag
xcpretty_utf = false
if params
# Operation bools
archiving = params.key? :archive
exporting = params.key? :export_archive
testing = params.key? :test
xcpretty_utf = params[:xcpretty_utf]
if params.key? :raw_buildlog
raw_buildlog = params[:raw_buildlog]
end
if exporting
# If not passed, retrieve path from previous xcodebuild call
params[:archive_path] ||= Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE]
# If not passed, construct export path from env vars
if params[:export_path].nil?
ipa_filename = scheme ? scheme : File.basename(params[:archive_path], ".*")
params[:export_path] = "#{build_path}#{ipa_filename}"
end
# Default to ipa as export format
export_format = params[:export_format] || "ipa"
# Store IPA path for later deploy steps (i.e. Crashlytics)
Actions.lane_context[SharedValues::IPA_OUTPUT_PATH] = params[:export_path] + "." + export_format.downcase
else
# If not passed, check for archive scheme & workspace/project env vars
params[:scheme] ||= scheme
params[:workspace] ||= workspace
params[:project] ||= project
# If no project or workspace was passed in or set as an environment
# variable, attempt to autodetect the workspace.
if params[:project].to_s.empty? && params[:workspace].to_s.empty?
params[:workspace] = detect_workspace
end
end
if archiving
# If not passed, construct archive path from env vars
params[:archive_path] ||= "#{build_path}#{params[:scheme]}.xcarchive"
# Cache path for later xcodebuild calls
Actions.lane_context[SharedValues::XCODEBUILD_ARCHIVE] = params[:archive_path]
end
if params.key? :enable_address_sanitizer
params[:enableAddressSanitizer] = params[:enable_address_sanitizer] ? 'YES' : 'NO'
end
if params.key? :enable_thread_sanitizer
params[:enableThreadSanitizer] = params[:enable_thread_sanitizer] ? 'YES' : 'NO'
end
if params.key? :enable_code_coverage
params[:enableCodeCoverage] = params[:enable_code_coverage] ? 'YES' : 'NO'
end
# Maps parameter hash to CLI args
params = export_options_to_plist(params)
if hash_args = hash_to_args(params)
xcodebuild_args += hash_args
end
buildlog_path ||= params[:buildlog_path]
end
# By default we put xcodebuild.log in the Logs folder
buildlog_path ||= File.expand_path("#{FastlaneCore::Helper.buildlog_path}/fastlane/xcbuild/#{Time.now.strftime('%F')}/#{Process.pid}")
# Joins args into space delimited string
xcodebuild_args = xcodebuild_args.join(" ")
# Default args
xcpretty_args = []
# Formatting style
if params && params[:output_style]
output_style = params[:output_style]
UI.user_error!("Invalid output_style #{output_style}") unless [:standard, :basic].include?(output_style)
else
output_style = :standard
end
case output_style
when :standard
xcpretty_args << '--color' unless Helper.colors_disabled?
when :basic
xcpretty_args << '--no-utf'
end
if testing
if params[:reports]
# New report options format
reports = params[:reports].reduce("") do |arguments, report|
report_string = "--report #{report[:report]}"
if report[:output]
report_string << " --output \"#{report[:output]}\""
elsif report[:report] == 'junit'
report_string << " --output \"#{build_path}report/report.xml\""
elsif report[:report] == 'html'
report_string << " --output \"#{build_path}report/report.html\""
elsif report[:report] == 'json-compilation-database'
report_string << " --output \"#{build_path}report/report.json\""
end
if report[:screenshots]
report_string << " --screenshots"
end
unless arguments == ""
arguments << " "
end
arguments << report_string
end
xcpretty_args.push reports
elsif params[:report_formats]
# Test report file format
report_formats = params[:report_formats].map do |format|
"--report #{format}"
end.sort.join(" ")
xcpretty_args.push report_formats
# Save screenshots flag
if params[:report_formats].include?("html") && params[:report_screenshots]
xcpretty_args.push "--screenshots"
end
xcpretty_args.sort!
# Test report file path
if params[:report_path]
xcpretty_args.push "--output \"#{params[:report_path]}\""
elsif build_path
xcpretty_args.push "--output \"#{build_path}report\""
end
end
end
# Stdout format
if testing && !archiving
xcpretty_args << (params[:xcpretty_output] ? "--#{params[:xcpretty_output]}" : "--test")
else
xcpretty_args << (params[:xcpretty_output] ? "--#{params[:xcpretty_output]}" : "--simple")
end
xcpretty_args = xcpretty_args.join(" ")
xcpretty_command = ""
xcpretty_command = "| xcpretty #{xcpretty_args}" unless raw_buildlog
unless raw_buildlog
xcpretty_command = "#{xcpretty_command} --utf" if xcpretty_utf
end
pipe_command = "| tee '#{buildlog_path}/xcodebuild.log' #{xcpretty_command}"
FileUtils.mkdir_p buildlog_path
UI.message("For a more detailed xcodebuild log open #{buildlog_path}/xcodebuild.log")
output_result = ""
override_architecture_prefix = params[:xcodebuild_architecture] ? "arch -#{params[:xcodebuild_architecture]} " : ""
# In some cases the simulator is not booting up in time
# One way to solve it is to try to rerun it for one more time
begin
output_result = Actions.sh "set -o pipefail && #{override_architecture_prefix}xcodebuild #{xcodebuild_args} #{pipe_command}"
rescue => ex
exit_status = $?.exitstatus
raise_error = true
if exit_status.eql? 65
iphone_simulator_time_out_error = /iPhoneSimulator: Timed out waiting/
if (iphone_simulator_time_out_error =~ ex.message) != nil
raise_error = false
UI.important("First attempt failed with iPhone Simulator error: #{iphone_simulator_time_out_error.source}")
UI.important("Retrying once more...")
output_result = Actions.sh "set -o pipefail && xcodebuild #{xcodebuild_args} #{pipe_command}"
end
end
raise ex if raise_error
end
# If raw_buildlog and some reports had to be created, create xcpretty reports from the build log
if raw_buildlog && xcpretty_args.include?('--report')
output_result = Actions.sh "set -o pipefail && cat '#{buildlog_path}/xcodebuild.log' | xcpretty #{xcpretty_args} > /dev/null"
end
output_result
end
def self.export_options_to_plist(hash)
# Extract export options parameters from input options
if hash.has_key?(:export_options_plist) && hash[:export_options_plist].is_a?(Hash)
export_options = hash[:export_options_plist]
# Normalize some values
export_options[:teamID] = CredentialsManager::AppfileConfig.try_fetch_value(:team_id) if !export_options[:teamID] && CredentialsManager::AppfileConfig.try_fetch_value(:team_id)
export_options[:onDemandResourcesAssetPacksBaseURL] = Addressable::URI.encode(export_options[:onDemandResourcesAssetPacksBaseURL]) if export_options[:onDemandResourcesAssetPacksBaseURL]
if export_options[:manifest]
export_options[:manifest][:appURL] = Addressable::URI.encode(export_options[:manifest][:appURL]) if export_options[:manifest][:appURL]
export_options[:manifest][:displayImageURL] = Addressable::URI.encode(export_options[:manifest][:displayImageURL]) if export_options[:manifest][:displayImageURL]
export_options[:manifest][:fullSizeImageURL] = Addressable::URI.encode(export_options[:manifest][:fullSizeImageURL]) if export_options[:manifest][:fullSizeImageURL]
export_options[:manifest][:assetPackManifestURL] = Addressable::URI.encode(export_options[:manifest][:assetPackManifestURL]) if export_options[:manifest][:assetPackManifestURL]
end
# Saves options to plist
path = "#{Tempfile.new('exportOptions').path}.plist"
File.write(path, export_options.to_plist)
hash[:export_options_plist] = path
end
hash
end
def self.hash_to_args(hash)
# Remove nil value params
hash = hash.delete_if { |_, v| v.nil? }
# Maps nice developer param names to CLI arguments
hash.map do |k, v|
v ||= ""
if arg = ARGS_MAP[k]
value = (v != true && v.to_s.length > 0 ? "\"#{v}\"" : "")
"#{arg} #{value}".strip
elsif k == :build_settings
v.map do |setting, val|
val = clean_build_setting_value(val)
"#{setting}=\"#{val}\""
end.join(' ')
elsif k == :destination
[*v].collect { |dst| "-destination \"#{dst}\"" }.join(' ')
elsif k == :keychain && v.to_s.length > 0
# If keychain is specified, append as OTHER_CODE_SIGN_FLAGS
"OTHER_CODE_SIGN_FLAGS=\"--keychain #{v}\""
elsif k == :xcargs && v.to_s.length > 0
# Add more xcodebuild arguments
"#{v}"
end
end.compact
end
# Cleans values for build settings
# Only escaping `$(inherit)` types of values since "sh"
# interprets these as sub-commands instead of passing value into xcodebuild
def self.clean_build_setting_value(value)
value.to_s.gsub('$(', '\\$(')
end
def self.detect_workspace
workspace = nil
workspaces = Dir.glob("*.xcworkspace")
if workspaces.length > 1
UI.important("Multiple workspaces detected.")
end
unless workspaces.empty?
workspace = workspaces.first
UI.important("Using workspace \"#{workspace}\"")
end
return workspace
end
def self.description
"Use the `xcodebuild` command to build and sign your app"
end
def self.available_options
[
['archive', 'Set to true to build archive'],
['archive_path', 'The path to archive the to. Must contain `.xcarchive`'],
['workspace', 'The workspace to use'],
['scheme', 'The scheme to build'],
['build_settings', 'Hash of additional build information'],
['xcargs', 'Pass additional xcodebuild options'],
['buildlog_path', 'The path where the xcodebuild.log will be created, by default it is created in ~/Library/Logs/fastlane/xcbuild'],
['output_style', 'Set the output format to one of: :standard (Colored UTF8 output, default), :basic (black & white ASCII output)'],
['xcodebuild_architecture', 'Allows to set the architecture that `xcodebuild` is run with, for example to force it to run under Rosetta on an Apple Silicon mac'],
['raw_buildlog', 'Set to true to see xcodebuild raw output. Default value is false'],
['xcpretty_output', 'specifies the output type for xcpretty. eg. \'test\', or \'simple\''],
['xcpretty_utf', 'Specifies xcpretty should use utf8 when reporting builds. This has no effect when raw_buildlog is specified.']
]
end
def self.details
"**Note**: `xcodebuild` is a complex command, so it is recommended to use [_gym_](https://docs.fastlane.tools/actions/gym/) for building your ipa file and [_scan_](https://docs.fastlane.tools/actions/scan/) for testing your app instead."
end
def self.author
"dtrenz"
end
end
class XcarchiveAction < Action
def self.run(params)
params_hash = params || {}
params_hash[:archive] = true
XcodebuildAction.run(params_hash)
end
def self.description
"Archives the project using `xcodebuild`"
end
def self.example_code
[
'xcarchive'
]
end
def self.category
:building
end
def self.author
"dtrenz"
end
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
def self.available_options
[
['archive_path', 'The path to archive the to. Must contain `.xcarchive`'],
['workspace', 'The workspace to use'],
['scheme', 'The scheme to build'],
['build_settings', 'Hash of additional build information'],
['xcargs', 'Pass additional xcodebuild options'],
['output_style', 'Set the output format to one of: :standard (Colored UTF8 output, default), :basic (black & white ASCII output)'],
['xcodebuild_architecture', 'Allows to set the architecture that `xcodebuild` is run with, for example to force it to run under Rosetta on an Apple Silicon mac'],
['buildlog_path', 'The path where the xcodebuild.log will be created, by default it is created in ~/Library/Logs/fastlane/xcbuild'],
['raw_buildlog', 'Set to true to see xcodebuild raw output. Default value is false'],
['xcpretty_output', 'specifies the output type for xcpretty. eg. \'test\', or \'simple\''],
['xcpretty_utf', 'Specifies xcpretty should use utf8 when reporting builds. This has no effect when raw_buildlog is specified.']
]
end
end
class XcbuildAction < Action
def self.run(params)
params_hash = params || {}
params_hash[:build] = true
XcodebuildAction.run(params_hash)
end
def self.example_code
[
'xcbuild'
]
end
def self.category
:building
end
def self.description
"Builds the project using `xcodebuild`"
end
def self.author
"dtrenz"
end
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
def self.available_options
[
['archive', 'Set to true to build archive'],
['archive_path', 'The path to archive the to. Must contain `.xcarchive`'],
['workspace', 'The workspace to use'],
['scheme', 'The scheme to build'],
['build_settings', 'Hash of additional build information'],
['xcargs', 'Pass additional xcodebuild options'],
['output_style', 'Set the output format to one of: :standard (Colored UTF8 output, default), :basic (black & white ASCII output)'],
['buildlog_path', 'The path where the xcodebuild.log will be created, by default it is created in ~/Library/Logs/fastlane/xcbuild'],
['raw_buildlog', 'Set to true to see xcodebuild raw output. Default value is false'],
['xcpretty_output', 'specifies the output type for xcpretty. eg. \'test\', or \'simple\''],
['xcpretty_utf', 'Specifies xcpretty should use utf8 when reporting builds. This has no effect when raw_buildlog is specified.']
]
end
end
class XccleanAction < Action
def self.run(params)
params_hash = params || {}
params_hash[:clean] = true
XcodebuildAction.run(params_hash)
end
def self.description
"Cleans the project using `xcodebuild`"
end
def self.example_code
[
'xcclean'
]
end
def self.category
:building
end
def self.author
"dtrenz"
end
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
def self.available_options
[
['archive', 'Set to true to build archive'],
['archive_path', 'The path to archive the to. Must contain `.xcarchive`'],
['workspace', 'The workspace to use'],
['scheme', 'The scheme to build'],
['build_settings', 'Hash of additional build information'],
['xcargs', 'Pass additional xcodebuild options'],
['output_style', 'Set the output format to one of: :standard (Colored UTF8 output, default), :basic (black & white ASCII output)'],
['xcodebuild_architecture', 'Allows to set the architecture that `xcodebuild` is run with, for example to force it to run under Rosetta on an Apple Silicon mac'],
['buildlog_path', 'The path where the xcodebuild.log will be created, by default it is created in ~/Library/Logs/fastlane/xcbuild'],
['raw_buildlog', 'Set to true to see xcodebuild raw output. Default value is false'],
['xcpretty_output', 'specifies the output type for xcpretty. eg. \'test\', or \'simple\''],
['xcpretty_utf', 'Specifies xcpretty should use utf8 when reporting builds. This has no effect when raw_buildlog is specified.']
]
end
end
class XcexportAction < Action
def self.run(params)
params_hash = params || {}
params_hash[:export_archive] = true
XcodebuildAction.run(params_hash)
end
def self.description
"Exports the project using `xcodebuild`"
end
def self.example_code
[
'xcexport'
]
end
def self.category
:building
end
def self.author
"dtrenz"
end
def self.available_options
[
['archive', 'Set to true to build archive'],
['archive_path', 'The path to archive the to. Must contain `.xcarchive`'],
['workspace', 'The workspace to use'],
['scheme', 'The scheme to build'],
['build_settings', 'Hash of additional build information'],
['xcargs', 'Pass additional xcodebuild options'],
['output_style', 'Set the output format to one of: :standard (Colored UTF8 output, default), :basic (black & white ASCII output)'],
['xcodebuild_architecture', 'Allows to set the architecture that `xcodebuild` is run with, for example to force it to run under Rosetta on an Apple Silicon mac'],
['buildlog_path', 'The path where the xcodebuild.log will be created, by default it is created in ~/Library/Logs/fastlane/xcbuild'],
['raw_buildlog', 'Set to true to see xcodebuild raw output. Default value is false'],
['xcpretty_output', 'specifies the output type for xcpretty. eg. \'test\', or \'simple\''],
['xcpretty_utf', 'Specifies xcpretty should use utf8 when reporting builds. This has no effect when raw_buildlog is specified.']
]
end
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
end
class XctestAction < Action
def self.run(params)
UI.important("Have you seen the new 'scan' tool to run tests? https://docs.fastlane.tools/actions/scan/")
params_hash = params || {}
params_hash[:build] = true
params_hash[:test] = true
XcodebuildAction.run(params_hash)
end
def self.example_code
[
'xctest(
destination: "name=iPhone 7s,OS=10.0"
)'
]
end
def self.category
:building
end
def self.description
"Runs tests on the given simulator"
end
def self.available_options
[
['archive', 'Set to true to build archive'],
['archive_path', 'The path to archive the to. Must contain `.xcarchive`'],
['workspace', 'The workspace to use'],
['scheme', 'The scheme to build'],
['build_settings', 'Hash of additional build information'],
['xcargs', 'Pass additional xcodebuild options'],
['destination', 'The simulator to use, e.g. "name=iPhone 5s,OS=8.1"'],
['destination_timeout', 'The timeout for connecting to the simulator, in seconds'],
['enable_code_coverage', 'Turn code coverage on or off when testing. eg. true|false. Requires Xcode 7+'],
['output_style', 'Set the output format to one of: :standard (Colored UTF8 output, default), :basic (black & white ASCII output)'],
['xcodebuild_architecture', 'Allows to set the architecture that `xcodebuild` is run with, for example to force it to run under Rosetta on an Apple Silicon mac'],
['buildlog_path', 'The path where the xcodebuild.log will be created, by default it is created in ~/Library/Logs/fastlane/xcbuild'],
['raw_buildlog', 'Set to true to see xcodebuild raw output. Default value is false'],
['xcpretty_output', 'specifies the output type for xcpretty. eg. \'test\', or \'simple\''],
['xcpretty_utf', 'Specifies xcpretty should use utf8 when reporting builds. This has no effect when raw_buildlog is specified.']
]
end
def self.is_supported?(platform)
[:ios, :mac].include? platform
end
def self.author
"dtrenz"
end
end
end
end
# rubocop:enable all
| ruby | MIT | d1f6eb6228644936997aae1956d8036ea62cd5b4 | 2026-01-04T15:37:27.371479Z | false |
fastlane/fastlane | https://github.com/fastlane/fastlane/blob/d1f6eb6228644936997aae1956d8036ea62cd5b4/fastlane/lib/fastlane/actions/podio_item.rb | fastlane/lib/fastlane/actions/podio_item.rb | module Fastlane
module Actions
module SharedValues
PODIO_ITEM_URL = :PODIO_ITEM_URL
end
class PodioItemAction < Action
AUTH_URL = 'https://podio.com/oauth/token'
BASE_URL = 'https://api.podio.com'
def self.run(params)
require 'rest_client'
require 'json'
require 'uri'
post_item(params)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
'Creates or updates an item within your Podio app'
end
def self.details
[
"Use this action to create or update an item within your Podio app (see [https://help.podio.com/hc/en-us/articles/201019278-Creating-apps-](https://help.podio.com/hc/en-us/articles/201019278-Creating-apps-)).",
"Pass in dictionary with field keys and their values.",
"Field key is located under `Modify app` -> `Advanced` -> `Developer` -> `External ID` (see [https://developers.podio.com/examples/items](https://developers.podio.com/examples/items))."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :client_id,
env_name: 'PODIO_ITEM_CLIENT_ID',
description: 'Client ID for Podio API (see https://developers.podio.com/api-key)',
verify_block: proc do |value|
UI.user_error!("No Client ID for Podio given, pass using `client_id: 'id'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :client_secret,
env_name: 'PODIO_ITEM_CLIENT_SECRET',
sensitive: true,
description: 'Client secret for Podio API (see https://developers.podio.com/api-key)',
verify_block: proc do |value|
UI.user_error!("No Client Secret for Podio given, pass using `client_secret: 'secret'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :app_id,
env_name: 'PODIO_ITEM_APP_ID',
description: 'App ID of the app you intend to authenticate with (see https://developers.podio.com/authentication/app_auth)',
verify_block: proc do |value|
UI.user_error!("No App ID for Podio given, pass using `app_id: 'id'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :app_token,
env_name: 'PODIO_ITEM_APP_TOKEN',
sensitive: true,
description: 'App token of the app you intend to authenticate with (see https://developers.podio.com/authentication/app_auth)',
verify_block: proc do |value|
UI.user_error!("No App token for Podio given, pass using `app_token: 'token'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :identifying_field,
env_name: 'PODIO_ITEM_IDENTIFYING_FIELD',
description: 'String specifying the field key used for identification of an item',
verify_block: proc do |value|
UI.user_error!("No Identifying field given, pass using `identifying_field: 'field name'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :identifying_value,
description: 'String uniquely specifying an item within the app',
verify_block: proc do |value|
UI.user_error!("No Identifying value given, pass using `identifying_value: 'unique value'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :other_fields,
description: 'Dictionary of your app fields. Podio supports several field types, see https://developers.podio.com/doc/items',
type: Hash,
optional: true)
]
end
def self.output
[
['PODIO_ITEM_URL', 'URL to newly created (or updated) Podio item']
]
end
def self.authors
['pprochazka72', 'laugejepsen']
end
def self.is_supported?(_platform)
true
end
#####################################################
# @!group Logic
#####################################################
def self.post_item(options)
auth_config = authenticate(options[:client_id],
options[:client_secret],
options[:app_id],
options[:app_token])
item_id, item_url = get_item(auth_config,
options[:identifying_field],
options[:identifying_value],
options[:app_id])
unless options[:other_fields].nil?
options[:other_fields].each do |key, value|
uri = URI.parse(value)
if uri.kind_of?(URI::HTTP)
link_embed_id = get_embed_id(auth_config, uri)
options[:other_fields].merge!(key => link_embed_id)
end
end
update_item(auth_config, item_id, options[:other_fields])
end
Actions.lane_context[SharedValues::PODIO_ITEM_URL] = item_url
end
def self.authenticate(client_id, client_secret, app_id, app_token)
auth_response = RestClient.post(AUTH_URL, grant_type: 'app',
app_id: app_id,
app_token: app_token,
client_id: client_id,
client_secret: client_secret)
UI.user_error!("Failed to authenticate with Podio API") if auth_response.code != 200
auth_response_dictionary = JSON.parse(auth_response.body)
access_token = auth_response_dictionary['access_token']
{ Authorization: "OAuth2 #{access_token}", content_type: :json, accept: :json }
end
def self.get_item(auth_config, identifying_field, identifying_value, app_id)
item_id, item_url = get_existing_item(auth_config, identifying_value, app_id)
unless item_id
item_id, item_url = create_item(auth_config, identifying_field, identifying_value, app_id)
end
[item_id, item_url]
end
def self.get_existing_item(auth_config, identifying_value, app_id)
filter_request_body = { query: identifying_value, limit: 1, ref_type: 'item' }.to_json
filter_response = RestClient.post("#{BASE_URL}/search/app/#{app_id}/", filter_request_body, auth_config)
UI.user_error!("Failed to search for already existing item #{identifying_value}") if filter_response.code != 200
existing_items = JSON.parse(filter_response.body)
existing_item_id = nil
existing_item_url = nil
if existing_items.length > 0
existing_item = existing_items[0]
if existing_item['title'] == identifying_value
existing_item_id = existing_item['id']
existing_item_url = existing_item['link']
end
end
[existing_item_id, existing_item_url]
end
def self.create_item(auth_config, identifying_field, identifying_value, app_id)
item_request_body = { fields: { identifying_field => identifying_value } }.to_json
item_response = RestClient.post("#{BASE_URL}/item/app/#{app_id}", item_request_body, auth_config)
UI.user_error!("Failed to create item \"#{identifying_value}\"") if item_response.code != 200
item_response_dictionary = JSON.parse(item_response.body)
[item_response_dictionary['item_id'], item_response_dictionary['link']]
end
def self.update_item(auth_config, item_id, fields)
if fields.length > 0
item_request_body = { fields: fields }.to_json
item_response = RestClient.put("#{BASE_URL}/item/#{item_id}", item_request_body, auth_config)
UI.user_error!("Failed to update item values \"#{fields}\"") unless item_response.code != 200 || item_response.code != 204
end
end
def self.get_embed_id(auth_config, url)
embed_request_body = { url: url }.to_json
embed_response = RestClient.post("#{BASE_URL}/embed/", embed_request_body, auth_config)
UI.user_error!("Failed to create embed for link #{link}") if embed_response.code != 200
embed_response_dictionary = JSON.parse(embed_response.body)
embed_response_dictionary['embed_id']
end
def self.example_code
[
'podio_item(
identifying_value: "Your unique value",
other_fields: {
"field1" => "fieldValue",
"field2" => "fieldValue2"
}
)'
]
end
def self.category
:beta
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/check_app_store_metadata.rb | fastlane/lib/fastlane/actions/check_app_store_metadata.rb | module Fastlane
module Actions
module SharedValues
end
class CheckAppStoreMetadataAction < Action
def self.run(config)
# 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
require 'precheck'
Precheck.config = config
return Precheck::Runner.new.run
end
def self.description
"Check your app's metadata before you submit your app to review (via _precheck_)"
end
def self.details
"More information: https://fastlane.tools/precheck"
end
def self.available_options
require 'precheck/options'
Precheck::Options.available_options
end
def self.return_value
return "true if precheck passes, else, false"
end
def self.return_type
:bool
end
def self.authors
["taquitos"]
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'check_app_store_metadata(
negative_apple_sentiment: [level: :skip], # Set to skip to not run the `negative_apple_sentiment` rule
curse_words: [level: :warn] # Set to warn to only warn on curse word check failures
)',
'precheck # alias for "check_app_store_metadata"'
]
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/ensure_git_status_clean.rb | fastlane/lib/fastlane/actions/ensure_git_status_clean.rb | module Fastlane
module Actions
module SharedValues
GIT_REPO_WAS_CLEAN_ON_START = :GIT_REPO_WAS_CLEAN_ON_START
end
# Raises an exception and stop the lane execution if the repo is not in a clean state
class EnsureGitStatusCleanAction < Action
def self.run(params)
# Build command
if params[:ignored]
ignored_mode = params[:ignored]
ignored_mode = 'no' if ignored_mode == 'none'
command = "git status --porcelain --ignored='#{ignored_mode}'"
else
command = "git status --porcelain"
end
# Don't log if manually ignoring files as it will emulate output later
print_output = params[:ignore_files].nil?
repo_status = Actions.sh(command, log: print_output)
# Manual post processing trying to ignore certain file paths
if (ignore_files = params[:ignore_files])
repo_status = repo_status.lines.reject do |line|
path = path_from_git_status_line(line)
next if path.empty?
was_found = ignore_files.include?(path)
UI.message("Ignoring '#{path}'") if was_found
was_found
end.join("")
# Emulate the output format of `git status --porcelain`
UI.command(command)
repo_status.lines.each do |line|
UI.message("βΈ " + line.chomp.magenta)
end
end
repo_clean = repo_status.empty?
if repo_clean
UI.success('Git status is clean, all good! πͺ')
Actions.lane_context[SharedValues::GIT_REPO_WAS_CLEAN_ON_START] = true
else
error_message = "Git repository is dirty! Please ensure the repo is in a clean state by committing/stashing/discarding all changes first."
error_message += "\nUncommitted changes:\n#{repo_status}" if params[:show_uncommitted_changes]
if params[:show_diff]
repo_diff = Actions.sh("git diff")
error_message += "\nGit diff: \n#{repo_diff}"
end
UI.user_error!(error_message)
end
end
def self.path_from_git_status_line(line)
# Extract the file path from the line based on https://git-scm.com/docs/git-status#_output.
# The first two characters indicate the status of the file path (e.g. ' M')
# M App/script.sh
#
# If the file path is renamed, the original path is also included in the line (e.g. 'R ORIG_PATH -> PATH')
# R App/script.sh -> App/script_renamed.sh
#
path = line.match(/^.. (.* -> )?(.*)$/)[2]
path = path.delete_prefix('"').delete_suffix('"')
return path
end
def self.description
"Raises an exception if there are uncommitted git changes"
end
def self.details
[
"A sanity check to make sure you are working in a repo that is clean.",
"Especially useful to put at the beginning of your Fastfile in the `before_all` block, if some of your other actions will touch your filesystem, do things to your git repo, or just as a general reminder to save your work.",
"Also needed as a prerequisite for some other actions like `reset_git_repo`."
].join("\n")
end
def self.output
[
['GIT_REPO_WAS_CLEAN_ON_START', 'Stores the fact that the git repo was clean at some point']
]
end
def self.author
["lmirosevic", "antondomashnev"]
end
def self.example_code
[
'ensure_git_status_clean'
]
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :show_uncommitted_changes,
env_name: "FL_ENSURE_GIT_STATUS_CLEAN_SHOW_UNCOMMITTED_CHANGES",
description: "The flag whether to show uncommitted changes if the repo is dirty",
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :show_diff,
env_name: "FL_ENSURE_GIT_STATUS_CLEAN_SHOW_DIFF",
description: "The flag whether to show the git diff if the repo is dirty",
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :ignored,
env_name: "FL_ENSURE_GIT_STATUS_CLEAN_IGNORED_FILE",
description: [
"The handling mode of the ignored files. The available options are: `'traditional'`, `'none'` (default) and `'matching'`.",
"Specifying `'none'` to this parameter is the same as not specifying the parameter at all, which means that no ignored file will be used to check if the repo is dirty or not.",
"Specifying `'traditional'` or `'matching'` causes some ignored files to be used to check if the repo is dirty or not (more info in the official docs: https://git-scm.com/docs/git-status#Documentation/git-status.txt---ignoredltmodegt)"
].join(" "),
optional: true,
verify_block: proc do |value|
mode = value.to_s
modes = %w(traditional none matching)
UI.user_error!("Unsupported mode, must be: #{modes}") unless modes.include?(mode)
end),
FastlaneCore::ConfigItem.new(key: :ignore_files,
env_name: "FL_ENSURE_GIT_STATUS_CLEAN_IGNORE_FILES",
description: "Array of files to ignore",
optional: true,
type: Array)
]
end
def self.category
:source_control
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/create_app_online.rb | fastlane/lib/fastlane/actions/create_app_online.rb | module Fastlane
module Actions
module SharedValues
PRODUCE_APPLE_ID = :PRODUCE_APPLE_ID
end
class CreateAppOnlineAction < Action
def self.run(params)
require 'produce'
return if Helper.test?
Produce.config = params # we already have the finished config
Dir.chdir(FastlaneCore::FastlaneFolder.path || Dir.pwd) do
# This should be executed in the fastlane folder
apple_id = Produce::Manager.start_producing.to_s
Actions.lane_context[SharedValues::PRODUCE_APPLE_ID] = apple_id
ENV['PRODUCE_APPLE_ID'] = apple_id
end
end
def self.description
"Creates the given application on iTC and the Dev Portal (via _produce_)"
end
def self.details
[
"Create new apps on App Store Connect and Apple Developer Portal via _produce_.",
"If the app already exists, `create_app_online` will not do anything.",
"For more information about _produce_, visit its documentation page: [https://docs.fastlane.tools/actions/produce/](https://docs.fastlane.tools/actions/produce/)."
].join("\n")
end
def self.available_options
require 'produce'
Produce::Options.available_options
end
def self.output
[
['PRODUCE_APPLE_ID', 'The Apple ID of the newly created app. You probably need it for `deliver`']
]
end
def self.author
"KrauseFx"
end
def self.is_supported?(platform)
platform == :ios
end
def self.example_code
[
'create_app_online(
username: "felix@krausefx.com",
app_identifier: "com.krausefx.app",
app_name: "MyApp",
language: "English",
app_version: "1.0",
sku: "123",
team_name: "SunApps GmbH" # Only necessary when in multiple teams.
)',
'produce # alias for "create_app_online"'
]
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/unlock_keychain.rb | fastlane/lib/fastlane/actions/unlock_keychain.rb | module Fastlane
module Actions
class UnlockKeychainAction < Action
def self.run(params)
keychain_path = FastlaneCore::Helper.keychain_path(params[:path])
add_to_search_list = params[:add_to_search_list]
set_default = params[:set_default]
commands = []
# add to search list if not already added
if add_to_search_list == true || add_to_search_list == :add
commands << add_keychain_to_search_list(keychain_path)
elsif add_to_search_list == :replace
commands << replace_keychain_in_search_list(keychain_path)
end
# set default keychain
if set_default
commands << default_keychain(keychain_path)
end
escaped_path = keychain_path.shellescape
escaped_password = params[:password].shellescape
# Log the full path, useful for troubleshooting
UI.message("Unlocking keychain at path: #{escaped_path}")
# unlock given keychain and disable lock and timeout
commands << Fastlane::Actions.sh("security unlock-keychain -p #{escaped_password} #{escaped_path}", log: false)
commands << Fastlane::Actions.sh("security set-keychain-settings #{escaped_path}", log: false)
commands
end
def self.add_keychain_to_search_list(keychain_path)
keychains = Fastlane::Actions.sh("security list-keychains -d user", log: false).shellsplit
# add the keychain to the keychain list
unless keychains.include?(keychain_path)
keychains << keychain_path
Fastlane::Actions.sh("security list-keychains -s #{keychains.shelljoin}", log: false)
end
end
def self.replace_keychain_in_search_list(keychain_path)
begin
UI.message("Reading existing default keychain")
Actions.lane_context[Actions::SharedValues::ORIGINAL_DEFAULT_KEYCHAIN] = Fastlane::Actions.sh("security default-keychain").strip
rescue => e
raise unless e.message.include?("security: SecKeychainCopyDefault: A default keychain could not be found.")
end
escaped_path = keychain_path.shellescape
Fastlane::Actions.sh("security list-keychains -s #{escaped_path}", log: false)
end
def self.default_keychain(keychain_path)
escaped_path = keychain_path.shellescape
Fastlane::Actions.sh("security default-keychain -s #{escaped_path}", log: false)
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Unlock a keychain"
end
def self.details
[
"Unlocks the given keychain file and adds it to the keychain search list.",
"Keychains can be replaced with `add_to_search_list: :replace`."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_UNLOCK_KEYCHAIN_PATH",
description: "Path to the keychain file",
default_value: "login",
optional: false),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_UNLOCK_KEYCHAIN_PASSWORD",
sensitive: true,
description: "Keychain password",
optional: false),
FastlaneCore::ConfigItem.new(key: :add_to_search_list,
env_name: "FL_UNLOCK_KEYCHAIN_ADD_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: true),
FastlaneCore::ConfigItem.new(key: :set_default,
env_name: "FL_UNLOCK_KEYCHAIN_SET_DEFAULT",
description: "Set as default keychain",
type: Boolean,
default_value: false)
]
end
def self.authors
["xfreebird"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'unlock_keychain( # Unlock an existing keychain and add it to the keychain search list
path: "/path/to/KeychainName.keychain",
password: "mysecret"
)',
'unlock_keychain( # By default the keychain is added to the existing. To replace them with the selected keychain you may use `:replace`
path: "/path/to/KeychainName.keychain",
password: "mysecret",
add_to_search_list: :replace # To only add a keychain use `true` or `:add`.
)',
'unlock_keychain( # In addition, the keychain can be selected as a default keychain
path: "/path/to/KeychainName.keychain",
password: "mysecret",
set_default: true
)',
'unlock_keychain( # If the keychain file is located in the standard location `~/Library/Keychains`, then it is sufficient to provide the keychain file name, or file name with its suffix.
path: "KeychainName",
password: "mysecret"
)'
]
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/get_push_certificate.rb | fastlane/lib/fastlane/actions/get_push_certificate.rb | module Fastlane
module Actions
class GetPushCertificateAction < Action
def self.run(params)
require 'pem'
require 'pem/options'
require 'pem/manager'
success_block = params[:new_profile]
PEM.config = params
if Helper.test?
profile_path = './test.pem'
else
profile_path = PEM::Manager.start
end
if success_block && profile_path
success_block.call(File.expand_path(profile_path)) if success_block
end
end
def self.description
"Ensure a valid push profile is active, creating a new one if needed (via _pem_)"
end
def self.author
"KrauseFx"
end
def self.details
sample = <<-SAMPLE.markdown_sample
```ruby
get_push_certificate(
new_profile: proc do
# your upload code
end
)
```
SAMPLE
[
"Additionally to the available options, you can also specify a block that only gets executed if a new profile was created. You can use it to upload the new profile to your server.",
"Use it like this:".markdown_preserve_newlines,
sample
].join("\n")
end
def self.available_options
require 'pem'
require 'pem/options'
@options = PEM::Options.available_options
@options << FastlaneCore::ConfigItem.new(key: :new_profile,
description: "Block that is called if there is a new profile",
optional: true,
type: :string_callback)
@options
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'get_push_certificate',
'pem # alias for "get_push_certificate"',
'get_push_certificate(
force: true, # create a new profile, even if the old one is still valid
app_identifier: "net.sunapps.9", # optional app identifier,
save_private_key: true,
new_profile: proc do |profile_path| # this block gets called when a new profile was generated
puts profile_path # the absolute path to the new PEM file
# insert the code to upload the PEM file to the server
end
)'
]
end
def self.category
:push
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_branch.rb | fastlane/lib/fastlane/actions/git_branch.rb | module Fastlane
module Actions
class GitBranchAction < Action
def self.run(params)
branch = Actions.git_branch || ""
return "" if branch == "HEAD" # Backwards compatibility with the original (and documented) implementation
branch
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Returns the name of the current git branch, possibly as managed by CI ENV vars"
end
def self.details
"If no branch could be found, this action will return an empty string. If `FL_GIT_BRANCH_DONT_USE_ENV_VARS` is `true`, it'll ignore CI ENV vars. This is a wrapper for the internal action Actions.git_branch"
end
def self.available_options
[]
end
def self.output
[
['GIT_BRANCH_ENV_VARS', 'The git branch environment variables']
]
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'git_branch'
]
end
def self.return_type
:string
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/verify_xcode.rb | fastlane/lib/fastlane/actions/verify_xcode.rb | require 'shellwords'
module Fastlane
module Actions
module SharedValues
end
class VerifyXcodeAction < Action
def self.run(params)
UI.message("Verifying your Xcode installation at path '#{params[:xcode_path]}'...")
# Check 1/2
verify_codesign(params)
# Check 2/2
# More information https://developer.apple.com/news/?id=09222015a
verify_gatekeeper(params)
true
end
def self.verify_codesign(params)
UI.message("Verifying Xcode was signed by Apple Inc.")
codesign_output = Actions.sh("codesign --display --verbose=4 #{params[:xcode_path].shellescape}")
# If the returned codesign info contains all entries for any one of these sets, we'll consider it valid
accepted_codesign_detail_sets = [
[ # Found on App Store installed Xcode installations
"Identifier=com.apple.dt.Xcode",
"Authority=Apple Mac OS Application Signing",
"Authority=Apple Worldwide Developer Relations Certification Authority",
"Authority=Apple Root CA",
"TeamIdentifier=59GAB85EFG"
],
[ # Found on App Store installed Xcode installations post-Xcode 11.3
"Identifier=com.apple.dt.Xcode",
"Authority=Apple Mac OS Application Signing",
"Authority=Apple Worldwide Developer Relations Certification Authority",
"Authority=Apple Root CA",
"TeamIdentifier=APPLECOMPUTER"
],
[ # Found on Xcode installations (pre-Xcode 8) downloaded from developer.apple.com
"Identifier=com.apple.dt.Xcode",
"Authority=Software Signing",
"Authority=Apple Code Signing Certification Authority",
"Authority=Apple Root CA",
"TeamIdentifier=not set"
],
[ # Found on Xcode installations (post-Xcode 8) downloaded from developer.apple.com
"Identifier=com.apple.dt.Xcode",
"Authority=Software Signing",
"Authority=Apple Code Signing Certification Authority",
"Authority=Apple Root CA",
"TeamIdentifier=59GAB85EFG"
]
]
# Map the accepted details sets into an equal number of sets collecting the details for which
# the output of codesign did not have matches
missing_details_sets = accepted_codesign_detail_sets.map do |accepted_details_set|
accepted_details_set.reject { |detail| codesign_output.include?(detail) }
end
# If any of the sets is empty, it means that all details were matched, and the check is successful
show_and_raise_error(nil, params[:xcode_path]) unless missing_details_sets.any?(&:empty?)
UI.success("Successfully verified the code signature β
")
end
def self.verify_gatekeeper(params)
UI.message("Verifying Xcode using GateKeeper...")
UI.message("This will take up to a few minutes, now is a great time to go for a coffee β...")
command = "/usr/sbin/spctl --assess --verbose #{params[:xcode_path].shellescape}"
must_includes = ['accepted']
output = verify(command: command, must_includes: must_includes, params: params)
if output.include?("source=Mac App Store") || output.include?("source=Apple") || output.include?("source=Apple System")
UI.success("Successfully verified Xcode installation at path '#{params[:xcode_path]}' π§")
else
show_and_raise_error("Invalid Download Source of Xcode: #{output}", params[:xcode_path])
end
end
def self.verify(command: nil, must_includes: nil, params: nil)
output = Actions.sh(command)
errors = []
must_includes.each do |current|
next if output.include?(current)
errors << current
end
if errors.count > 0
show_and_raise_error(errors.join("\n"), params[:xcode_path])
end
return output
end
def self.show_and_raise_error(error, xcode_path)
UI.error("Attention: Your Xcode Installation could not be verified.")
UI.error("If you believe that your Xcode is valid, please submit an issue on GitHub")
if error
UI.error("The following information couldn't be found:")
UI.error(error)
end
UI.user_error!("The Xcode installation at path '#{xcode_path}' could not be verified.")
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Verifies that the Xcode installation is properly signed by Apple"
end
def self.details
"This action was implemented after the recent Xcode attack to make sure you're not using a [hacked Xcode installation](http://researchcenter.paloaltonetworks.com/2015/09/novel-malware-xcodeghost-modifies-xcode-infects-apple-ios-apps-and-hits-app-store/)."
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :xcode_path,
env_name: "FL_VERIFY_XCODE_XCODE_PATH",
description: "The path to the Xcode installation to test",
code_gen_sensitive: true,
default_value: File.expand_path('../../', FastlaneCore::Helper.xcode_path),
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Couldn't find Xcode at path '#{value}'") unless File.exist?(value)
end)
]
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'verify_xcode',
'verify_xcode(xcode_path: "/Applications/Xcode.app")'
]
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_github_release.rb | fastlane/lib/fastlane/actions/set_github_release.rb | module Fastlane
module Actions
module SharedValues
SET_GITHUB_RELEASE_HTML_LINK = :SET_GITHUB_RELEASE_HTML_LINK
SET_GITHUB_RELEASE_RELEASE_ID = :SET_GITHUB_RELEASE_RELEASE_ID
SET_GITHUB_RELEASE_JSON = :SET_GITHUB_RELEASE_JSON
end
class SetGithubReleaseAction < Action
def self.run(params)
UI.important("Creating release of #{params[:repository_name]} on tag \"#{params[:tag_name]}\" with name \"#{params[:name]}\".")
UI.important("Will also upload assets #{params[:upload_assets]}.") if params[:upload_assets]
repo_name = params[:repository_name]
api_token = params[:api_token]
api_bearer = params[:api_bearer]
server_url = params[:server_url]
tag_name = params[:tag_name]
payload = {
'tag_name' => params[:tag_name],
'draft' => !!params[:is_draft],
'prerelease' => !!params[:is_prerelease],
'generate_release_notes' => !!params[:is_generate_release_notes]
}
payload['name'] = params[:name] if params[:name]
payload['body'] = params[:description] if params[:description]
payload['target_commitish'] = params[:commitish] if params[:commitish]
GithubApiAction.run(
server_url: server_url,
api_token: api_token,
api_bearer: api_bearer,
http_method: 'POST',
path: "repos/#{repo_name}/releases",
body: payload,
error_handlers: {
422 => proc do |result|
UI.error(result[:body])
UI.error("Release on tag #{tag_name} already exists!")
return nil
end,
404 => proc do |result|
UI.error(result[:body])
UI.user_error!("Repository #{repo_name} cannot be found, please double check its name and that you provided a valid API token (GITHUB_API_TOKEN)")
end,
401 => proc do |result|
UI.error(result[:body])
UI.user_error!("You are not authorized to access #{repo_name}, please make sure you provided a valid API token (GITHUB_API_TOKEN)")
end,
'*' => proc do |result|
UI.user_error!("GitHub responded with #{result[:status]}:#{result[:body]}")
end
}
) do |result|
json = result[:json]
html_url = json['html_url']
release_id = json['id']
UI.success("Successfully created release at tag \"#{tag_name}\" on GitHub")
UI.important("See release at \"#{html_url}\"")
Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_HTML_LINK] = html_url
Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_RELEASE_ID] = release_id
Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_JSON] = json
assets = params[:upload_assets]
if assets && assets.count > 0
# upload assets
self.upload_assets(assets, json['upload_url'], api_token, api_bearer)
# fetch the release again, so that it contains the uploaded assets
GithubApiAction.run(
server_url: server_url,
api_token: api_token,
api_bearer: api_bearer,
http_method: 'GET',
path: "repos/#{repo_name}/releases/#{release_id}",
error_handlers: {
'*' => proc do |get_result|
UI.error("GitHub responded with #{get_result[:status]}:#{get_result[:body]}")
UI.user_error!("Failed to fetch the newly created release, but it *has been created* successfully.")
end
}
) do |get_result|
Actions.lane_context[SharedValues::SET_GITHUB_RELEASE_JSON] = get_result[:json]
UI.success("Successfully uploaded assets #{assets} to release \"#{html_url}\"")
return get_result[:json]
end
else
return json || result[:body]
end
end
end
def self.upload_assets(assets, upload_url_template, api_token, api_bearer)
assets.each do |asset|
self.upload(asset, upload_url_template, api_token, api_bearer)
end
end
def self.upload(asset_path, upload_url_template, api_token, api_bearer)
# if it's a directory, zip it first in a temp directory, because we can only upload binary files
absolute_path = File.absolute_path(asset_path)
# check that the asset even exists
UI.user_error!("Asset #{absolute_path} doesn't exist") unless File.exist?(absolute_path)
if File.directory?(absolute_path)
Dir.mktmpdir do |dir|
tmpzip = File.join(dir, File.basename(absolute_path) + '.zip')
sh("cd \"#{File.dirname(absolute_path)}\"; zip -r --symlinks \"#{tmpzip}\" \"#{File.basename(absolute_path)}\" 2>&1 >/dev/null")
self.upload_file(tmpzip, upload_url_template, api_token, api_bearer)
end
else
self.upload_file(absolute_path, upload_url_template, api_token, api_bearer)
end
end
def self.upload_file(file, url_template, api_token, api_bearer)
require 'addressable/template'
file_name = File.basename(file)
expanded_url = Addressable::Template.new(url_template).expand(name: file_name).to_s
headers = { 'Content-Type' => 'application/zip' } # works for all binary files
UI.important("Uploading #{file_name}")
GithubApiAction.run(
api_token: api_token,
api_bearer: api_bearer,
http_method: 'POST',
headers: headers,
url: expanded_url,
raw_body: File.read(file),
error_handlers: {
'*' => proc do |result|
UI.error("GitHub responded with #{result[:status]}:#{result[:body]}")
UI.user_error!("Failed to upload asset #{file_name} to GitHub.")
end
}
) do |result|
UI.success("Successfully uploaded #{file_name}.")
end
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"This will create a new release on GitHub and upload assets for it"
end
def self.details
[
"Creates a new release on 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 tag name. By default, that's `master`.",
"If the tag doesn't exist, one will be created on the commit or branch passed in as commitish.",
"Out parameters provide the release's id, which can be used for later editing and the release HTML link to GitHub. You can also specify a list of assets to be uploaded to the release with the `:upload_assets` parameter."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :repository_name,
env_name: "FL_SET_GITHUB_RELEASE_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_GITHUB_RELEASE_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_GITHUB_RELEASE_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_GITHUB_RELEASE_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: :tag_name,
env_name: "FL_SET_GITHUB_RELEASE_TAG_NAME",
description: "Pass in the tag name",
optional: false),
FastlaneCore::ConfigItem.new(key: :name,
env_name: "FL_SET_GITHUB_RELEASE_NAME",
description: "Name of this release",
optional: true),
FastlaneCore::ConfigItem.new(key: :commitish,
env_name: "FL_SET_GITHUB_RELEASE_COMMITISH",
description: "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master)",
optional: true),
FastlaneCore::ConfigItem.new(key: :description,
env_name: "FL_SET_GITHUB_RELEASE_DESCRIPTION",
description: "Description of this release",
optional: true,
default_value: Actions.lane_context[SharedValues::FL_CHANGELOG],
default_value_dynamic: true),
FastlaneCore::ConfigItem.new(key: :is_draft,
env_name: "FL_SET_GITHUB_RELEASE_IS_DRAFT",
description: "Whether the release should be marked as draft",
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :is_prerelease,
env_name: "FL_SET_GITHUB_RELEASE_IS_PRERELEASE",
description: "Whether the release should be marked as prerelease",
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :is_generate_release_notes,
env_name: "FL_SET_GITHUB_RELEASE_IS_GENERATE_RELEASE_NOTES",
description: "Whether the name and body of this release should be generated automatically",
optional: true,
default_value: false,
type: Boolean),
FastlaneCore::ConfigItem.new(key: :upload_assets,
env_name: "FL_SET_GITHUB_RELEASE_UPLOAD_ASSETS",
description: "Path to assets to be uploaded with the release",
optional: true,
type: Array,
verify_block: proc do |value|
UI.user_error!("upload_assets must be an Array of paths to assets") unless value.kind_of?(Array)
end)
]
end
def self.output
[
['SET_GITHUB_RELEASE_HTML_LINK', 'Link to your created release'],
['SET_GITHUB_RELEASE_RELEASE_ID', 'Release id (useful for subsequent editing)'],
['SET_GITHUB_RELEASE_JSON', 'The whole release JSON object']
]
end
def self.return_value
[
"A hash containing all relevant information of this release",
"Access things like 'html_url', 'tag_name', 'name', 'body'"
].join("\n")
end
def self.return_type
:hash
end
def self.authors
["czechboy0", "tommeier"]
end
def self.is_supported?(platform)
true
end
def self.example_code
[
'github_release = set_github_release(
repository_name: "fastlane/fastlane",
api_token: ENV["GITHUB_TOKEN"],
name: "Super New actions",
tag_name: "v1.22.0",
description: (File.read("changelog") rescue "No changelog provided"),
commitish: "master",
upload_assets: ["example_integration.ipa", "./pkg/built.gem"]
)'
]
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/read_podspec.rb | fastlane/lib/fastlane/actions/read_podspec.rb | module Fastlane
module Actions
module SharedValues
READ_PODSPEC_JSON = :READ_PODSPEC_JSON
end
class ReadPodspecAction < Action
def self.run(params)
Actions.verify_gem!('cocoapods')
path = params[:path]
require 'cocoapods-core'
spec = Pod::Spec.from_file(path).to_hash
UI.success("Reading podspec from file #{path}")
Actions.lane_context[SharedValues::READ_PODSPEC_JSON] = spec
return spec
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Loads a CocoaPods spec as JSON"
end
def self.details
[
"This can be used for only specifying a version string in your podspec - and during your release process you'd read it from the podspec by running `version = read_podspec['version']` at the beginning of your lane.",
"Loads the specified (or the first found) podspec in the folder as JSON, so that you can inspect its `version`, `files` etc.",
"This can be useful when basing your release process on the version string only stored in one place - in the podspec.",
"As one of the first steps you'd read the podspec and its version and the rest of the workflow can use that version string (when e.g. creating a new git tag or a GitHub Release)."
].join("\n")
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_READ_PODSPEC_PATH",
description: "Path to the podspec to be read",
default_value: Dir['*.podspec*'].first,
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("File #{value} not found") unless File.exist?(value)
end)
]
end
def self.output
[
['READ_PODSPEC_JSON', 'Podspec JSON payload']
]
end
def self.authors
["czechboy0"]
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'spec = read_podspec
version = spec["version"]
puts "Using Version #{version}"',
'spec = read_podspec(path: "./XcodeServerSDK.podspec")'
]
end
def self.sample_return_value
{
'version' => 1.0
}
end
def self.return_type
:hash
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_play_store.rb | fastlane/lib/fastlane/actions/upload_to_play_store.rb | module Fastlane
module Actions
class UploadToPlayStoreAction < Action
def self.run(params)
require 'supply'
require 'supply/options'
# If no APK params were provided, try to fill in the values from lane context, preferring
# the multiple APKs over the single APK if set.
if params[:apk_paths].nil? && params[:apk].nil?
all_apk_paths = Actions.lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS] || []
if all_apk_paths.size > 1
params[:apk_paths] = all_apk_paths
else
params[:apk] = Actions.lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]
end
end
# If no AAB param was provided, try to fill in the value from lane context.
# First GRADLE_ALL_AAB_OUTPUT_PATHS if only one
# Else from GRADLE_AAB_OUTPUT_PATH
if params[:aab].nil?
all_aab_paths = Actions.lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS] || []
if all_aab_paths.count == 1
params[:aab] = all_aab_paths.first
else
params[:aab] = Actions.lane_context[SharedValues::GRADLE_AAB_OUTPUT_PATH]
end
end
Supply.config = params # we already have the finished config
Supply::Uploader.new.perform_upload
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Upload metadata, screenshots and binaries to Google Play (via _supply_)"
end
def self.details
"More information: https://docs.fastlane.tools/actions/supply/"
end
def self.available_options
require 'supply'
require 'supply/options'
Supply::Options.available_options
end
def self.output
end
def self.return_value
end
def self.authors
["KrauseFx"]
end
def self.is_supported?(platform)
platform == :android
end
def self.example_code
[
'upload_to_play_store',
'supply # alias for "upload_to_play_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/screengrab.rb | fastlane/lib/fastlane/actions/screengrab.rb | module Fastlane
module Actions
require 'fastlane/actions/capture_android_screenshots'
class ScreengrabAction < CaptureAndroidScreenshotsAction
#####################################################
# @!group Documentation
#####################################################
def self.description
"Alias for the `capture_android_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/zip.rb | fastlane/lib/fastlane/actions/zip.rb | module Fastlane
module Actions
class ZipAction < Action
class Runner
attr_reader :output_path, :path, :verbose, :password, :symlinks, :include, :exclude
def initialize(params)
@output_path = File.expand_path(params[:output_path] || params[:path])
@path = params[:path]
@verbose = params[:verbose]
@password = params[:password]
@symlinks = params[:symlinks]
@include = params[:include] || []
@exclude = params[:exclude] || []
@output_path += ".zip" unless @output_path.end_with?(".zip")
end
def run
UI.message("Compressing #{path}...")
create_output_dir
run_zip_command
UI.success("Successfully generated zip file at path '#{output_path}'")
output_path
end
def create_output_dir
output_dir = File.expand_path("..", output_path)
FileUtils.mkdir_p(output_dir)
end
def run_zip_command
# The 'zip' command archives relative to the working directory, chdir to produce expected results relative to `path`
Dir.chdir(File.expand_path("..", path)) do
Actions.sh(*zip_command)
end
end
def zip_command
zip_options = verbose ? "r" : "rq"
zip_options += "y" if symlinks
command = ["zip", "-#{zip_options}"]
if password
command << "-P"
command << password
end
# The zip command is executed from the paths **parent** directory, as a result we use just the basename, which is the file or folder within
basename = File.basename(path)
command << output_path
command << basename
unless include.empty?
command << "-i"
command += include.map { |path| File.join(basename, path) }
end
unless exclude.empty?
command << "-x"
command += exclude.map { |path| File.join(basename, path) }
end
command
end
end
def self.run(params)
Runner.new(params).run
end
#####################################################
# @!group Documentation
#####################################################
def self.description
"Compress a file or folder to a zip"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :path,
env_name: "FL_ZIP_PATH",
description: "Path to the directory or file to be zipped",
verify_block: proc do |value|
path = File.expand_path(value)
UI.user_error!("Couldn't find file/folder at path '#{path}'") unless File.exist?(path)
end),
FastlaneCore::ConfigItem.new(key: :output_path,
env_name: "FL_ZIP_OUTPUT_NAME",
description: "The name of the resulting zip file",
optional: true),
FastlaneCore::ConfigItem.new(key: :verbose,
env_name: "FL_ZIP_VERBOSE",
description: "Enable verbose output of zipped file",
default_value: true,
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :password,
env_name: "FL_ZIP_PASSWORD",
description: "Encrypt the contents of the zip archive using a password",
optional: true),
FastlaneCore::ConfigItem.new(key: :symlinks,
env_name: "FL_ZIP_SYMLINKS",
description: "Store symbolic links as such in the zip archive",
optional: true,
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :include,
env_name: "FL_ZIP_INCLUDE",
description: "Array of paths or patterns to include",
optional: true,
type: Array,
default_value: []),
FastlaneCore::ConfigItem.new(key: :exclude,
env_name: "FL_ZIP_EXCLUDE",
description: "Array of paths or patterns to exclude",
optional: true,
type: Array,
default_value: [])
]
end
def self.example_code
[
'zip',
'zip(
path: "MyApp.app",
output_path: "Latest.app.zip"
)',
'zip(
path: "MyApp.app",
output_path: "Latest.app.zip",
verbose: false
)',
'zip(
path: "MyApp.app",
output_path: "Latest.app.zip",
verbose: false,
symlinks: true
)',
'zip(
path: "./",
output_path: "Source Code.zip",
exclude: [".git/*"]
)',
'zip(
path: "./",
output_path: "Swift Code.zip",
include: ["**/*.swift"],
exclude: ["Package.swift", "vendor/*", "Pods/*"]
)'
]
end
def self.category
:misc
end
def self.output
[]
end
def self.return_value
"The path to the output zip file"
end
def self.return_type
:string
end
def self.authors
["KrauseFx"]
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/get_provisioning_profile.rb | fastlane/lib/fastlane/actions/get_provisioning_profile.rb | module Fastlane
module Actions
module SharedValues
SIGH_PROFILE_PATH = :SIGH_PROFILE_PATH
SIGH_PROFILE_PATHS = :SIGH_PROFILE_PATHS
SIGH_UDID = :SIGH_UDID # deprecated
SIGH_UUID = :SIGH_UUID
SIGH_NAME = :SIGH_NAME
SIGH_PROFILE_TYPE ||= :SIGH_PROFILE_TYPE
end
class GetProvisioningProfileAction < Action
def self.run(values)
require 'sigh'
require 'credentials_manager/appfile_config'
# Only set :api_key from SharedValues if :api_key_path isn't set (conflicting options)
unless values[:api_key_path]
values[:api_key] ||= Actions.lane_context[SharedValues::APP_STORE_CONNECT_API_KEY]
end
Sigh.config = values # we already have the finished config
path = Sigh::Manager.start
Actions.lane_context[SharedValues::SIGH_PROFILE_PATH] = path # absolute path
Actions.lane_context[SharedValues::SIGH_PROFILE_PATHS] ||= []
Actions.lane_context[SharedValues::SIGH_PROFILE_PATHS] << path
uuid = ENV["SIGH_UUID"] || ENV["SIGH_UDID"] # the UUID of the profile
name = ENV["SIGH_NAME"] # the name of the profile
Actions.lane_context[SharedValues::SIGH_UUID] = Actions.lane_context[SharedValues::SIGH_UDID] = uuid if uuid
Actions.lane_context[SharedValues::SIGH_NAME] = Actions.lane_context[SharedValues::SIGH_NAME] = name if name
set_profile_type(values, ENV["SIGH_PROFILE_ENTERPRISE"])
return uuid # returns uuid of profile
end
def self.set_profile_type(values, enterprise)
profile_type = "app-store"
profile_type = "ad-hoc" if values[:adhoc]
profile_type = "development" if values[:development]
profile_type = "developer-id" if values[:developer_id]
profile_type = "enterprise" if enterprise
UI.message("Setting Provisioning Profile type to '#{profile_type}'")
Actions.lane_context[SharedValues::SIGH_PROFILE_TYPE] = profile_type
end
def self.description
"Generates a provisioning profile, saving it in the current folder (via _sigh_)"
end
def self.author
"KrauseFx"
end
# rubocop:disable Lint/MissingKeysOnSharedArea
def self.output
[
['SIGH_PROFILE_PATH', 'A path in which certificates, key and profile are exported'],
['SIGH_PROFILE_PATHS', 'Paths in which certificates, key and profile are exported'],
['SIGH_UUID', 'UUID (Universally Unique IDentifier) of a provisioning profile'],
['SIGH_NAME', 'The name of the profile'],
['SIGH_PROFILE_TYPE', 'The profile type, can be app-store, ad-hoc, development, enterprise, developer-id, can be used in `build_app` as a default value for `export_method`']
]
end
def self.return_value
"The UUID of the profile sigh just fetched/generated"
end
def self.return_type
:string
end
def self.details
"**Note**: 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 provisioning profiles. Use _sigh_ directly only if you want full control over what's going on and know more about codesigning."
end
def self.available_options
require 'sigh'
Sigh::Options.available_options
end
def self.is_supported?(platform)
[:ios, :mac].include?(platform)
end
def self.example_code
[
'get_provisioning_profile',
'sigh # alias for "get_provisioning_profile"',
'get_provisioning_profile(
adhoc: true,
force: true,
filename: "myFile.mobileprovision"
)'
]
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/tryouts.rb | fastlane/lib/fastlane/actions/tryouts.rb | module Fastlane
module Actions
module SharedValues
# Contains all the data returned from the Tryouts API. See http://tryouts.readthedocs.org/en/latest/releases.html#create-release
TRYOUTS_BUILD_INFORMATION = :TRYOUTS_BUILD_INFORMATION
end
class TryoutsAction < Action
TRYOUTS_API_BUILD_RELEASE_TEMPLATE = "https://api.tryouts.io/v1/applications/%s/releases/"
def self.run(params)
UI.success('Upload to Tryouts has been started. This may take some time.')
response = self.upload_build(params)
case response.status
when 200...300
Actions.lane_context[SharedValues::TRYOUTS_BUILD_INFORMATION] = response.body
UI.success('Build successfully uploaded to Tryouts!')
UI.message("Release download url: #{response.body['download_url']}") if response.body["download_url"]
else
UI.user_error!("Error when trying to upload build file to Tryouts: #{response.body}")
end
end
def self.upload_build(params)
require 'faraday'
require 'faraday_middleware'
url = TRYOUTS_API_BUILD_RELEASE_TEMPLATE % params[:app_id]
connection = Faraday.new(url) do |builder|
builder.request(:multipart)
builder.request(:url_encoded)
builder.response(:json, content_type: /\bjson$/)
builder.use(FaradayMiddleware::FollowRedirects)
builder.adapter(:net_http)
end
options = {}
options[:build] = Faraday::UploadIO.new(params[:build_file], 'application/octet-stream')
if params[:notes_path]
options[:notes] = File.read(params[:notes_path])
elsif params[:notes]
options[:notes] = params[:notes]
end
options[:notify] = params[:notify].to_s
options[:status] = params[:status].to_s
post_request = connection.post do |req|
req.headers['Authorization'] = params[:api_token]
req.body = options
end
post_request.on_complete do |env|
yield(env[:status], env[:body]) if block_given?
end
end
def self.description
"Upload a new build to [Tryouts](https://tryouts.io/)"
end
def self.details
"More information: [http://tryouts.readthedocs.org/en/latest/releases.html#create-release](http://tryouts.readthedocs.org/en/latest/releases.html#create-release)"
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :app_id,
env_name: "TRYOUTS_APP_ID",
description: "Tryouts application hash",
verify_block: proc do |value|
UI.user_error!("No application identifier for Tryouts given, pass using `app_id: 'application id'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :api_token,
env_name: "TRYOUTS_API_TOKEN",
sensitive: true,
description: "API Token (api_key:api_secret) for Tryouts Access",
verify_block: proc do |value|
UI.user_error!("No API token for Tryouts given, pass using `api_token: 'token'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :build_file,
env_name: "TRYOUTS_BUILD_FILE",
description: "Path to your IPA or APK file. Optional if you use the _gym_ or _xcodebuild_ action",
default_value: Actions.lane_context[SharedValues::IPA_OUTPUT_PATH],
default_value_dynamic: true,
verify_block: proc do |value|
UI.user_error!("Couldn't find build file at path '#{value}'") unless File.exist?(value)
end),
FastlaneCore::ConfigItem.new(key: :notes,
env_name: "TRYOUTS_NOTES",
description: "Release notes",
optional: true),
FastlaneCore::ConfigItem.new(key: :notes_path,
env_name: "TRYOUTS_NOTES_PATH",
description: "Release notes text file path. Overrides the :notes parameter",
verify_block: proc do |value|
UI.user_error!("Couldn't find notes file at path '#{value}'") unless File.exist?(value)
end,
optional: true),
FastlaneCore::ConfigItem.new(key: :notify,
env_name: "TRYOUTS_NOTIFY",
description: "Notify testers? 0 for no",
type: Integer,
default_value: 1),
FastlaneCore::ConfigItem.new(key: :status,
env_name: "TRYOUTS_STATUS",
description: "2 to make your release public. Release will be distributed to available testers. 1 to make your release private. Release won't be distributed to testers. This also prevents release from showing up for SDK update",
verify_block: proc do |value|
available_options = ["1", "2"]
UI.user_error!("'#{value}' is not a valid 'status' value. Available options are #{available_options.join(', ')}") unless available_options.include?(value.to_s)
end,
type: Integer,
default_value: 2)
]
end
def self.example_code
[
'tryouts(
api_token: "...",
app_id: "application-id",
build_file: "test.ipa",
)'
]
end
def self.category
:beta
end
def self.output
[
['TRYOUTS_BUILD_INFORMATION', 'Contains release info like :application_name, :download_url. See http://tryouts.readthedocs.org/en/latest/releases.html#create-release']
]
end
def self.authors
["alicertel"]
end
def self.is_supported?(platform)
[:ios, :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/spaceship_stats.rb | fastlane/lib/fastlane/actions/spaceship_stats.rb | module Fastlane
module Actions
class SpaceshipStatsAction < Action
def self.run(params)
require 'fastlane_core/print_table'
require 'spaceship'
rows = []
Spaceship::StatsMiddleware.service_stats.each do |service, count|
rows << [service.name, service.auth_type, service.url, count]
end
puts("")
puts(Terminal::Table.new(
title: "Spaceship Stats",
headings: ["Service", "Auth Type", "URL", "Number of requests"],
rows: FastlaneCore::PrintTable.transform_output(rows)
))
puts("")
if params[:print_request_logs]
log_rows = []
Spaceship::StatsMiddleware.request_logs.each do |request_log|
log_rows << [request_log.auth_type, request_log.url]
end
puts("")
puts(Terminal::Table.new(
title: "Spaceship Request Log",
headings: ["Auth Type", "URL"],
rows: FastlaneCore::PrintTable.transform_output(log_rows)
))
puts("")
end
end
def self.url_name(url_prefix)
Spaceship::StatsMiddleware::URL_PREFIXES[url_prefix]
end
def self.description
"Print out Spaceship stats from this session (number of request to each domain)"
end
def self.is_supported?(platform)
true
end
def self.available_options
[
FastlaneCore::ConfigItem.new(key: :print_request_logs,
description: "Print all URLs requested",
type: Boolean,
default_value: false)
]
end
def self.example_code
[
'spaceship_stats'
]
end
def self.category
:misc
end
def self.author
"joshdholtz"
end
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.