Class: Thrust::IPABuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/thrust/ipa_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(out, xcode_tools, agv_tool, git, app_config, deployment_config, deployment_target) ⇒ IPABuilder

Returns a new instance of IPABuilder.



3
4
5
6
7
8
9
10
11
# File 'lib/thrust/ipa_builder.rb', line 3

def initialize(out, xcode_tools, agv_tool, git, app_config, deployment_config, deployment_target)
  @out = out
  @xcode_tools = xcode_tools
  @agv_tool = agv_tool
  @git = git
  @app_config = app_config
  @deployment_config = deployment_config
  @deployment_target = deployment_target
end

Instance Method Details

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/thrust/ipa_builder.rb', line 13

def run
  @git.ensure_clean

  begin
    @git.checkout_tag(@deployment_config.tag) if @deployment_config.tag

    if @deployment_config.versioning_method != 'none'
      if @deployment_config.versioning_method == 'commits'
        @agv_tool.change_build_number(@git.commit_count, nil, @app_config.path_to_xcodeproj)
      elsif @deployment_config.versioning_method == 'timestamp-sha'
        @agv_tool.change_build_number(@git.current_commit, Time.now.utc.strftime('%y%m%d%H%M'), @app_config.path_to_xcodeproj)
      else
        @agv_tool.change_build_number(@git.current_commit, nil, @app_config.path_to_xcodeproj)
      end
    end

    app_name = @app_config.app_name
    target = @deployment_config.target || app_name

    ipa_file = @xcode_tools.cleanly_create_ipa(target, app_name, @app_config.distribution_certificate, @deployment_config.provisioning_search_query)

    @git.reset

    @out.puts "\n\n"
    @out.puts "Successfully built .ipa:".green
    @out.puts ipa_file
  rescue Exception => e
    @out.puts "\n\n"
    @out.puts e.message.red
    @out.puts "\n\n"

    @git.reset
    exit 1
  end
end