-
-
Save simonoff/104cb7a8a31994296fe2 to your computer and use it in GitHub Desktop.
This file contains 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 'shenzhen' | |
require 'xcpretty' | |
require 'cocoapods' | |
require 'date' | |
testflight_api_token = "TESTFLIGHT_API_TOKEN" | |
testflight_team_token = "TESTFLIGHT_TEAM_TOKEN" | |
workspace_file = "MyWorkspace.xcworkspace" | |
scheme_name = "MySchemeName" | |
testflight_distribution_lists = "MY_DISTRIBUTION_LIST" | |
def run(command, min_exit_status = 0) | |
puts "Executing: `#{command}`" | |
system(command) | |
return $?.exitstatus | |
end | |
desc "Cleaning environment" | |
task :clean do | |
run("rm -rf Build && rm -rf DerivedData && rm -rf Pods && rm -rf Podfile.lock && rm -rf #{workspace_file}") | |
end | |
desc "install dependencies" | |
task :dependencies do | |
run("pod install") | |
end | |
desc "Run #{scheme_name} tests" | |
task :run_tests do | |
$tests_success = run("xcodebuild -scheme \"#{scheme_name}\" -workspace #{workspace_file} -destination 'name=iPhone Retina (4-inch),OS=7.1' clean test | xcpretty -tc; exit ${PIPESTATUS[0]}") | |
end | |
desc "Clean ipa artefacts" | |
task :clean_ipa do | |
run("rm -rf #{scheme_name}.ipa && rm -rf #{scheme_name}.app.dSYM.zip") | |
end | |
desc "Upload application to Testflight" | |
task :testflight => ['clean','dependencies','run_tests'] do | |
if ($tests_success == 0) | |
configuration = ENV['configuration'] | |
configuration ||= "Release" | |
puts "Using configuration: " + configuration | |
build_status = run("ipa build -s #{scheme_name} --configuration #{configuration}") | |
upload_time = Time.now.strftime("%d/%m/%Y") | |
upload_status = run("ipa distribute:testflight -a #{testflight_api_token} -T #{testflight_team_token} -l #{testflight_distribution_lists} --notify -m '#{scheme_name}-#{configuration} #{upload_time}.'") | |
Rake::Task['clean_ipa'].invoke | |
exit(-1) unless build_status==0 && upload_status == 0 | |
else | |
puts "\033[0;31m! #{scheme_name} unit tests failed" | |
exit(-1) | |
end | |
end | |
desc "Test and compile #{scheme_name}" | |
task :ci => ['clean','dependencies','run_tests'] do | |
puts "\033[0;31m! #{scheme_name} unit tests failed" unless $tests_success == 0 | |
if ($tests_success == 0) | |
puts "\033[0;32m** All is good!" | |
else | |
exit(-1) | |
end | |
end | |
task default: 'ci' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment