Class: IOSBox::Tools::Deploy
- Inherits:
-
Thor
- Object
- Thor
- IOSBox::Tools::Deploy
- Includes:
- Thor::Actions
- Defined in:
- lib/ios-box/tools/deploy.rb
Instance Method Summary collapse
Instance Method Details
#add(provider) ⇒ Object
11 12 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ios-box/tools/deploy.rb', line 11 def add(provider) iosbox = IOSBox.new pbx = PBXProject::PBXProject.new :file => File.join(iosbox.project_dir, iosbox.config.project, "project.pbxproj") pbx.parse # Find all configuration lists and check if we have already Ad Hoc configuration cfglists = pbx.find_item :type => PBXProject::PBXTypes::XCConfigurationList cfglists.each do |cfg| if cfg.buildConfigurations.select {|bc| bc.comment == "Ad Hoc"}.empty? puts "Copy Release => Ad Hoc" release = cfg.buildConfigurations.select {|bc| bc.comment == "Release"}.first.value bc = pbx.find_item :guid => release, :type => PBXProject::PBXTypes::XCBuildConfiguration adhoc = PBXProject::PBXTypes::XCBuildConfiguration.new adhoc.comment = "Ad Hoc" adhoc.name = PBXProject::PBXTypes::BasicValue.new(:value => '"Ad Hoc"') adhoc.buildSettings = bc.buildSettings pbx.add_item adhoc cfg.buildConfigurations << PBXProject::PBXTypes::BasicValue.new(:value => adhoc.guid, :comment => "Ad Hoc") cfg.defaultConfigurationName = "Release" end end pbx.write_to :file => File.join(iosbox.project_dir, iosbox.config.project, "project.pbxproj") # Copy scheme xcuserdata = File.join(iosbox.project_dir, iosbox.config.project, "xcuserdata", "#{ENV['USER']}.xcuserdatad") scheme = File.open(Dir[File.join(xcuserdata, "xcschemes", "*.xcscheme")].first) deploy = File.join(xcuserdata, "xcschemes", "Deploy.xcscheme") doc = Nokogiri::XML(scheme) # Get identifier blueprint_id = doc.xpath("//BuildableReference").first.attr("BlueprintIdentifier") # Change configuration of Archive action = doc.xpath("//ArchiveAction").first action.attribute("buildConfiguration").value = "Ad Hoc" # Add Post Action Nokogiri::XML::Builder.with(action) do |xml| xml.PostActions { xml.ExecutionAction(:ActionType => "Xcode.IDEStandardExecutionActionsCore.ExecutionActionType.ShellScriptAction") { xml.ActionContent(:title => "Run Script", :scriptText=> "(cd $PROJECT_DIR; ios-box deploy #{provider})") { xml.EnvironmentBuildable { xml.BuildableReference( :BuildableIdentifier => "primary", :BlueprintIdentifier => "C0B33A571451827A000B80A2", :BuildableName => "ios.app", :BlueprintName => "ios", :ReferencedContainer => "container:ios.xcodeproj") } } } } end File.open(deploy, 'w') {|io| io.puts doc.to_xml } # Configure provider send(provider, "config") end |
#testflight(config = nil) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/ios-box/tools/deploy.rb', line 77 def testflight(config = nil) iosbox = IOSBox.new if config == "config" # Config mode iosbox.config.testflight ||= {} iosbox.config.testflight['apitoken'] = shell.ask("Testflight API token:") iosbox.config.testflight['teamtoken'] = shell.ask("Testflight Team token:") iosbox.config.save exit end tf = ::IOSBox::Deploy::Testflight.new iosbox # Do we have archive path in buildcache if ENV['XCODE_VERSION_ACTUAL'] and ENV['CONFIGURATION'] == "Ad Hoc" # Always use fresh data if ran from XCode prod_path = ENV['ARCHIVE_PATH'] # Update cache puts iosbox.cache.inspect iosbox.cache[:"ad hoc"][:archive_path] = ENV['ARCHIVE_PATH'] iosbox.cache.save elsif iosbox.cache[:"ad hoc"][:archive_path] # Otherwise use build cache if exists prod_path = iosbox.cache[:"ad hoc"][:archive_path] else # Otherwise, require Xcode require_xcode end # Check that we have required keys if iosbox.config.testflight['apitoken'].nil? shell.error "Please set TestFlight API token (ios-box config set testflight_apitoken XXXXXX)" end if iosbox.config.testflight['teamtoken'].nil? shell.error "Please set TestFlight Team token (ios-box config set testflight_teamtoken XXXXXX)" end if iosbox.config.testflight['apitoken'].nil? or iosbox.config.testflight['teamtoken'].nil? tf.notify :name => "Deployment Failed", :title => "Testflight Deployment", :error => "Testflight has not been configured. Please run ios-box deploy testflight config" end puts "Deploying to TestFlight... Please wait..." ipa = tf.create_ipa prod_path dsym = tf.create_dsym prod_path # Creating build notes if ['notes'].nil? if iosbox.config.deploy['autonotes'] # Get last deployment last_deployed = iosbox.config.testflight['lastdeploy'] || iosbox.git.log.last.id # Get git changelog notes = "" iosbox.git.commits_between(last_deployed, 'HEAD').reverse_each do |commit| notes << commit..to_s + "\n" notes << commit..to_s.length.times.inject("") { |i,c| i + "=" } + "\n" notes << commit. + "\n" end end else if File.exists?(['notes']) notes = File.read(['notes']) else notes = ['notes'] end end if notes.empty? # Try to find TextMate mate = %x{which mate}.strip if File.exists?(mate) f = Tempfile.new('notes') f.write "Replace this with build notes." f.close system(mate, "--wait", f.path) notes = File.read(f) end end tf.deploy :file => ipa, :apitoken => iosbox.config.testflight['apitoken'], :teamtoken => iosbox.config.testflight['teamtoken'], :notes => notes, :dsym => dsym, :distribution => ['distribution'], :notify => ['notify'], :replace => ['replace'], :growl => iosbox.config.growl end |