Fastfile 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. # This file contains the fastlane.tools configuration
  2. # You can find the documentation at https://docs.fastlane.tools
  3. #
  4. # For a list of all available actions, check out
  5. #
  6. # https://docs.fastlane.tools/actions
  7. #
  8. # For a list of all available plugins, check out
  9. #
  10. # https://docs.fastlane.tools/plugins/available-plugins
  11. #
  12. default_platform(:ios)
  13. TEAMID = ENV["TEAMID"]
  14. GH_PAT = ENV["GH_PAT"]
  15. GITHUB_WORKSPACE = ENV["GITHUB_WORKSPACE"]
  16. GITHUB_REPOSITORY_OWNER = ENV["GITHUB_REPOSITORY_OWNER"]
  17. FASTLANE_KEY_ID = ENV["FASTLANE_KEY_ID"]
  18. FASTLANE_ISSUER_ID = ENV["FASTLANE_ISSUER_ID"]
  19. FASTLANE_KEY = ENV["FASTLANE_KEY"]
  20. DEVICE_NAME = ENV["DEVICE_NAME"]
  21. DEVICE_ID = ENV["DEVICE_ID"]
  22. ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120"
  23. platform :ios do
  24. desc "Build Loop Follow"
  25. lane :build_LoopFollow do
  26. setup_ci if ENV['CI']
  27. update_project_team(
  28. path: "#{GITHUB_WORKSPACE}/LoopFollow.xcodeproj",
  29. teamid: "#{TEAMID}"
  30. )
  31. api_key = app_store_connect_api_key(
  32. key_id: "#{FASTLANE_KEY_ID}",
  33. issuer_id: "#{FASTLANE_ISSUER_ID}",
  34. key_content: "#{FASTLANE_KEY}"
  35. )
  36. previous_build_number = latest_testflight_build_number(
  37. app_identifier: "com.#{TEAMID}.LoopFollow",
  38. api_key: api_key,
  39. )
  40. current_build_number = previous_build_number + 1
  41. increment_build_number(
  42. xcodeproj: "#{GITHUB_WORKSPACE}/LoopFollow.xcodeproj",
  43. build_number: current_build_number
  44. )
  45. match(
  46. type: "appstore",
  47. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
  48. app_identifier: [
  49. "com.#{TEAMID}.LoopFollow"
  50. ]
  51. )
  52. previous_build_number = latest_testflight_build_number(
  53. app_identifier: "com.#{TEAMID}.LoopFollow",
  54. api_key: api_key,
  55. )
  56. current_build_number = previous_build_number + 1
  57. increment_build_number(
  58. xcodeproj: "#{GITHUB_WORKSPACE}/LoopFollow.xcodeproj",
  59. build_number: current_build_number
  60. )
  61. mapping = Actions.lane_context[
  62. SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING
  63. ]
  64. update_code_signing_settings(
  65. path: "#{GITHUB_WORKSPACE}/LoopFollow.xcodeproj",
  66. profile_name: mapping["com.#{TEAMID}.LoopFollow"],
  67. code_sign_identity: "iPhone Distribution",
  68. targets: ["LoopFollow"]
  69. )
  70. gym(
  71. export_method: "app-store",
  72. scheme: "LoopFollow",
  73. output_name: "LoopFollow.ipa",
  74. configuration: "Release",
  75. destination: 'generic/platform=iOS',
  76. buildlog_path: 'buildlog'
  77. )
  78. copy_artifacts(
  79. target_path: "artifacts",
  80. artifacts: ["*.mobileprovision", "*.ipa", "*.dSYM.zip"]
  81. )
  82. end
  83. desc "Push to TestFlight"
  84. lane :release do
  85. api_key = app_store_connect_api_key(
  86. key_id: "#{FASTLANE_KEY_ID}",
  87. issuer_id: "#{FASTLANE_ISSUER_ID}",
  88. key_content: "#{FASTLANE_KEY}"
  89. )
  90. upload_to_testflight(
  91. api_key: api_key,
  92. skip_submission: false,
  93. ipa: "LoopFollow.ipa",
  94. skip_waiting_for_build_processing: true,
  95. )
  96. end
  97. desc "Provision Identifiers and Certificates"
  98. lane :identifiers do
  99. setup_ci if ENV['CI']
  100. ENV["MATCH_READONLY"] = false.to_s
  101. app_store_connect_api_key(
  102. key_id: "#{FASTLANE_KEY_ID}",
  103. issuer_id: "#{FASTLANE_ISSUER_ID}",
  104. key_content: "#{FASTLANE_KEY}"
  105. )
  106. def configure_bundle_id(name, identifier, capabilities)
  107. bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier) || Spaceship::ConnectAPI::BundleId.create(name: name, identifier: identifier)
  108. capabilities.each { |capability|
  109. bundle_id.create_capability(capability)
  110. }
  111. end
  112. configure_bundle_id("LoopFollow", "com.#{TEAMID}.LoopFollow", [
  113. ])
  114. end
  115. desc "Provision Certificates"
  116. lane :certs do
  117. setup_ci if ENV['CI']
  118. ENV["MATCH_READONLY"] = false.to_s
  119. app_store_connect_api_key(
  120. key_id: "#{FASTLANE_KEY_ID}",
  121. issuer_id: "#{FASTLANE_ISSUER_ID}",
  122. key_content: "#{FASTLANE_KEY}"
  123. )
  124. match(
  125. type: "appstore",
  126. force: true,
  127. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
  128. app_identifier: [
  129. "com.#{TEAMID}.LoopFollow",
  130. ]
  131. )
  132. end
  133. desc "Validate Secrets"
  134. lane :validate_secrets do
  135. setup_ci if ENV['CI']
  136. ENV["MATCH_READONLY"] = true.to_s
  137. app_store_connect_api_key(
  138. key_id: "#{FASTLANE_KEY_ID}",
  139. issuer_id: "#{FASTLANE_ISSUER_ID}",
  140. key_content: "#{FASTLANE_KEY}"
  141. )
  142. def find_bundle_id(identifier)
  143. bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier)
  144. end
  145. find_bundle_id("com.#{TEAMID}.loopkit.LoopFollow")
  146. match(
  147. type: "appstore",
  148. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
  149. app_identifier: [],
  150. )
  151. end
  152. desc "Nuke Certs"
  153. lane :nuke_certs do
  154. setup_ci if ENV['CI']
  155. ENV["MATCH_READONLY"] = false.to_s
  156. app_store_connect_api_key(
  157. key_id: "#{FASTLANE_KEY_ID}",
  158. issuer_id: "#{FASTLANE_ISSUER_ID}",
  159. key_content: "#{FASTLANE_KEY}"
  160. )
  161. match_nuke(
  162. type: "appstore",
  163. team_id: "#{TEAMID}",
  164. skip_confirmation: true,
  165. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}")
  166. )
  167. end
  168. end