Class: FastlaneCraft::AppReleaseManager
- Inherits:
-
Object
- Object
- FastlaneCraft::AppReleaseManager
- Includes:
- FastlaneCore, Gem
- Defined in:
- lib/fastlane-craft/app_release_manager.rb
Instance Method Summary collapse
- #archive ⇒ Object
- #bump_version ⇒ Object
- #curr_git_tag ⇒ Object
- #existing_git_tag ⇒ Object
- #git_tags ⇒ Object
-
#initialize(schemes, project, branch, version = nil, build_version = nil, target_suffix = nil) ⇒ AppReleaseManager
constructor
A new instance of AppReleaseManager.
- #push_git_tag ⇒ Object
- #push_version_bump ⇒ Object
- #release ⇒ Object
- #remove_existing_git_tag ⇒ Object
- #update_env ⇒ Object
- #upload_to_tf ⇒ Object
- #version_dump ⇒ Object
- #version_valid?(version) ⇒ Boolean
Constructor Details
#initialize(schemes, project, branch, version = nil, build_version = nil, target_suffix = nil) ⇒ AppReleaseManager
Returns a new instance of AppReleaseManager.
15 16 17 18 19 20 21 22 23 24 |
# 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 |
Instance Method Details
#archive ⇒ Object
72 73 74 75 |
# 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 ⇒ Object
38 39 40 41 42 43 44 45 46 |
# 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 ⇒ Object
92 93 94 95 96 |
# 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 ⇒ Object
98 99 100 101 102 103 |
# File 'lib/fastlane-craft/app_release_manager.rb', line 98 def existing_git_tag .detect do |t| tag_v = t.match(/[0-9.]+/)[0] version_valid?(tag_v) && Version.new(tag_v) == @version end end |
#git_tags ⇒ Object
105 106 107 |
# File 'lib/fastlane-craft/app_release_manager.rb', line 105 def `git tag`.split("\n") end |
#push_git_tag ⇒ Object
77 78 79 80 81 |
# File 'lib/fastlane-craft/app_release_manager.rb', line 77 def push_git_tag UI. "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 ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# 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 ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# 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 ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/fastlane-craft/app_release_manager.rb', line 83 def remove_existing_git_tag tag = existing_git_tag return if tag.nil? UI. "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 ⇒ Object
55 56 57 58 59 |
# 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 ⇒ Object
48 49 50 51 52 53 |
# 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 ⇒ Object
113 114 115 |
# File 'lib/fastlane-craft/app_release_manager.rb', line 113 def version_dump "#{@project_controller.version}/#{@project_controller.build_version}" end |
#version_valid?(version) ⇒ Boolean
109 110 111 |
# 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 |