Created
March 2, 2009 23:03
-
-
Save lukeredpath/73051 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'term/ansicolor' | |
RELEASE_OUTPUT_PATH = File.expand_path("~/Projects/releases/Squeemote") | |
TARGET_NAME = "Squeemote" | |
CONFIGURATION = ENV['CONFIGURATION'] || "Distribution" | |
SDK_VERSION = ENV['SDK'] || 'iphoneos2.2' | |
module Colorize | |
class << self | |
include Term::ANSIColor | |
def puts(color, string) | |
Kernel.puts send(color) + string + reset | |
end | |
end | |
end | |
require File.expand_path("~/Projects/opensource/xcodebuild-outputparser/lib/xcode_output_parser") | |
def with_timer(&block) | |
progress = Thread.new do | |
loop { print '.'; STDOUT.flush; sleep 0.2 } | |
end | |
start = Time.now | |
yield | |
puts && progress.kill | |
Time.now - start | |
end | |
namespace :test do | |
task :clean do | |
print "* Cleaning build" | |
with_timer { `xcodebuild clean` } | |
puts "* Done" | |
end | |
task :build do | |
print "* Running test build" | |
output = nil | |
time_taken = with_timer do | |
output = `xcodebuild -target Testing -configuration Development -sdk iphonesimulator2.2` | |
end | |
result = XcodeOutputParser::TestResultParser.new.parse_output(output) | |
unless result.success? | |
puts "The following tests failed:" | |
result.test_suites.each do |test_suite| | |
next unless test_suite.failing_tests.any? | |
Colorize.puts :red, " * #{test_suite.name}" | |
test_suite.failing_tests.each do |test| | |
puts "\t- #{test.name}" | |
puts "\t- #{test.failure_message}" | |
end | |
end | |
end | |
Colorize.puts(result.success? ? :green : :red, | |
"* Finished in #{time_taken} seconds. #{result.total_tests_run} tests, #{result.number_of_failures} failures") | |
end | |
task :all => [:clean, :build] | |
end | |
task :release do | |
puts "* Bumping build version." | |
`agvtool bump -all` | |
puts "* Building #{CONFIGURATION} release." | |
`xcodebuild -target #{TARGET_NAME} -configuration #{CONFIGURATION} -sdk #{SDK_VERSION}` | |
build_path = File.join('build', "#{CONFIGURATION}-iphoneos") | |
puts "* Creating #{CONFIGURATION} package" | |
output_path = File.join(RELEASE_OUTPUT_PATH, `agvtool mvers -terse1`.strip + "-#{CONFIGURATION.downcase}") | |
`rm -Rf #{output_path}` if File.exist?(output_path) | |
`mkdir #{output_path} && mv #{File.join(build_path, '*')} #{output_path}` | |
puts "* Compressing." | |
`cd #{output_path} && zip -ry #{TARGET_NAME}.zip #{TARGET_NAME}.app` | |
puts "* Done." | |
end | |
task :default => 'test:build' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment