class FastlaneCraft::AppReleaseManager

Public Class Methods

new(schemes, project, branch, version = nil, build_version = nil, target_suffix = nil) click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 15
def initialize(schemes, project, branch, version = nil, build_version = nil, target_suffix = nil)
  raise 'Invalid Version' if version && !version_valid?(version)

  @scheme = schemes.first
  @branch = branch
  @target_suffix = target_suffix
  @project_controller = ProjectController.new(project, schemes)
  @version = version.nil? ? @project_controller.version : Version.new(version)
  @build_version = build_version
end

Public Instance Methods

archive() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 72
def archive
  cmd = "fastlane gym --configuration Release --scheme #{@scheme} --export_method app-store"
  raise "Archiving failed! Command execution error: '#{cmd}'" unless system(cmd)
end
bump_version() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 38
def bump_version
  msg = 'Given version is less than the actual app version'
  UI.user_error! msg if @version < @project_controller.version
  return unless @version > @project_controller.version

  @project_controller.set_version(@version)
  @project_controller.set_build_version(Version.new(@version.to_s + '.0'))
  UI.success "Version was successfully bumped to #{version_dump}"
end
curr_git_tag() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 92
def curr_git_tag
  return @version.to_s unless @target_suffix

  "#{@version}_#{@target_suffix}"
end
existing_git_tag() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 98
def existing_git_tag
  git_tags.detect do |t|
    tag_v = t.match(/[0-9.]+/)[0]
    version_valid?(tag_v) && Version.new(tag_v) == @version
  end
end
git_tags() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 105
def git_tags
  `git tag`.split("\n")
end
push_git_tag() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 77
def push_git_tag
  UI.message "going to push tag: #{curr_git_tag}"
  cmd = "git tag #{curr_git_tag} && git push --tags"
  raise "Tag push failed! Command execution error: '#{cmd}'" unless system(cmd)
end
push_version_bump() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 61
def push_version_bump
  cmd = "git pull origin HEAD:#{@branch}"
  raise "Git Pull Failed! Command execution error: '#{cmd}'" unless system(cmd)

  cmd = "git add . && git commit -m 'Bump version to #{version_dump}'"
  raise "Git Commit Failed! Command execution error: '#{cmd}'" unless system(cmd)

  cmd = "git push origin HEAD:#{@branch}"
  raise "Git Push Failed! Command execution error: '#{cmd}'" unless system(cmd)
end
release() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 26
def release
  bump_version
  archive
  upload_to_tf
  @build_version.nil? ? @project_controller.bump_build_version_patch : @project_controller.set_build_version(@build_version)
  update_env
  push_version_bump

  remove_existing_git_tag
  push_git_tag
end
remove_existing_git_tag() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 83
def remove_existing_git_tag
  tag = existing_git_tag
  return if tag.nil?

  UI.message "going to remove tag: #{tag}"
  cmd = "git tag -d #{tag} && git push origin :refs/tags/#{tag}"
  raise "Git tag deletion failed! Command execution error: '#{cmd}'" unless system(cmd)
end
update_env() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 55
def update_env
  ENV[SharedValues::APP_RELEASE_VERSION] = @project_controller.version.to_s
  ENV[SharedValues::APP_RELEASE_BUILD_NUMBER] = @project_controller.build_version.to_s
  ENV[SharedValues::APP_RELEASE_VERSION_TAG] = version_dump
end
upload_to_tf() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 48
def upload_to_tf
  # see more at https://github.com/fastlane/fastlane/issues/15390
  ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV"
  cmd = 'fastlane pilot upload --skip_submission --skip_waiting_for_build_processing'
  raise "TF uploading Failed! Command execution error: '#{cmd}'" unless system(cmd)
end
version_dump() click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 113
def version_dump
  "#{@project_controller.version}/#{@project_controller.build_version}"
end
version_valid?(version) click to toggle source
# File lib/fastlane-craft/app_release_manager.rb, line 109
def version_valid?(version)
  version.to_s.match?(/^\d{1,3}\.\d{1,3}\.\d{1,3}$/)
end