Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add task to submit a release/ad-hoc build #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion 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, :app_token, :distribution_lists, :notify, :identify_testers
attr_accessor :sdk, :api_token, :team_token, :app_token, :distribution_lists, :replace, :notify, :identify_testers

def initialize(config)
@config = config
Expand Down Expand Up @@ -134,6 +134,35 @@ def testflight?
sh curl
end

desc "Submit a distribution archive to TestFlight"
task :distribute 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
notes = ENV['notes']
App.fail "Submission notes must be provided via the `notes' environment variable. Example: rake testflight notes='w00t'" unless notes

# Don't recreate an archive as we want to upload the exact same build on the App Store and on TestFlight
#Rake::Task["archive:distribution"].invoke

# An archived version of the .dSYM bundle is needed.
app_dsym = App.config.app_bundle('iPhoneOS').sub(/Development/, 'Release').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.sub(/Development/, 'Release')}\" -F dsym=@\"#{app_dsym_zip}\" -F api_token='#{prefs.api_token}' -F team_token='#{prefs.team_token}' -F notes=\"#{notes}\" -F replace=#{prefs.replace ? 'True' : 'False'} -F notify=#{prefs.notify ? 'True' : 'False'}"
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"
Expand Down