Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. fastlane_version "1.98.0"
  2.  
  3. default_platform :ios
  4.  
  5. lane :dependencies do
  6. sh "pod repo update"
  7. cocoapods
  8. end
  9.  
  10. # 'fastlane certs' to create or fetch all required
  11. lane :certs do
  12. match(app_identifier: "com.mlsdev.tom.Fitlife.debug", type: "development", force_for_new_devices: true)
  13. match(app_identifier: "com.mlsdev.tom.Fitlife.staging", type: "appstore")
  14. match(app_identifier: "com.mlsdev.tom.Fitlife.staging", type: "development", force_for_new_devices: true)
  15. match(app_identifier: "com.mlsdev.tom.Fitlife", type: "appstore")
  16. match(app_identifier: "com.mlsdev.tom.Fitlife", type: "development", force_for_new_devices: true)
  17. end
  18.  
  19. # push notification certificates - required for backend (zip results and save it into your project dropbox or slack team or etc.)
  20. lane :pems do
  21. pem(force: true, app_identifier: "com.mlsdev.tom.Fitlife", save_private_key: true, development: false, output_path: "~/Documents/FitlifePems/prod/")
  22. pem(force: true, app_identifier: "com.mlsdev.tom.Fitlife.staging", save_private_key: true, development: false, output_path: "~/Documents/FitlifePems/stage/")
  23. pem(force: true, app_identifier: "com.mlsdev.tom.Fitlife.debug", save_private_key: true, development: true, output_path: "~/Documents/FitlifePems/devel/")
  24. end
  25.  
  26. lane :upload_build_to_testflight do |config|
  27. startTime = Time.now
  28. ENV["PILOT_APP_IDENTIFIER"] = ENV["MATCH_APP_IDENTIFIER"]
  29. ENV["APP_VERSION_NUMBER"] = get_version_number_from_plist(
  30. target: "Fitlife",
  31. build_configuration_name: config[:environment]
  32. )
  33. ENV["APP_BUILD_NUMBER"] = Time.new.strftime("%Y.%m.%d.%H%M")
  34. ## This will ensure upload will complete successfully on CI, since we may be behind firewall
  35. ENV["DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS"] = "-t DAV"
  36. ENV["SLACK_URL"] = "https://hooks.slack.com/services/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" # usualy this should be your project channel hook
  37. configuration = config[:environment] || "ProductionRelease"
  38.  
  39. #post_to_slack_build_initiated(environment: configuration)
  40. dependencies
  41. changelog
  42. clear_derived_data
  43. runTests
  44. match(app_identifier: config[:bundle], type: "appstore", readonly: true)
  45.  
  46. increment_build_number_in_plist(
  47. build_number: ENV["APP_BUILD_NUMBER"],
  48. target: "Fitlife",
  49. build_configuration_name: config[:environment]
  50. )
  51.  
  52. gym(configuration: configuration)
  53. changelog
  54.  
  55. pilot(
  56. skip_submission: true,
  57. team_name: "Fit Life Space Inc.", # TODO: Maybe this parameter can be auto taken from Appfile?
  58. changelog: ENV['CHANGELOG'],
  59. skip_waiting_for_build_processing: true
  60. )
  61. post_to_slack(start_time: startTime)
  62. end
  63.  
  64. lane :staging do
  65. ENV["CURRENT_LANE_TARGET"] = "Fitlife Staging"
  66. upload_build_to_testflight(environment: "StagingRelease", bundle: "com.mlsdev.tom.Fitlife.staging")
  67. end
  68.  
  69. lane :production do
  70. ENV["CURRENT_LANE_TARGET"] = "Fitlife Production"
  71. upload_build_to_testflight(environment: "ProductionRelease", bundle: "com.mlsdev.tom.Fitlife")
  72. end
  73.  
  74. lane :changelog do
  75. readme = File.read("../SupportingFiles/CHANGELOG.md")
  76. latest_version = readme.split("\n## ").first
  77. first_line = latest_version.split("\n").first
  78. version_number = first_line.split(" ")[1]
  79.  
  80. # Generate release notes from CHANGELOG
  81. release_notes = latest_version.split("\n")[0..-1].join("\n")
  82. ENV['CHANGELOG'] = release_notes
  83. end
  84.  
  85. lane :runTests do
  86. dependencies
  87. clear_derived_data
  88. ENV["FASTLANE_EXPLICIT_OPEN_SIMULATOR"] = "1"
  89. scan
  90. end
  91.  
  92. lane :post_to_slack_build_initiated do |options|
  93. environment = options[:environment]
  94. target = ENV["CURRENT_LANE_TARGET"].strip
  95. version = ENV["APP_VERSION_NUMBER"]
  96. build = ENV["APP_BUILD_NUMBER"]
  97.  
  98. slack(
  99. message: "Started creating *#{target}* #{environment} build *#{version}* (#{build})",
  100. default_payloads: []
  101. )
  102. end
  103.  
  104. # slack notification lane, executed after successfull staging/production execution
  105. lane :post_to_slack do |options|
  106. target = ENV["CURRENT_LANE_TARGET"]
  107. version = ENV["APP_VERSION_NUMBER"]
  108. build = ENV["APP_BUILD_NUMBER"]
  109. lane_duration = (Time.now - options[:start_time]).round
  110. commit = `git rev-parse HEAD`.strip
  111. commit_url = ENV["GIT_URL"] + commit # TODO: Check this url construction!
  112. author = `git --no-pager show -s --format='%ae' HEAD`.strip
  113. branch = `echo ${GIT_BRANCH#*/}`.strip
  114.  
  115. slack(
  116. message: "*#{target}* `#{version} #{build}` builded from <#{commit_url}|#{commit[0,5]}> finished uploading! \n*Git Branch:* #{branch} *Git Author:* <mailto:#{author}|#{author}> *Duration:* #{lane_duration} second(s)\nChanges: \n\n" + ENV['CHANGELOG'],
  117. default_payloads:[]
  118. )
  119. end
  120.  
  121. lane :devices do
  122. register_devices(
  123. devices: {
  124. 'MLS Telezhkin iPhone X' => 'e2953c8e2916cb8f3ee4a5a9555a044af1ced4cd',
  125. 'Oleh Iphon6s' => 'b72e0230a2031feb29fedd79e976caa86958562e',
  126. }
  127. )
  128. end
  129.  
  130. lane :refresh_dsyms do
  131. #download_and_upload_dsyms(bundle: "com.mlsdev.tom.Fitlife")
  132. download_and_upload_dsyms(bundle: "com.mlsdev.tom.Fitlife.staging")
  133. end
  134.  
  135. lane :download_and_upload_dsyms do |options|
  136. ENV["DOWNLOAD_DSYMS_APP_IDENTIFIER"] = options[:bundle]
  137. dependencies
  138. download_dsyms # Download dSYM files from iTC
  139. ENV['CRASHLYTICS_API_TOKEN'] = 'CHANGE_WITH_REAL_VALUE' # Visit https://fabric.io/settings/organizations/ -> Your Organization -> 'API Key'
  140. upload_symbols_to_crashlytics(binary_path: "./Pods/Fabric/upload-symbols") # Upload them to Crashlytics
  141. end
  142.  
  143. after_all do
  144. clean_build_artifacts
  145. end
  146.  
  147. error do |lane, exception|
  148. target = ENV["CURRENT_LANE_TARGET"]
  149. version = ENV["APP_VERSION_NUMBER"]
  150. build = ENV["APP_BUILD_NUMBER"]
  151. error = exception.to_s
  152.  
  153. if ENV["SLACK_URL"]
  154. slack(
  155. message: "Build #{target} *#{version}* (#{build}) failed! Error: #{error}",
  156. success: false
  157. )
  158. end
  159. end
  160.  
  161. # uncomment this section if you want to receive slack notifications about failures (for example you can send it to yourself or team channel)
  162. #error do |lane, exception|
  163. # ENV["SLACK_URL"] = "https://hooks.slack.com/services/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" # slack webhook
  164. # target = ENV["CURRENT_LANE_TARGET"]
  165. # ENV["BUILD_URL"] ||= "http://localhost/"
  166. # buildURL = ENV["BUILD_URL"].strip.sub(":8080", '') + "console"
  167. # branch = `echo ${GIT_BRANCH#*/}`.strip
  168. # author = `git --no-pager show -s --format='%ae' HEAD`.strip
  169. # slack(message: "*#{target} build failed: *<#{buildURL}|Build Log> *Exception:* #{exception.message} \n*Git Branch:* #{branch} *Git Author:* <mailto:#{author}|#{author}>", success: false, default_payloads:[])
  170. #end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement