Last time I stopped at build incrementation. Let's continue with better lanes:
# From
lane :release do
build_app 'Release'
end
# To
lane :release_patch do # | :release_minor | :release_patch | :release_quick_fix
release :major # | :minor | :patch | :quick_fix
end
# While the Hockey lanes changed to
lane :hockey_debug do
lane :hockey_beta do
build_app 'Debug' # | 'Beta'
endWhere the release(version) and the submit(binary_flag) methods looks like this:
def release(version)
# If we are submitting a quick fix, we don't really care what branch we are on
# as long as it contains the quick-fix text, to be sure we are where we want to be
if version == :release_quick_fix
# If current_branch doesn't include 'quick-fix', ensure to something that will surely fail
ensure_git_branch branch: 'quick-fix' unless @current_branch.include? 'quick-fix'
else
# This is a fastlane helper that checks if we are on the required branch
ensure_git_branch branch: 'development'
end
# This will increment the version, based on the kind of release
increment_version version
build_app
As you can see, all the logic was mitigated into 3, more concise, methods, build_app, submit and release. Now for the increment_version method:
def increment_version(type)
# In case the lane fails, we revert the version number
@previous_version = version_number
split = version_number.split '.'
if type == :major
split[0] = "#{split[0].to_i + 1}"
split[1] = '0'
Next time I will talk about tagging, committing, pull requesting or pushing and sending a message to Slack.