Skip to content

Commit

Permalink
initial revision
Browse files Browse the repository at this point in the history
  • Loading branch information
lrz committed Apr 24, 2012
0 parents commit a050b8a
Show file tree
Hide file tree
Showing 6 changed files with 263 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pkg
22 changes: 22 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2012, Laurent Sansonetti <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74 changes: 74 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
== motion-testflight

motion-testflight allows RubyMotion projects to easily embed the TestFlight
SDK and be submitted to the TestFlight platform.

=== Requirements

* RubyMotion 1.0 or greater (see http://www.rubymotion.com).
* A TestFlight account, can be obtained for free at http://testflightapp.com.

=== Installation

$ sudo gem install motion-testflight

=== Setup

1. Download the TestFlight SDK package from https://testflightapp.com/sdk/download/ and unpack it into the `vendor/TestFlightSDK' directory of your RubyMotion project. Create the `vendor' directory if it does not exist. You should have something like this.

$ ls vendor/TestFlightSDK
README.txt libTestFlight.a
TestFlight.h release_notes.txt

2. Edit the Rakefile of your RubyMotion project and add the following require line.

require 'motion/project/testflight'

3. Still in the Rakefile, set up the following variables in your application configuration block.

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>'
end

You can retrieve your API and team tokens from your TestFlight account page.

4. (Optional) You can also set up distribution lists, if needed.

Motion::Project::App.setup do |app|
# ...
app.testflight.distribution_lists = ['CoolKids']
end

=== Usage

motion-testflight introduces a `testflight' Rake task to your project, which can be used to submit a development build. The `notes' parameter must be provided, and its content will be used as the submission release notes.

$ rake testflight notes="zomg!"

=== License

Copyright (c) 2012, Laurent Sansonetti <[email protected]>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 changes: 30 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
require 'rake/gempackagetask'

Version = 1.0

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
25 changes: 25 additions & 0 deletions lib/motion-testflight.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2012, Laurent Sansonetti <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

require 'motion/project/testflight'
111 changes: 111 additions & 0 deletions lib/motion/project/testflight.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
# Copyright (c) 2012, Laurent Sansonetti <[email protected]>
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.

unless defined?(Motion::Project::Config)
raise "This file must be required within a RubyMotion project Rakefile."
end

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

def initialize(config)
@config = config
end

def sdk=(sdk)
if @sdk != sdk
@config.unvendor_project(@sdk)
@sdk = sdk
@config.vendor_project(sdk, :static)
end
end

def team_token=(team_token)
@team_token = team_token
create_launcher
end

def inspect
{:sdk => sdk, :api_token => api_token, :team_token => team_token, :distribution_lists => distribution_lists}.inspect
end

private

def create_launcher
return unless team_token
launcher_code = <<EOF
# This file is automatically generated. Do not edit.
if Object.const_defined?('TestFlight') and !UIDevice.currentDevice.model.include?('Simulator')
NSNotificationCenter.defaultCenter.addObserverForName(UIApplicationDidBecomeActiveNotification, object:nil, queue:nil, usingBlock:lambda do |notification|
TestFlight.takeOff('#{team_token}')
end)
end
EOF
launcher_file = './app/testflight_launcher.rb'
if !File.exist?(launcher_file) or File.read(launcher_file) != launcher_code
File.open(launcher_file, 'w') { |io| io.write(launcher_code) }
end
files = @config.files
files << launcher_file unless files.find { |x| File.expand_path(x) == File.expand_path(launcher_file) }
end
end

module Motion; module Project; class Config
variable :testflight

def testflight
@testflight ||= TestFlightConfig.new(self)
end
end; end; end

namespace 'testflight' do
desc "Submit a development archive to TestFlight"
task :submit => 'archive:development' do
# 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

# An archived version of the .dSYM bundle is needed.
app_dsym = App.config.app_bundle('iPhoneOS').sub(/\.app$/, '.dSYM')
app_dsym_zip = app_dsym + '.zip'
if !File.exist?(app_dsym_zip) or File.mtime(app_dsym) > File.mtime(app_dsym_zip)
Dir.chdir(File.dirname(app_dsym)) do
sh "/usr/bin/zip -q -r \"#{File.basename(app_dsym)}.zip\" \"#{File.basename(app_dsym)}\""
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 << " -F distribution_lists='#{distribution_lists}'" if distribution_lists
App.info 'Run', curl
sh curl
end
end

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

0 comments on commit a050b8a

Please sign in to comment.