Skip to content

Commit

Permalink
Merge pull request #7 from joenoon/testflight_mode
Browse files Browse the repository at this point in the history
Testflight mode
  • Loading branch information
Watson1978 committed Oct 6, 2012
2 parents 71e198f + e85ace9 commit ac8b9b1
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 36 deletions.
12 changes: 9 additions & 3 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,15 @@ SDK and be submitted to the TestFlight platform.

Motion::Project::App.setup do |app|
# ...
app.testflight.sdk = 'vendor/TestFlight'
app.testflight.api_token = '<insert your API token here>'
app.testflight.team_token = '<insert your team token here>'
app.development do
# ...
app.testflight do
app.testflight.sdk = 'vendor/TestFlight'
app.testflight.api_token = '<insert your API token here>'
app.testflight.team_token = '<insert your team token here>'
app.testflight.notify = true # default is false
end
end
end

You can retrieve the values for +api_token+ and +team_token+ in your TestFlight account page.
Expand Down
30 changes: 0 additions & 30 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,30 +0,0 @@
require 'rake/gempackagetask'

Version = 1.2

GemSpec = Gem::Specification.new do |spec|
spec.name = 'motion-testflight'
spec.summary = 'TestFlight integration for RubyMotion projects'
spec.description = "motion-testflight allows RubyMotion projects to easily embed the TestFlight SDK and be submitted to the TestFlight platform."
spec.author = 'Laurent Sansonetti'
spec.email = '[email protected]'
spec.homepage = 'http://www.rubymotion.com'
spec.version = Version

files = []
files << 'README.rdoc'
files << 'LICENSE'
files.concat(Dir.glob('lib/**/*.rb'))
spec.files = files
end

Rake::GemPackageTask.new(GemSpec) do |pkg|
pkg.need_zip = false
pkg.need_tar = true
end

task :default => :gem

task :clean do
FileUtils.rm_rf 'pkg'
end
53 changes: 50 additions & 3 deletions lib/motion/project/testflight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
end

class TestFlightConfig
attr_accessor :sdk, :api_token, :team_token, :distribution_lists
attr_accessor :sdk, :api_token, :team_token, :distribution_lists, :notify

def initialize(config)
@config = config
Expand Down Expand Up @@ -75,23 +75,38 @@ def create_launcher
end

module Motion; module Project; class Config

attr_accessor :testflight_mode

variable :testflight

def testflight
@testflight ||= TestFlightConfig.new(self)
yield if block_given? && testflight?
@testflight
end

def testflight?
@testflight_mode == true
end

end; end; end

namespace 'testflight' do
desc "Submit an archive to TestFlight"
task :submit => 'archive' do
task :submit do

App.config_without_setup.testflight_mode = true

# Retrieve configuration settings.
prefs = App.config.testflight
App.fail "A value for app.testflight.api_token is mandatory" unless prefs.api_token
App.fail "A value for app.testflight.team_token is mandatory" unless prefs.team_token
distribution_lists = (prefs.distribution_lists ? prefs.distribution_lists.join(',') : nil)
notes = ENV['notes']
App.fail "Submission notes must be provided via the `notes' environment variable. Example: rake testflight notes='w00t'" unless notes

Rake::Task["archive"].invoke

# An archived version of the .dSYM bundle is needed.
app_dsym = App.config.app_bundle('iPhoneOS').sub(/\.app$/, '.dSYM')
Expand All @@ -102,12 +117,44 @@ def testflight
end
end

curl = "/usr/bin/curl http://testflightapp.com/api/builds.json -F file=@\"#{App.config.archive}\" -F dsym=@\"#{app_dsym_zip}\" -F api_token='#{prefs.api_token}' -F team_token='#{prefs.team_token}' -F notes=\"#{notes}\" -F notify=True"
curl = "/usr/bin/curl http://testflightapp.com/api/builds.json -F file=@\"#{App.config.archive}\" -F dsym=@\"#{app_dsym_zip}\" -F api_token='#{prefs.api_token}' -F team_token='#{prefs.team_token}' -F notes=\"#{notes}\" -F notify=#{prefs.notify ? "True" : "False"}"
curl << " -F distribution_lists='#{distribution_lists}'" if distribution_lists
App.info 'Run', curl
sh curl
end

desc "Records if the device build is created in testflight mode, so some things can be cleaned up between mode switches"
task :record_mode do
testflight_mode = App.config_without_setup.testflight_mode ? "True" : "False"

platform = 'iPhoneOS'
bundle_path = App.config.app_bundle(platform)
build_dir = File.join(App.config.versionized_build_dir(platform))
FileUtils.mkdir_p(build_dir)
previous_testflight_mode_file = File.join(build_dir, '.testflight_mode')

previous_testflight_mode = "False"
if File.exist?(previous_testflight_mode_file)
previous_testflight_mode = File.read(previous_testflight_mode_file).strip
end
if previous_testflight_mode != testflight_mode
App.info "Testflight", "Cleaning executable, Info.plist, and PkgInfo for mode change (was: #{previous_testflight_mode}, now: #{testflight_mode})"
[
App.config.app_bundle_executable(platform), # main_exec
File.join(bundle_path, 'Info.plist'), # bundle_info_plist
File.join(bundle_path, 'PkgInfo') # bundle_pkginfo
].each do |path|
rm_rf(path) if File.exist?(path)
end
end
File.open(previous_testflight_mode_file, 'w') do |f|
f.write testflight_mode
end
end
end

desc 'Same as testflight:submit'
task 'testflight' => 'testflight:submit'

# record testflight mode before every device build
task 'build:device' => 'testflight:record_mode'
19 changes: 19 additions & 0 deletions motion-testflight.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- encoding: utf-8 -*-

Version = "1.2.1"

Gem::Specification.new do |spec|
spec.name = 'motion-testflight'
spec.summary = 'TestFlight integration for RubyMotion projects'
spec.description = "motion-testflight allows RubyMotion projects to easily embed the TestFlight SDK and be submitted to the TestFlight platform."
spec.author = 'Laurent Sansonetti'
spec.email = '[email protected]'
spec.homepage = 'http://www.rubymotion.com'
spec.version = Version

files = []
files << 'README.rdoc'
files << 'LICENSE'
files.concat(Dir.glob('lib/**/*.rb'))
spec.files = files
end

0 comments on commit ac8b9b1

Please sign in to comment.