Skip to content

Instantly share code, notes, and snippets.

@gnestor
Created February 21, 2015 03:39
Show Gist options
  • Save gnestor/c056a17d9b78c68a7ff0 to your computer and use it in GitHub Desktop.
Save gnestor/c056a17d9b78c68a7ff0 to your computer and use it in GitHub Desktop.
RubyMotion: Custom rake tasks for New Relic, Testflight (old), and Crittercism
def build_path
"build/iPhoneOS-7.0-Release/"
end
def ipa_name
"APP_FILE_NAME.ipa"
end
def dsym_name
"APP_FILE_NAME.app.dSYM"
end
def uuid
`xcrun dwarfdump --uuid #{build_path}#{dsym_name} | tr '[:upper:]' '[:lower:]' | tr -d '-'| awk '{print $2}' | xargs | sed 's/ /,/g'`
end
desc "Generate Development Build"
task :adhoc => [
:deep_clean,
"archive:development"
]
desc "Generate App Store Build"
task :appstore => [
"archive:distribution",
:zip_dsym,
:get_uuid,
:new_relic
]
task :deep_clean do
sh "rake clean"
end
task :zip_dsym do
`rm #{build_path}#{dsym_name}.zip`
sh "cd #{build_path} && zip -r #{dsym_name}.zip #{dsym_name}"
end
task :get_uuid do
@uuid = `xcrun dwarfdump --uuid #{build_path}#{dsym_name} | tr '[:upper:]' '[:lower:]' | tr -d '-'| awk '{print $2}' | xargs | sed 's/ /,/g'`
end
desc "Send to Testflight"
task :testflight do
cmd = <<-CMD
cd #{build_path} &&
curl http://testflightapp.com/api/builds.json
-F file=@#{ipa_name}
-F api_token='#{ENV['TESTFLIGHT_API_TOKEN']}'
-F team_token='#{ENV['TESTFLIGHT_TEAM_TOKEN']}'
-F notes='#{ENV['notes']}'
-F notify=True
-F distribution_lists='dayoftheshirt'
CMD
puts cmd
sh cmd.gsub("\n", "\\\n")
end
desc "Send dSYM to New Relic"
task :new_relic do
cmd = <<-CMD
cd #{build_path} &&
curl https://mobile-symbol-upload.newrelic.com/symbol
-F dsym=@#{dsym_name}.zip
-F buildId="#{uuid}"
-F appName="APP_NAME"
-H "X-APP-LICENSE-KEY: NEW_RELIC_LICENSE_KEY"
CMD
puts cmd
sh cmd.gsub("\n", "\\\n")
end
desc "Send to crittercism"
task :crittercism do
if adhoc?
env = 'adhoc'
else # Release
env = 'release'
end
config = YAML.load_file("config/#{env}.yml")
app_id = config['crittercism']['appId']
api_key = ENV["CRITTERCISM_#{env.upcase}_API_KEY"]
cmd = <<-CMD
cd #{build_path} &&
curl "https://api.crittercism.com/api_beta/dsym/#{app_id}"
-F dsym=@"#{dsym_name}.zip"
-F key="#{api_key}"
CMD
puts cmd
sh cmd.gsub("\n", "\\\n")
end
@gnestor
Copy link
Author

gnestor commented Feb 21, 2015

Put your custom rake file in your PROJECT_ROOT/lib/tasks/ directory and use it with rake TASK_NAME (e.g. rake appstore or rake new_relic).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment