Fastfile 7.2 KB

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