Fastfile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  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 iAPS"
  25. lane :build_iAPS do
  26. setup_ci if ENV['CI']
  27. update_project_team(
  28. path: "#{GITHUB_WORKSPACE}/FreeAPS.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: "ru.artpancreas.#{TEAMID}.FreeAPS",
  38. api_key: api_key,
  39. )
  40. current_build_number = previous_build_number + 1
  41. increment_build_number(
  42. xcodeproj: "#{GITHUB_WORKSPACE}/FreeAPS.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. "ru.artpancreas.#{TEAMID}.FreeAPS",
  50. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp",
  51. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension"
  52. ]
  53. )
  54. previous_build_number = latest_testflight_build_number(
  55. app_identifier: "ru.artpancreas.#{TEAMID}.FreeAPS",
  56. api_key: api_key,
  57. )
  58. current_build_number = previous_build_number + 1
  59. increment_build_number(
  60. xcodeproj: "#{GITHUB_WORKSPACE}/FreeAPS.xcodeproj",
  61. build_number: current_build_number
  62. )
  63. mapping = Actions.lane_context[
  64. SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING
  65. ]
  66. update_code_signing_settings(
  67. path: "#{GITHUB_WORKSPACE}/FreeAPS.xcodeproj",
  68. profile_name: mapping["ru.artpancreas.#{TEAMID}.FreeAPS"],
  69. code_sign_identity: "iPhone Distribution",
  70. targets: ["FreeAPS"]
  71. )
  72. update_code_signing_settings(
  73. path: "#{GITHUB_WORKSPACE}/FreeAPS.xcodeproj",
  74. profile_name: mapping["ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension"],
  75. code_sign_identity: "iPhone Distribution",
  76. targets: ["FreeAPSWatch WatchKit Extension"]
  77. )
  78. update_code_signing_settings(
  79. path: "#{GITHUB_WORKSPACE}/FreeAPS.xcodeproj",
  80. profile_name: mapping["ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp"],
  81. code_sign_identity: "iPhone Distribution",
  82. targets: ["FreeAPSWatch"]
  83. )
  84. gym(
  85. export_method: "app-store",
  86. scheme: "FreeAPS X",
  87. output_name: "iAPS.ipa",
  88. configuration: "Release",
  89. destination: 'generic/platform=iOS',
  90. buildlog_path: 'buildlog'
  91. )
  92. copy_artifacts(
  93. target_path: "artifacts",
  94. artifacts: ["*.mobileprovision", "*.ipa", "*.dSYM.zip"]
  95. )
  96. end
  97. desc "Push to TestFlight"
  98. lane :release do
  99. api_key = app_store_connect_api_key(
  100. key_id: "#{FASTLANE_KEY_ID}",
  101. issuer_id: "#{FASTLANE_ISSUER_ID}",
  102. key_content: "#{FASTLANE_KEY}"
  103. )
  104. upload_to_testflight(
  105. api_key: api_key,
  106. skip_submission: false,
  107. ipa: "iAPS.ipa",
  108. skip_waiting_for_build_processing: true,
  109. )
  110. end
  111. desc "Provision Identifiers and Certificates"
  112. lane :identifiers do
  113. setup_ci if ENV['CI']
  114. ENV["MATCH_READONLY"] = false.to_s
  115. app_store_connect_api_key(
  116. key_id: "#{FASTLANE_KEY_ID}",
  117. issuer_id: "#{FASTLANE_ISSUER_ID}",
  118. key_content: "#{FASTLANE_KEY}"
  119. )
  120. def configure_bundle_id(name, identifier, capabilities)
  121. bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier) || Spaceship::ConnectAPI::BundleId.create(name: name, identifier: identifier)
  122. capabilities.each { |capability|
  123. bundle_id.create_capability(capability)
  124. }
  125. end
  126. configure_bundle_id("FreeAPS", "ru.artpancreas.#{TEAMID}.FreeAPS", [
  127. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
  128. Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT,
  129. Spaceship::ConnectAPI::BundleIdCapability::Type::NFC_TAG_READING
  130. ])
  131. configure_bundle_id("FreeAPSWatch WatchKit Extension", "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension", [
  132. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
  133. Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT
  134. ])
  135. configure_bundle_id("FreeAPSWatch", "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp", [
  136. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS
  137. ])
  138. end
  139. desc "Provision Certificates"
  140. lane :certs do
  141. setup_ci if ENV['CI']
  142. ENV["MATCH_READONLY"] = false.to_s
  143. app_store_connect_api_key(
  144. key_id: "#{FASTLANE_KEY_ID}",
  145. issuer_id: "#{FASTLANE_ISSUER_ID}",
  146. key_content: "#{FASTLANE_KEY}"
  147. )
  148. match(
  149. type: "appstore",
  150. force: true,
  151. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
  152. app_identifier: [
  153. "ru.artpancreas.#{TEAMID}.FreeAPS",
  154. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension",
  155. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp",
  156. ]
  157. )
  158. end
  159. desc "Validate Secrets"
  160. lane :validate_secrets do
  161. setup_ci if ENV['CI']
  162. ENV["MATCH_READONLY"] = true.to_s
  163. app_store_connect_api_key(
  164. key_id: "#{FASTLANE_KEY_ID}",
  165. issuer_id: "#{FASTLANE_ISSUER_ID}",
  166. key_content: "#{FASTLANE_KEY}"
  167. )
  168. def find_bundle_id(identifier)
  169. bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier)
  170. end
  171. find_bundle_id("ru.artpancreas.#{TEAMID}.FreeAPS")
  172. end
  173. desc "Nuke Certs"
  174. lane :nuke_certs do
  175. setup_ci if ENV['CI']
  176. ENV["MATCH_READONLY"] = false.to_s
  177. app_store_connect_api_key(
  178. key_id: "#{FASTLANE_KEY_ID}",
  179. issuer_id: "#{FASTLANE_ISSUER_ID}",
  180. key_content: "#{FASTLANE_KEY}"
  181. )
  182. match_nuke(
  183. type: "appstore",
  184. team_id: "#{TEAMID}",
  185. skip_confirmation: true,
  186. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}")
  187. )
  188. end
  189. end