From 868d0707d062149f7d3402d63835b8a9e260edfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Rodri=CC=81guez=20Troitin=CC=83o?= Date: Sat, 3 Sep 2011 22:47:52 +0200 Subject: [PATCH 01/37] Use information inside WorkspaceSettings to determine derived data directory. Based on information found in http://pilky.me/view/25 and my own tests. --- lib/beta_builder.rb | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 00ba547..681e08b 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -77,18 +77,35 @@ def ipa_name def built_app_path if build_dir == :derived - "#{derived_build_dir_from_build_output}/#{configuration}-iphoneos/#{app_file_name}" + "#{derived_build_dir}/#{configuration}-iphoneos/#{app_file_name}" else "#{build_dir}/#{configuration}-iphoneos/#{app_file_name}" end end - def derived_build_dir_from_build_output - output = File.read("build.output") - - # yes, this is truly horrible, but unless somebody else can find a better way... - reference = output.split("\n").grep(/^Validate(.*)\/Xcode\/DerivedData\/(.*)-(.*)/).first.split(" ").last - derived_data_directory = reference.split("/Build/Products/").first + def derived_build_dir + workspace_settings_path = File.join(workspace_path, 'xcuserdata', + "#{`whoami`.strip}.xcuserdatad", + 'WorkspaceSettings.xcsettings') + + # Check the derived data location style + workspace_settings = CFPropertyList.native_types( + CFPropertyList::List.new(:file => workspace_settings_path).value) + derived_data_location_style = workspace_settings['IDEWorkspaceUserSettings_DerivedDataLocationStyle'] + derived_data_directory = case derived_data_location_style + when 0 then # The standard DerivedData directory. + workspace_name = File.basename(workspace_path, '.xcworkspace') + derived_data_dir = File.expand_path('~/Library/Developer/Xcode/DerivedData') + + # Look in every directory named after our workspace for the + # info.plist that points back to our workspace. + Dir[File.join(derived_data_dir, "#{workspace_name}-*")].find do |d| + CFPropertyList.native_types(CFPropertyList::List.new(:file => "#{d}/info.plist").value)['WorkspacePath'] == workspace_path + end + when 1, 2 then # We have the full path, or relative path + workspace_settings['IDEWorkspaceUserSettings_DerivedDataCustomLocation'] + end + "#{derived_data_directory}/Build/Products/" end From f9fe8d872c3d62660f062571ecc2ef6c0a946bc5 Mon Sep 17 00:00:00 2001 From: Andy Rennard Date: Fri, 11 Nov 2011 17:06:31 +0000 Subject: [PATCH 02/37] Moved position of archive task deploy and prepare tasks would give the error: Don't know how to build task 'beta:archive' when used in conjunction with namespaces. Moving the archive task above the deployment_strategy section seems to fix this. --- lib/beta_builder.rb | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 57505c3..21596a0 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -149,7 +149,15 @@ def define FileUtils.mkdir('pkg/dist') FileUtils.mv("pkg/#{@configuration.ipa_name}", "pkg/dist") end - + + desc "Build and archive the app" + task :archive => :build do + puts "Archiving build..." + archive = BetaBuilder.archive(@configuration) + output_path = archive.save_to(@configuration.archive_path) + puts "Archive saved to #{output_path}." + end + if @configuration.deployment_strategy desc "Prepare your app for deployment" task :prepare => :package do @@ -168,13 +176,7 @@ def define end end - desc "Build and archive the app" - task :archive => :build do - puts "Archiving build..." - archive = BetaBuilder.archive(@configuration) - output_path = archive.save_to(@configuration.archive_path) - puts "Archive saved to #{output_path}." - end + end end end From ed7a3e4d68fd29e6d73def6d96aaa111b627304f Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Fri, 11 Nov 2011 23:09:48 -0800 Subject: [PATCH 03/37] Ftfy. --- lib/beta_builder/deployment_strategies/web.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index 7510d2b..c047867 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -4,21 +4,21 @@ class Web < Strategy def extended_configuration_for_strategy proc do def deployment_url - File.join(deploy_to, target.downcase, ipa_name) + File.join(deploy_to, ipa_name) end def manifest_url - File.join(deploy_to, target.downcase, "manifest.plist") + File.join(deploy_to, "manifest.plist") end def remote_installation_path - File.join(remote_directory, target.downcase) + File.join(remote_directory) end end end def prepare - plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}/Info.plist") + plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}.app/Info.plist") plist_data = CFPropertyList.native_types(plist.value) File.open("pkg/dist/manifest.plist", "w") do |io| io << %{ From aa4e235e68669e72f4c287e605ebead53a875275 Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Sat, 12 Nov 2011 11:57:38 -0800 Subject: [PATCH 04/37] Get these out of the built location, not the deploy payload section. --- lib/beta_builder/deployment_strategies/web.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index c047867..67e8b8f 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -18,7 +18,7 @@ def remote_installation_path end def prepare - plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}.app/Info.plist") + plist = CFPropertyList::List.new(:file => "#{@configuration.built_app_path}/Info.plist") plist_data = CFPropertyList.native_types(plist.value) File.open("pkg/dist/manifest.plist", "w") do |io| io << %{ From d26644b6b3ef5dcb0f12da5691de6f24df6cdb8a Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Sat, 12 Nov 2011 11:57:51 -0800 Subject: [PATCH 05/37] Package it up with Apple's script, not your own thing. --- lib/beta_builder.rb | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 57505c3..33f21b1 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -141,13 +141,16 @@ def define end FileUtils.rm_rf('pkg') && FileUtils.mkdir_p('pkg') - FileUtils.mkdir_p("pkg/Payload") - FileUtils.mv(@configuration.built_app_path, "pkg/Payload/#{@configuration.app_file_name}") - Dir.chdir("pkg") do - system("zip -r '#{@configuration.ipa_name}' Payload") - end +# FileUtils.mkdir_p("pkg/Payload") +# FileUtils.mv(@configuration.built_app_path, "pkg/Payload/#{@configuration.app_file_name}") +# Dir.chdir("pkg") do +# system("zip -r '#{@configuration.ipa_name}' Payload") +# end + + system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '/tmp/#{@configuration.ipa_name}' --sign 'iPhone Distribution: Virtual World Computing, LLC' --embed adhoc.mobileprovision") + FileUtils.mkdir('pkg/dist') - FileUtils.mv("pkg/#{@configuration.ipa_name}", "pkg/dist") + FileUtils.mv("/tmp/#{@configuration.ipa_name}", "pkg/dist") end if @configuration.deployment_strategy From 8fa80cac2453bbf770bfbd7d4d2073c57cac0ceb Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Sat, 12 Nov 2011 11:58:02 -0800 Subject: [PATCH 06/37] Indent these things betterly. --- lib/beta_builder/deployment_strategies/web.rb | 113 +++++++++--------- 1 file changed, 56 insertions(+), 57 deletions(-) diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index 67e8b8f..b85156a 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -21,65 +21,64 @@ def prepare plist = CFPropertyList::List.new(:file => "#{@configuration.built_app_path}/Info.plist") plist_data = CFPropertyList.native_types(plist.value) File.open("pkg/dist/manifest.plist", "w") do |io| - io << %{ - - - - - items - - - assets - - - kind - software-package - url - #{@configuration.deployment_url} - - - metadata - - bundle-identifier - #{plist_data['CFBundleIdentifier']} - bundle-version - #{plist_data['CFBundleVersion']} - kind - software - title - #{plist_data['CFBundleDisplayName']} - - - - - - } + io << %{ + + + + items + + + assets + + + kind + software-package + url + #{@configuration.deployment_url} + + + metadata + + bundle-identifier + #{plist_data['CFBundleIdentifier']} + bundle-version + #{plist_data['CFBundleVersion']} + kind + software + title + #{plist_data['CFBundleDisplayName']} + + + + + +} end File.open("pkg/dist/index.html", "w") do |io| - io << %{ - - - - - - Beta Download - - - -
- -

Link didn't work?
- Make sure you're visiting this page on your device, not your computer.

- - - } + io << %{ + + + + + Beta Download + + + +
+ +

Link didn't work?
+ Make sure you're visiting this page on your device, not your computer.

+
+ + +} end end From 754953ee51a8162290641cd6ba09416e644e273a Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Sat, 12 Nov 2011 18:45:22 -0800 Subject: [PATCH 07/37] Pulled out app-specific configuration. --- lib/beta_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 33f21b1..57e7ca3 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -147,7 +147,7 @@ def define # system("zip -r '#{@configuration.ipa_name}' Payload") # end - system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '/tmp/#{@configuration.ipa_name}' --sign 'iPhone Distribution: Virtual World Computing, LLC' --embed adhoc.mobileprovision") + system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '/tmp/#{@configuration.ipa_name}' --sign '#{@config.signing_identity}' --embed #{@configuration.provisioning_profile}") FileUtils.mkdir('pkg/dist') FileUtils.mv("/tmp/#{@configuration.ipa_name}", "pkg/dist") From 8727bc8c919ca05da88760e72f82e9ee02fd1fa9 Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Mon, 14 Nov 2011 18:44:03 -0800 Subject: [PATCH 08/37] Fix. --- lib/beta_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 57e7ca3..f2b4d8f 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -147,7 +147,7 @@ def define # system("zip -r '#{@configuration.ipa_name}' Payload") # end - system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '/tmp/#{@configuration.ipa_name}' --sign '#{@config.signing_identity}' --embed #{@configuration.provisioning_profile}") + system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '/tmp/#{@configuration.ipa_name}' --sign '#{@configuration.signing_identity}' --embed #{@configuration.provisioning_profile}") FileUtils.mkdir('pkg/dist') FileUtils.mv("/tmp/#{@configuration.ipa_name}", "pkg/dist") From bef32cf33a2258cf627d381eab06d6c7b328eb37 Mon Sep 17 00:00:00 2001 From: Daniel Staudigel Date: Mon, 14 Nov 2011 18:44:14 -0800 Subject: [PATCH 09/37] Include version string in the webpage. --- lib/beta_builder/deployment_strategies/web.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index b85156a..0ec694a 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -72,7 +72,7 @@ def prepare From 5d77fc757fbeafcedb896464dd3f47ce0b959672 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 6 Feb 2012 12:19:14 -0500 Subject: [PATCH 10/37] Add support for custom scp port. Closes #35 --- lib/beta_builder/deployment_strategies/web.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index 7510d2b..1524c69 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -16,7 +16,7 @@ def remote_installation_path end end end - + def prepare plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}/Info.plist") plist_data = CFPropertyList.native_types(plist.value) @@ -82,9 +82,20 @@ def prepare } end end - + def deploy - system("scp pkg/dist/* #{@configuration.remote_host}:#{@configuration.remote_installation_path}") + cmd = [] + + cmd.push "scp" + + if @configuration.remote_port + cmd.push "-P #{@configuration.remote_port}" + end + + cmd.push "pkg/dist/*" + cmd.push "#{@configuration.remote_host}:#{@configuration.remote_installation_path}" + + system(cmd.join(" ")) end end end From 1890622d4d68050278e363e6df3f1f0b740bd437 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 6 Feb 2012 12:26:05 -0500 Subject: [PATCH 11/37] Use relative paths instead of rubygems paths --- lib/beta_builder.rb | 42 +++++++++++------------ lib/beta_builder/deployment_strategies.rb | 4 +-- lib/betabuilder.rb | 2 +- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 878a6a7..b0987a0 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -2,9 +2,9 @@ require 'ostruct' require 'fileutils' require 'cfpropertylist' -require 'beta_builder/archived_build' -require 'beta_builder/deployment_strategies' -require 'beta_builder/build_output_parser' +require File.dirname(__FILE__) + '/beta_builder/archived_build' +require File.dirname(__FILE__) + '/beta_builder/deployment_strategies' +require File.dirname(__FILE__) + '/beta_builder/build_output_parser' module BetaBuilder class Tasks < ::Rake::TaskLib @@ -58,7 +58,7 @@ def build_arguments def archive_name app_name || target end - + def app_file_name raise ArgumentError, "app_name or target must be set in the BetaBuilder configuration block" if app_name.nil? && target.nil? if app_name @@ -67,7 +67,7 @@ def app_file_name "#{target}.app" end end - + def ipa_name if app_name "#{app_name}.ipa" @@ -75,7 +75,7 @@ def ipa_name "#{target}.ipa" end end - + def built_app_path if build_dir == :derived "#{derived_build_dir_from_build_output}/#{configuration}-iphoneos/#{app_file_name}" @@ -83,24 +83,24 @@ def built_app_path "#{build_dir}/#{configuration}-iphoneos/#{app_file_name}" end end - + def derived_build_dir_from_build_output output = BuildOutputParser.new(File.read("build.output")) - output.build_output_dir + output.build_output_dir end - + def built_app_dsym_path "#{built_app_path}.dSYM" end - + def dist_path File.join("pkg/dist") end - + def ipa_path File.join(dist_path, ipa_name) end - + def deploy_using(strategy_name, &block) if DeploymentStrategies.valid_strategy?(strategy_name.to_sym) self.deployment_strategy = DeploymentStrategies.build(strategy_name, self) @@ -110,28 +110,28 @@ def deploy_using(strategy_name, &block) end end end - + private - + def define namespace(@namespace) do desc "Build the beta release of the app" task :build => :clean do xcodebuild @configuration.build_arguments, "build" end - + task :clean do unless @configuration.skip_clean xcodebuild @configuration.build_arguments, "clean" end end - + desc "Package the beta release as an IPA file" task :package => :build do if @configuration.auto_archive Rake::Task["#{@namespace}:archive"].invoke end - + FileUtils.rm_rf('pkg') && FileUtils.mkdir_p('pkg') FileUtils.mkdir_p("pkg/Payload") FileUtils.mv(@configuration.built_app_path, "pkg/Payload/#{@configuration.app_file_name}") @@ -141,25 +141,25 @@ def define FileUtils.mkdir('pkg/dist') FileUtils.mv("pkg/#{@configuration.ipa_name}", "pkg/dist") end - + if @configuration.deployment_strategy desc "Prepare your app for deployment" task :prepare => :package do @configuration.deployment_strategy.prepare end - + desc "Deploy the beta using your chosen deployment strategy" task :deploy => :prepare do @configuration.deployment_strategy.deploy end - + desc "Deploy the last build" task :redeploy do @configuration.deployment_strategy.prepare @configuration.deployment_strategy.deploy end end - + desc "Build and archive the app" task :archive => :build do puts "Archiving build..." diff --git a/lib/beta_builder/deployment_strategies.rb b/lib/beta_builder/deployment_strategies.rb index 24a89f7..f2f4d98 100644 --- a/lib/beta_builder/deployment_strategies.rb +++ b/lib/beta_builder/deployment_strategies.rb @@ -34,6 +34,6 @@ def self.strategies end end -require 'beta_builder/deployment_strategies/web' -require 'beta_builder/deployment_strategies/testflight' +require File.dirname(__FILE__) + '/deployment_strategies/web' +require File.dirname(__FILE__) + '/deployment_strategies/testflight' diff --git a/lib/betabuilder.rb b/lib/betabuilder.rb index 98cdd18..0974f93 100644 --- a/lib/betabuilder.rb +++ b/lib/betabuilder.rb @@ -1 +1 @@ -require 'beta_builder' +require File.dirname(__FILE__) + '/beta_builder' From 8218a120eff1772e38b1977760d1af440bc24cc3 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Mon, 6 Feb 2012 13:45:37 -0500 Subject: [PATCH 12/37] * Use app_file_name, not app_name for Info.plist path * Add output when scp'ing --- lib/beta_builder/deployment_strategies/web.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/beta_builder/deployment_strategies/web.rb b/lib/beta_builder/deployment_strategies/web.rb index 1524c69..26a8744 100644 --- a/lib/beta_builder/deployment_strategies/web.rb +++ b/lib/beta_builder/deployment_strategies/web.rb @@ -18,7 +18,7 @@ def remote_installation_path end def prepare - plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_name}/Info.plist") + plist = CFPropertyList::List.new(:file => "pkg/Payload/#{@configuration.app_file_name}/Info.plist") plist_data = CFPropertyList.native_types(plist.value) File.open("pkg/dist/manifest.plist", "w") do |io| io << %{ @@ -95,7 +95,10 @@ def deploy cmd.push "pkg/dist/*" cmd.push "#{@configuration.remote_host}:#{@configuration.remote_installation_path}" - system(cmd.join(" ")) + cmd = cmd.join(" ") + + puts "* Running `#{cmd}`" + system(cmd) end end end From 264a168aa45dc8ccce5db2e0b12823c6511e8c48 Mon Sep 17 00:00:00 2001 From: Eric Allen Date: Tue, 17 Apr 2012 17:46:36 -0700 Subject: [PATCH 13/37] Detect build failures and abort Rake --- lib/beta_builder.rb | 3 ++- lib/beta_builder/build_output_parser.rb | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 878a6a7..959a60f 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -32,7 +32,7 @@ def initialize(namespace = :beta, &block) def xcodebuild(*args) # we're using tee as we still want to see our build output on screen - system("#{@configuration.xcodebuild_path} #{args.join(" ")} | tee build.output") + system("#{@configuration.xcodebuild_path} #{args.join(" ")} 2>&1 | tee build.output") end class Configuration < OpenStruct @@ -118,6 +118,7 @@ def define desc "Build the beta release of the app" task :build => :clean do xcodebuild @configuration.build_arguments, "build" + raise "** BUILD FAILED **" if BuildOutputParser.new(File.read("build.output")).failed? end task :clean do diff --git a/lib/beta_builder/build_output_parser.rb b/lib/beta_builder/build_output_parser.rb index ec8ff97..f0fe1bc 100644 --- a/lib/beta_builder/build_output_parser.rb +++ b/lib/beta_builder/build_output_parser.rb @@ -16,6 +16,10 @@ def build_output_dir derived_data_directory = reference.split("/Build/Products/").first "#{derived_data_directory}/Build/Products/" end + + def failed? + @output.split("\n").any? {|line| line.include? "** BUILD FAILED **"} + end end end From ec5bfc5f940db510b1bd5c43211286b5f0642cb7 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Tue, 24 Apr 2012 15:00:53 -0400 Subject: [PATCH 14/37] Fixing CFBundleIconFiles for me. Its a nested attribute under CFBundleIcons for our project. --- lib/beta_builder/archived_build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder/archived_build.rb b/lib/beta_builder/archived_build.rb index d9639e0..0971d49 100644 --- a/lib/beta_builder/archived_build.rb +++ b/lib/beta_builder/archived_build.rb @@ -76,7 +76,7 @@ def write_plist_to(path) "ApplicationPath" => File.join("Applications", @configuration.app_file_name), "CFBundleIdentifier" => metadata["CFBundleIdentifier"], "CFBundleShortVersionString" => version, - "IconPaths" => metadata["CFBundleIconFiles"].map { |file| File.join("Applications", @configuration.app_file_name, file) } + "IconPaths" => metadata["CFBundleIcons"]["CFBundlePrimaryIcon"]["CFBundleIconFiles"].map { |file| File.join("Applications", @configuration.app_file_name, file) } }, "ArchiveVersion" => 1.0, "Comment" => @configuration.release_notes_text, From 8d3828df3691b2f522ee7ed9507714aeca406d91 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Tue, 24 Apr 2012 23:54:32 -0400 Subject: [PATCH 15/37] changing case on require statement --- lib/beta_builder/archived_build.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder/archived_build.rb b/lib/beta_builder/archived_build.rb index 0971d49..a79ac1c 100644 --- a/lib/beta_builder/archived_build.rb +++ b/lib/beta_builder/archived_build.rb @@ -1,6 +1,6 @@ require 'uuid' require 'fileutils' -require 'CFPropertyList' +require 'cfpropertylist' module BetaBuilder def self.archive(configuration) From 1f7ac28d2dc5b6439481fd125d6053e02afc9034 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Tue, 24 Apr 2012 23:54:51 -0400 Subject: [PATCH 16/37] Streamlining and adding the option to set a version number (from Git) --- lib/beta_builder.rb | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 7a2853a..a42a0e8 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -23,7 +23,8 @@ def initialize(namespace = :beta, &block) :xcode4_archive_mode => false, :skip_clean => false, :verbose => false, - :dry_run => false + :dry_run => false, + :set_version_number => false ) @namespace = namespace yield @configuration if block_given? @@ -52,6 +53,10 @@ def build_arguments args << " -arch \"#{arch}\"" unless arch.nil? + if set_version_number + args << " VERSION_LONG=#{build_number_git}" + end + args end @@ -94,13 +99,17 @@ def built_app_dsym_path end def dist_path - File.join("pkg/dist") + File.join(derived_build_dir_from_build_output, "pkg") end def ipa_path File.join(dist_path, ipa_name) end + def build_number_git + `git describe --tags --long`.chop + end + def deploy_using(strategy_name, &block) if DeploymentStrategies.valid_strategy?(strategy_name.to_sym) self.deployment_strategy = DeploymentStrategies.build(strategy_name, self) @@ -115,34 +124,29 @@ def deploy_using(strategy_name, &block) def define namespace(@namespace) do - desc "Build the beta release of the app" - task :build => :clean do - xcodebuild @configuration.build_arguments, "build" - end + desc "Clean the Build" task :clean do unless @configuration.skip_clean xcodebuild @configuration.build_arguments, "clean" end end + desc "Build the beta release of the app" + task :build => :clean do + xcodebuild @configuration.build_arguments, "build" + end + desc "Package the beta release as an IPA file" task :package => :build do if @configuration.auto_archive Rake::Task["#{@namespace}:archive"].invoke end - - FileUtils.rm_rf('pkg') && FileUtils.mkdir_p('pkg') -# FileUtils.mkdir_p("pkg/Payload") -# FileUtils.mv(@configuration.built_app_path, "pkg/Payload/#{@configuration.app_file_name}") -# Dir.chdir("pkg") do -# system("zip -r '#{@configuration.ipa_name}' Payload") -# end - system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '/tmp/#{@configuration.ipa_name}' --sign '#{@configuration.signing_identity}' --embed #{@configuration.provisioning_profile}") + FileUtils.rm_rf("#{@configuration.dist_path}") + FileUtils.mkdir_p("#{@configuration.dist_path}") + system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '#{@configuration.ipa_path}' --sign '#{@configuration.signing_identity}' --embed #{@configuration.provisioning_profile}") - FileUtils.mkdir('pkg/dist') - FileUtils.mv("/tmp/#{@configuration.ipa_name}", "pkg/dist") end if @configuration.deployment_strategy From bf09e4aa977415b5f6aa38da97198c40b5d534e7 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 00:02:07 -0400 Subject: [PATCH 17/37] Changing version and adding my info --- Rakefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index b70e809..f525cc0 100644 --- a/Rakefile +++ b/Rakefile @@ -15,11 +15,11 @@ spec = Gem::Specification.new do |s| # Change these as appropriate s.name = "betabuilder" - s.version = "0.7.4.1" + s.version = "0.7.5" s.summary = "A set of Rake tasks and utilities for managing iOS ad-hoc builds" - s.author = "Luke Redpath" - s.email = "luke@lukeredpath.co.uk" - s.homepage = "http://github.com/lukeredpath/betabuilder" + s.authors = ["Luke Redpath", "Nick Peelman"] + s.email = ["luke@lukeredpath.co.uk", "nick@peelman.us"] + s.homepage = "http://github.com/peelman/betabuilder" s.has_rdoc = false s.extra_rdoc_files = %w(README.md LICENSE CHANGES.md) From 8a64507fa1be4375f1fb513b21cefc91997f61f7 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 00:19:12 -0400 Subject: [PATCH 18/37] Updating gemspec as well --- betabuilder.gemspec | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/betabuilder.gemspec b/betabuilder.gemspec index 609e718..cb73199 100644 --- a/betabuilder.gemspec +++ b/betabuilder.gemspec @@ -1,20 +1,20 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = "betabuilder" - s.version = "0.7.4.1" - + s.name = "betabuilder" + s.version = "0.7.5" + s.summary = "A set of Rake tasks and utilities for managing iOS ad-hoc builds" + s.authors = ["Luke Redpath", "Nick Peelman"] + s.email = ["luke@lukeredpath.co.uk", "nick@peelman.us"] + s.homepage = "http://github.com/peelman/betabuilder" + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Luke Redpath"] - s.date = "2011-11-16" - s.email = "luke@lukeredpath.co.uk" + s.date = "2012-04-25" s.extra_rdoc_files = ["README.md", "LICENSE", "CHANGES.md"] s.files = ["CHANGES.md", "LICENSE", "README.md", "lib/beta_builder/archived_build.rb", "lib/beta_builder/build_output_parser.rb", "lib/beta_builder/deployment_strategies/testflight.rb", "lib/beta_builder/deployment_strategies/web.rb", "lib/beta_builder/deployment_strategies.rb", "lib/beta_builder.rb", "lib/betabuilder.rb"] - s.homepage = "http://github.com/lukeredpath/betabuilder" s.rdoc_options = ["--main", "README.md"] s.require_paths = ["lib"] s.rubygems_version = "1.8.11" - s.summary = "A set of Rake tasks and utilities for managing iOS ad-hoc builds" if s.respond_to? :specification_version then s.specification_version = 3 From 02b2c5ea64b5e6a59b6c7a3705dd5f192e744562 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 01:00:47 -0400 Subject: [PATCH 19/37] Making the output path for IPAs configurable; defaults to the working directory. --- lib/beta_builder.rb | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index a42a0e8..2bcebc0 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -17,6 +17,7 @@ def initialize(namespace = :beta, &block) :xcodebuild_path => "xcodebuild", :project_file_path => nil, :workspace_path => nil, + :ipa_destination_path => "./", :scheme => nil, :app_name => nil, :arch => nil, @@ -98,12 +99,8 @@ def built_app_dsym_path "#{built_app_path}.dSYM" end - def dist_path - File.join(derived_build_dir_from_build_output, "pkg") - end - def ipa_path - File.join(dist_path, ipa_name) + File.join(File.expand_path(ipa_destination_path), ipa_name) end def build_number_git @@ -142,9 +139,7 @@ def define if @configuration.auto_archive Rake::Task["#{@namespace}:archive"].invoke end - - FileUtils.rm_rf("#{@configuration.dist_path}") - FileUtils.mkdir_p("#{@configuration.dist_path}") + system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '#{@configuration.ipa_path}' --sign '#{@configuration.signing_identity}' --embed #{@configuration.provisioning_profile}") end From 01c4f806a9ce156965f8123a29974537c8b2c3d0 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 12:54:43 -0400 Subject: [PATCH 20/37] Adding configuration to enable adding extra Xcodebuild arguments --- lib/beta_builder.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 2bcebc0..bf9bd96 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -15,6 +15,7 @@ def initialize(namespace = :beta, &block) :auto_archive => false, :archive_path => File.expand_path("~/Library/Developer/Xcode/Archives"), :xcodebuild_path => "xcodebuild", + :xcodeargs => nil, :project_file_path => nil, :workspace_path => nil, :ipa_destination_path => "./", @@ -54,9 +55,11 @@ def build_arguments args << " -arch \"#{arch}\"" unless arch.nil? - if set_version_number - args << " VERSION_LONG=#{build_number_git}" - end + + args << " VERSION_LONG=#{build_number_git}" if set_version_number + + args << " #{xcodeargs}" unless xcodeargs.nil? + args end From 431875ad37a8c81227386c01d8632075027206e8 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 13:04:34 -0400 Subject: [PATCH 21/37] Joining file paths properly... --- lib/beta_builder.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index bf9bd96..3064ad1 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -87,9 +87,9 @@ def ipa_name def built_app_path if build_dir == :derived - "#{derived_build_dir_from_build_output}/#{configuration}-iphoneos/#{app_file_name}" + File.join("#{derived_build_dir_from_build_output}", "#{configuration}-iphoneos", "#{app_file_name}") else - "#{build_dir}/#{configuration}-iphoneos/#{app_file_name}" + File.join("#{build_dir}", "#{configuration}-iphoneos", "#{app_file_name}") end end From bcece3f8214960176b8b3a9a459ec7d8c683fab9 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 13:19:00 -0400 Subject: [PATCH 22/37] Wrapping provisioning profile in single quotes... --- lib/beta_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 3064ad1..4b56f24 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -143,7 +143,7 @@ def define Rake::Task["#{@namespace}:archive"].invoke end - system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '#{@configuration.ipa_path}' --sign '#{@configuration.signing_identity}' --embed #{@configuration.provisioning_profile}") + system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '#{@configuration.ipa_path}' --sign '#{@configuration.signing_identity}' --embed '#{@configuration.provisioning_profile}'") end From 05a07072fad765597cc21c4879562db259c564f9 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Wed, 25 Apr 2012 18:05:00 -0400 Subject: [PATCH 23/37] Updating Readme --- README.md | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1f55b05..b13ddd5 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,52 @@ To use a namespace other than "beta" for the generated tasks, simply pass in you This lets you set up different sets of BetaBuilder tasks for different configurations in the same Rakefile (e.g. a production and staging build). +## Configuration +A full list of configuration options and their details + +`configuration` - (String) The Xcode Configuration to use (Defined on the Info tab of the Project) + +`build_dir` - (File Path) The directory the build output will be. (`:derived` for Xcode 4 for versions < 0.8) + +`auto_archive` - (true/**false**) Automatically archive when packaging + +`archive_path` - (File Path) Path to the Archives + +`xcodebuild_path` - (File Path) Path to xcodebuild, if its non-standard + +`xcodeargs` - (Arguments) Arguments passed to `xcodebuild` when it runs + +`project_file_path` - (File Path) Path to the `.xcodeproj` file + +`workspace_path` - (File Path) Path to the `.xcworkspace` file + +`ipa_destination_path` - (File Path) Path to output Packaged IPA to + +`scheme` - (String) What Scheme to use when building + +`app_name` - (String) The name of the app being built (should match the file name, less the `.app` extension) + +`arch` - (String) The architecture to build for, if different from project settings + +`xcode4_archive_mode` - (true/**false**) Use Xcode4's Archive mode + +`skip_clean` - (true/**false**) Skip the clean step when building + +`verbose` - (true/**false**) Increased output for debugging + +`dry_run` - (true/**false**) Don't upload to Distribution Strategy, just act like it + +`set_version_number` - (true/**false**) Attempts to set a version number, see below + +### Configuration (Testflight) +Testflight presents its own set of options that can be configured + +`api_token` - (String) Can be your API key, but its recommended to use an `ENV[""]` variable +`team_token` - (String) Your Team's Testflight API token +`distribution_lists` - (Array) A Ruby array (`[1,2]` or `%w{1 2}`) of distribution list names for Testflight +`notify` - (true/**false**) Notify the distribution list of this build +`replace` - (true/**false**) Replace if an existing build exists with the same ID and version + ## Xcode 4 support Betabuilder works with Xcode 4, but you may need to tweak your task configuration slightly. The most important change you will need to make is the build directory location, unless you have configured Xcode 4 to use the "build" directory relative to your project, as in Xcode 3. @@ -81,13 +127,29 @@ If you are working with an Xcode 4 workspace instead of a project file, you will config.workspace_path = "MyWorkspace.xcworkspace" config.scheme = "My App Scheme" config.app_name = "MyApp" - + set_version_number If you are using a workspace, then you must specify the scheme. You can still specify the build configuration (e.g. Release). ## Automatic deployment with deployment strategies BetaBuilder allows you to deploy your built package using it's extensible deployment strategy system; the gem currently comes with support for simple web-based deployment or uploading to [TestFlightApp.com](http://www.testflightapp.com). Eventually, you will be able to write your own custom deployment strategies if neither of these are suitable for your needs. +## Setting version numbers automatically + +You can use betabuilder to set a build number using Git's `describe` system. In order for that to work, at least one `tag` must exist somewhere in the git hierarchy for the branch being built from. + +Also, you are required to set your `CFBundleVersion` to `${VERSION_LONG}` inside your `Info.plist`. To accomodate manual builds, add a `VERSION_LONG` Build Setting to your app's Project, and treat it as you normally would your `Info.plist` version number. + +Once a tag is created and your App is configured, simply add this to your BetaBuilder config and it will use Git to generate the + + config.set_version_number = true + +It will generate a version number like: `1.0-15-g6b3c1bb`. + +* *1.0* is the most recent tag +* *15* is the number of commits since the tag was generated +* *g6b3c1bb* is the beginning of the hash of the last commit. + ### Deploying your app with TestFlight By far the easiest way to get your beta release into the hands of your testers is using the excellent [TestFlight service](http://testflightapp.com/), although at the time of writing it is still in private beta. You can use TestFlight to manage your beta testers and notify them of new releases instantly. From d9b90cb9f054cd5d510770c2c7a35d4d50ffc9d7 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Fri, 27 Apr 2012 11:40:53 -0400 Subject: [PATCH 24/37] Updating Readme --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index b13ddd5..88cbe3a 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,27 @@ A full list of configuration options and their details Testflight presents its own set of options that can be configured `api_token` - (String) Can be your API key, but its recommended to use an `ENV[""]` variable + `team_token` - (String) Your Team's Testflight API token + `distribution_lists` - (Array) A Ruby array (`[1,2]` or `%w{1 2}`) of distribution list names for Testflight + `notify` - (true/**false**) Notify the distribution list of this build + `replace` - (true/**false**) Replace if an existing build exists with the same ID and version +### Configuration (Web) +Pushing to a web server has the following options. + +SSH keys will simplify authentication and make this process seamless + +`remote_host` - (String) Hostname for the server the build will be pushed to + +`remote_port` - (String) Port Number to use for SCP/SFTP + +`remote_installation_path` - (String) Remote Path + + ## Xcode 4 support Betabuilder works with Xcode 4, but you may need to tweak your task configuration slightly. The most important change you will need to make is the build directory location, unless you have configured Xcode 4 to use the "build" directory relative to your project, as in Xcode 3. From 9a3fe7e07c1a15b178080867505eb7767e852091 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Fri, 27 Apr 2012 12:10:06 -0400 Subject: [PATCH 25/37] Refactoring a bit Raise errors if you try to package without setting a signing identity Raise errors if you try to package without setting a provisioning profile --- lib/beta_builder.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 38e96ca..b52fe8f 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -142,8 +142,22 @@ def define if @configuration.auto_archive Rake::Task["#{@namespace}:archive"].invoke end - - system("/usr/bin/xcrun -sdk iphoneos PackageApplication -v '#{@configuration.built_app_path}' -o '#{@configuration.ipa_path}' --sign '#{@configuration.signing_identity}' --embed '#{@configuration.provisioning_profile}'") + + raise "** PACKAGE FAILED ** No Signing Identity Found" unless @configuration.signing_identity + raise "** PACKAGE FAILED ** No Provisioning Profile Found" unless @configuration.provisioning_profile + + # Construct the IPA and Sign it + cmd = [] + cmd.push "/usr/bin/xcrun" + cmd.push "-sdk iphoneos" + cmd.push "PackageApplication" + cmd.push "-v '#{@configuration.built_app_path}'" + cmd.push "-o '#{@configuration.ipa_path}'" + cmd.push "--sign '#{@configuration.signing_identity}'" + cmd.push "--embed '#{@configuration.provisioning_profile}'" + cmd = cmd.join(" ") + puts "Running #{cmd}" + system(cmd) end From 8c0a7b853910b4c8dcb6301a8b736364abb88049 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Fri, 27 Apr 2012 17:11:38 -0400 Subject: [PATCH 26/37] Updating Changelog --- CHANGES.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index c6c9b42..9fe1264 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,12 @@ +## 0.7.5 +* Allows automation of version/build number setting +* Allows custom SCP ports (@smtlaissezfaire) +* Fixes Archive task failure (@rennarda) +* Uses Apple's Packager to produce valid IPAs (@dts) +* Fixes cases where CFPropertyList could fail to load (@svelix) +* Uses relative paths for requires (@smtlaissezfaire) +* Raises an exception if the build fails (@epall) + ## 0.7.4.1 * Allow auto-archiving from other Rake namespaces (@victor) * Fixed bug with Xcode archive sharing (@victor) From fc391a2806ff64dd2a447a24c046f4cf8677ad3b Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Fri, 27 Apr 2012 19:21:14 -0400 Subject: [PATCH 27/37] Adding full paths to xcodebuild and xcrun; they are override-able in the config Adding ability to add arguments to package command Changing argument / command structure Making build and signing output optional (use config.verbose to trigger) Adding simplified output --- lib/beta_builder.rb | 71 ++++++++++++------- lib/beta_builder/deployment_strategies.rb | 2 +- .../deployment_strategies/testflight.rb | 8 ++- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index b52fe8f..0af6100 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -14,8 +14,10 @@ def initialize(namespace = :beta, &block) :build_dir => "build", :auto_archive => false, :archive_path => File.expand_path("~/Library/Developer/Xcode/Archives"), - :xcodebuild_path => "xcodebuild", + :xcodebuild_path => "/usr/bin/xcodebuild", + :xcrun_path => "/usr/bin/xcrun", :xcodeargs => nil, + :packageargs => nil, :project_file_path => nil, :workspace_path => nil, :ipa_destination_path => "./", @@ -35,7 +37,13 @@ def initialize(namespace = :beta, &block) def xcodebuild(*args) # we're using tee as we still want to see our build output on screen - system("#{@configuration.xcodebuild_path} #{args.join(" ")} 2>&1 | tee build.output") + cmd = [] + cmd << @configuration.xcodebuild_path + cmd.concat args + puts "Running: #{cmd.join("")}" if @configuration.verbose + cmd << "2>&1 %s build.output" % (@configuration.verbose ? '| tee' : '>') + cmd = cmd.join(" ") + system(cmd) end class Configuration < OpenStruct @@ -44,22 +52,25 @@ def release_notes_text release_notes end def build_arguments - args = "" + args = [] if workspace_path raise "A scheme is required if building from a workspace" unless scheme - args << "-workspace '#{workspace_path}' -scheme '#{scheme}' -configuration '#{configuration}'" + args << "-workspace '#{workspace_path}'" + args << "-scheme '#{scheme}'" else - args = "-target '#{target}' -configuration '#{configuration}' -sdk iphoneos" - args << " -project #{project_file_path}" if project_file_path + args << "-target '#{target}'" + args << "-sdk iphoneos" + args << "-project '#{project_file_path}'" if project_file_path end - - args << " -arch \"#{arch}\"" unless arch.nil? - - - args << " VERSION_LONG=#{build_number_git}" if set_version_number - args << " #{xcodeargs}" unless xcodeargs.nil? - + args << "-configuration '#{configuration}'" + args << "-arch '#{arch}'" unless arch.nil? + args << "VERSION_LONG='#{build_number_git}'" if set_version_number + + if xcodeargs + args.concat xcodeargs if xcodeargs.is_an Array + args << "#{xcodeargs}" if xcodears.is_a String + end args end @@ -127,14 +138,18 @@ def define desc "Clean the Build" task :clean do unless @configuration.skip_clean + print "Cleaning Project..." xcodebuild @configuration.build_arguments, "clean" + puts "Done" end end desc "Build the beta release of the app" task :build => :clean do + print "Building Project..." xcodebuild @configuration.build_arguments, "build" raise "** BUILD FAILED **" if BuildOutputParser.new(File.read("build.output")).failed? + puts "Done" end desc "Package the beta release as an IPA file" @@ -142,23 +157,31 @@ def define if @configuration.auto_archive Rake::Task["#{@namespace}:archive"].invoke end - + print "Packaging and Signing..." raise "** PACKAGE FAILED ** No Signing Identity Found" unless @configuration.signing_identity raise "** PACKAGE FAILED ** No Provisioning Profile Found" unless @configuration.provisioning_profile # Construct the IPA and Sign it cmd = [] - cmd.push "/usr/bin/xcrun" - cmd.push "-sdk iphoneos" - cmd.push "PackageApplication" - cmd.push "-v '#{@configuration.built_app_path}'" - cmd.push "-o '#{@configuration.ipa_path}'" - cmd.push "--sign '#{@configuration.signing_identity}'" - cmd.push "--embed '#{@configuration.provisioning_profile}'" + cmd << @configuration.xcrun_path + cmd << "-sdk iphoneos" + cmd << "PackageApplication" + cmd << "-v '#{@configuration.built_app_path}'" + cmd << "-o '#{@configuration.ipa_path}'" + cmd << "--sign '#{@configuration.signing_identity}'" + cmd << "--embed '#{@configuration.provisioning_profile}'" + if @configuration.packageargs + cmd.concat @configuration.packageargs if @configuration.packageargs.is_an Array + cmd << @configuration.packageargs if @configuration.packageargs.is_a String + end + puts "Running #{cmd.join(" ")}" if @configuration.verbose + cmd << "2>&1 %s build.output" % (@configuration.verbose ? '| tee' : '>') cmd = cmd.join(" ") - puts "Running #{cmd}" system(cmd) - + + puts "Done" + + puts "IPA File: #{@configuration.ipa_path}" if @configuration.verbose end desc "Build and archive the app" @@ -186,8 +209,6 @@ def define @configuration.deployment_strategy.deploy end end - - end end end diff --git a/lib/beta_builder/deployment_strategies.rb b/lib/beta_builder/deployment_strategies.rb index f2f4d98..4520ebd 100644 --- a/lib/beta_builder/deployment_strategies.rb +++ b/lib/beta_builder/deployment_strategies.rb @@ -22,7 +22,7 @@ def configure(&block) end def prepare - puts "Nothing to prepare!" + puts "Nothing to prepare!" if @configuration.verbose end end diff --git a/lib/beta_builder/deployment_strategies/testflight.rb b/lib/beta_builder/deployment_strategies/testflight.rb index 41250aa..f83e9e7 100644 --- a/lib/beta_builder/deployment_strategies/testflight.rb +++ b/lib/beta_builder/deployment_strategies/testflight.rb @@ -27,7 +27,6 @@ def deploy :notify => @configuration.notify || false, :replace => @configuration.replace || false } - puts "Uploading build to TestFlight..." if @configuration.verbose puts "ipa path: #{@configuration.ipa_path}" puts "release notes: #{release_notes}" @@ -38,6 +37,8 @@ def deploy return end + print "Uploading build to TestFlight..." + begin response = RestClient.post(ENDPOINT, payload, :accept => :json) rescue => e @@ -45,9 +46,10 @@ def deploy end if (response.code == 201) || (response.code == 200) - puts "Upload complete." + puts "Done." else - puts "Upload failed. (#{response})" + puts "Failed." + puts "#{response}" end end From 58bd5751cefe369aea073c0a6440df072b1184cd Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Fri, 27 Apr 2012 19:23:16 -0400 Subject: [PATCH 28/37] Updating Changelog --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 9fe1264..18a20b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ ## 0.7.5 * Allows automation of version/build number setting +* Adds full paths to xcodebuild and xcrun; they are override-able in the config +* Adds ability to add arguments to package command +* Refactors commands and argument code +* Makes build and signing output optional (use config.verbose to trigger) +* Adds simplified output * Allows custom SCP ports (@smtlaissezfaire) * Fixes Archive task failure (@rennarda) * Uses Apple's Packager to produce valid IPAs (@dts) @@ -7,6 +12,7 @@ * Uses relative paths for requires (@smtlaissezfaire) * Raises an exception if the build fails (@epall) + ## 0.7.4.1 * Allow auto-archiving from other Rake namespaces (@victor) * Fixed bug with Xcode archive sharing (@victor) From 5d4290dc5ec9ac99e547ca7b16d690f8dfd48f98 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 30 Apr 2012 20:52:29 -0400 Subject: [PATCH 29/37] Adding the option to do set Skip Clean, Verbose mode, and Dry Run from the command line via Environment variables. --- lib/beta_builder.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 0af6100..2404b3c 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -25,9 +25,9 @@ def initialize(namespace = :beta, &block) :app_name => nil, :arch => nil, :xcode4_archive_mode => false, - :skip_clean => false, - :verbose => false, - :dry_run => false, + :skip_clean => ENV['SKIPCLEAN'] || false, + :verbose => ENV['VERBOSE'] || false, + :dry_run => ENV['DRY'] || false, :set_version_number => false ) @namespace = namespace From 5362ab96d085196dbb62d711895b0ec1a44294f8 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 30 Apr 2012 21:05:35 -0400 Subject: [PATCH 30/37] Adding a space, fixing some is_a?s. --- lib/beta_builder.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 2404b3c..4489722 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -40,7 +40,7 @@ def xcodebuild(*args) cmd = [] cmd << @configuration.xcodebuild_path cmd.concat args - puts "Running: #{cmd.join("")}" if @configuration.verbose + puts "Running: #{cmd.join(" ")}" if @configuration.verbose cmd << "2>&1 %s build.output" % (@configuration.verbose ? '| tee' : '>') cmd = cmd.join(" ") system(cmd) @@ -68,8 +68,8 @@ def build_arguments args << "VERSION_LONG='#{build_number_git}'" if set_version_number if xcodeargs - args.concat xcodeargs if xcodeargs.is_an Array - args << "#{xcodeargs}" if xcodears.is_a String + args.concat xcodeargs if xcodeargs.is_a? Array + args << "#{xcodeargs}" if xcodears.is_a? String end args @@ -171,8 +171,8 @@ def define cmd << "--sign '#{@configuration.signing_identity}'" cmd << "--embed '#{@configuration.provisioning_profile}'" if @configuration.packageargs - cmd.concat @configuration.packageargs if @configuration.packageargs.is_an Array - cmd << @configuration.packageargs if @configuration.packageargs.is_a String + cmd.concat @configuration.packageargs if @configuration.packageargs.is_a? Array + cmd << @configuration.packageargs if @configuration.packageargs.is_a? String end puts "Running #{cmd.join(" ")}" if @configuration.verbose cmd << "2>&1 %s build.output" % (@configuration.verbose ? '| tee' : '>') From b64224eba94bd262340f60b4685db1a4ce9f036f Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 30 Apr 2012 22:04:59 -0400 Subject: [PATCH 31/37] Better ENV handling (thanks @cdmwebs) --- lib/beta_builder.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 4489722..b1379ea 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -25,9 +25,9 @@ def initialize(namespace = :beta, &block) :app_name => nil, :arch => nil, :xcode4_archive_mode => false, - :skip_clean => ENV['SKIPCLEAN'] || false, - :verbose => ENV['VERBOSE'] || false, - :dry_run => ENV['DRY'] || false, + :skip_clean => ENV.fetch('SKIPCLEAN', false), + :verbose => ENV.fetch('VERBOSE', false), + :dry_run => ENV.fetch('DRY', false), :set_version_number => false ) @namespace = namespace From 479992be678df66da5a639b2943a29fa6713d602 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 21 May 2012 14:45:37 -0400 Subject: [PATCH 32/37] Adding Rake::DSL include to avoid deprecation issue... --- lib/beta_builder/deployment_strategies/testflight.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/beta_builder/deployment_strategies/testflight.rb b/lib/beta_builder/deployment_strategies/testflight.rb index f83e9e7..3afbaa1 100644 --- a/lib/beta_builder/deployment_strategies/testflight.rb +++ b/lib/beta_builder/deployment_strategies/testflight.rb @@ -6,6 +6,8 @@ module BetaBuilder module DeploymentStrategies class TestFlight < Strategy + include Rake::DSL + include FileUtils ENDPOINT = "https://testflightapp.com/api/builds.json" def extended_configuration_for_strategy From 1083e2cd8fe7cace6c6d89150150c038e82a7847 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 21 May 2012 16:10:20 -0400 Subject: [PATCH 33/37] Updating readme --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 88cbe3a..2a439ae 100644 --- a/README.md +++ b/README.md @@ -123,6 +123,20 @@ SSH keys will simplify authentication and make this process seamless `remote_installation_path` - (String) Remote Path +### Configuration (RunTime) +Certain configuration options are availabe at the command line, so that you can temporarily set them for a single run without modifying your configuration. + +Pass any of these in as environment variables: + +`DRY` - (true/**false**) Enable Dry Run +`VERBOSE` - (true/**false**) Turn on all output; lets you see the clean, build, and signing output +`SKIPCLEAN` - (true/**false**) Skips the clean step and goes right to Build. + +####Examples + +`rake staging:deploy DRY=true` + +`rake staging:redeploy VERBOSE=true SKIPCLEAN=true` ## Xcode 4 support From dbfdd4df40cbcff09d65843d32669a0605b66f00 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 21 May 2012 16:10:46 -0400 Subject: [PATCH 34/37] Updating changes --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 18a20b7..dcd7ce3 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ * Fixes cases where CFPropertyList could fail to load (@svelix) * Uses relative paths for requires (@smtlaissezfaire) * Raises an exception if the build fails (@epall) +* Improved method for locating the DerivedData location (@drodriguez) ## 0.7.4.1 From 21eec39bd26a44a389d1401782eadde9b9b980c1 Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 21 May 2012 17:27:17 -0400 Subject: [PATCH 35/37] Undoing @drodriguez's DerivedData location...was too fragile... --- lib/beta_builder.rb | 33 +++++---------------------------- 1 file changed, 5 insertions(+), 28 deletions(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index 8d65a9d..c7fbad1 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -94,42 +94,19 @@ def ipa_name else "#{target}.ipa" end - end + end def built_app_path if build_dir == :derived - File.join("#{derived_build_dir}", "#{configuration}-iphoneos", "#{app_file_name}") + File.join("#{derived_build_dir_from_build_output}", "#{configuration}-iphoneos", "#{app_file_name}") else File.join("#{build_dir}", "#{configuration}-iphoneos", "#{app_file_name}") end end - def derived_build_dir - workspace_settings_path = File.join(workspace_path, 'xcuserdata', - "#{`whoami`.strip}.xcuserdatad", - 'WorkspaceSettings.xcsettings') - - # Check the derived data location style - workspace_settings = CFPropertyList.native_types( - CFPropertyList::List.new(:file => workspace_settings_path).value) - derived_data_location_style = workspace_settings['IDEWorkspaceUserSettings_DerivedDataLocationStyle'] - derived_data_directory = case derived_data_location_style - when 0 then # The standard DerivedData directory. - workspace_name = File.basename(workspace_path, '.xcworkspace') - derived_data_dir = File.expand_path('~/Library/Developer/Xcode/DerivedData') - - # Look in every directory named after our workspace for the - # info.plist that points back to our workspace. - Dir[File.join(derived_data_dir, "#{workspace_name}-*")].find do |d| - CFPropertyList.native_types(CFPropertyList::List.new(:file => "#{d}/info.plist").value)['WorkspacePath'] == workspace_path - end - when 1, 2 then # We have the full path, or relative path - workspace_settings['IDEWorkspaceUserSettings_DerivedDataCustomLocation'] - else - raise "Unable to determine the DerivedData path. Your Workspace may be invalid or corrupted" - end - - "#{derived_data_directory}/Build/Products/" + def derived_build_dir_from_build_output + output = BuildOutputParser.new(File.read("build.output")) + output.build_output_dir end def built_app_dsym_path From d8644e8d0fa0eeff83601f74e754d1ef1f9100df Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Mon, 21 May 2012 17:28:27 -0400 Subject: [PATCH 36/37] Revert "Updating changes" This reverts commit dbfdd4df40cbcff09d65843d32669a0605b66f00. --- CHANGES.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index dcd7ce3..18a20b7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +11,6 @@ * Fixes cases where CFPropertyList could fail to load (@svelix) * Uses relative paths for requires (@smtlaissezfaire) * Raises an exception if the build fails (@epall) -* Improved method for locating the DerivedData location (@drodriguez) ## 0.7.4.1 From bb6662b32791d9a74bf21c8597be4fdc697b970c Mon Sep 17 00:00:00 2001 From: Nick Peelman Date: Tue, 19 Jun 2012 15:34:02 -0400 Subject: [PATCH 37/37] Use a shorter Git message for version information --- lib/beta_builder.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/beta_builder.rb b/lib/beta_builder.rb index c7fbad1..20a26fb 100644 --- a/lib/beta_builder.rb +++ b/lib/beta_builder.rb @@ -118,7 +118,7 @@ def ipa_path end def build_number_git - `git describe --tags --long`.chop + `git describe --tags --abbrev=1`.chop end def deploy_using(strategy_name, &block)