Fastfile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. changelog: git_branch+" "+last_git_commit[:abbreviated_commit_hash],
  110. )
  111. end
  112. desc "Provision Identifiers and Certificates"
  113. lane :identifiers do
  114. setup_ci if ENV['CI']
  115. ENV["MATCH_READONLY"] = false.to_s
  116. app_store_connect_api_key(
  117. key_id: "#{FASTLANE_KEY_ID}",
  118. issuer_id: "#{FASTLANE_ISSUER_ID}",
  119. key_content: "#{FASTLANE_KEY}"
  120. )
  121. def configure_bundle_id(name, identifier, capabilities)
  122. bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier) || Spaceship::ConnectAPI::BundleId.create(name: name, identifier: identifier)
  123. capabilities.each { |capability|
  124. bundle_id.create_capability(capability)
  125. }
  126. end
  127. configure_bundle_id("FreeAPS", "ru.artpancreas.#{TEAMID}.FreeAPS", [
  128. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
  129. Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT,
  130. Spaceship::ConnectAPI::BundleIdCapability::Type::NFC_TAG_READING
  131. ])
  132. configure_bundle_id("FreeAPSWatch WatchKit Extension", "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension", [
  133. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
  134. Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT
  135. ])
  136. configure_bundle_id("FreeAPSWatch", "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp", [
  137. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS
  138. ])
  139. end
  140. desc "Provision Certificates"
  141. lane :certs do
  142. setup_ci if ENV['CI']
  143. ENV["MATCH_READONLY"] = false.to_s
  144. app_store_connect_api_key(
  145. key_id: "#{FASTLANE_KEY_ID}",
  146. issuer_id: "#{FASTLANE_ISSUER_ID}",
  147. key_content: "#{FASTLANE_KEY}"
  148. )
  149. match(
  150. type: "appstore",
  151. force: true,
  152. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
  153. app_identifier: [
  154. "ru.artpancreas.#{TEAMID}.FreeAPS",
  155. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension",
  156. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp",
  157. ]
  158. )
  159. end
  160. desc "Validate Secrets"
  161. lane :validate_secrets do
  162. setup_ci if ENV['CI']
  163. ENV["MATCH_READONLY"] = true.to_s
  164. app_store_connect_api_key(
  165. key_id: "#{FASTLANE_KEY_ID}",
  166. issuer_id: "#{FASTLANE_ISSUER_ID}",
  167. key_content: "#{FASTLANE_KEY}"
  168. )
  169. def find_bundle_id(identifier)
  170. bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier)
  171. end
  172. find_bundle_id("ru.artpancreas.#{TEAMID}.FreeAPS")
  173. end
  174. desc "Nuke Certs"
  175. lane :nuke_certs do
  176. setup_ci if ENV['CI']
  177. ENV["MATCH_READONLY"] = false.to_s
  178. app_store_connect_api_key(
  179. key_id: "#{FASTLANE_KEY_ID}",
  180. issuer_id: "#{FASTLANE_ISSUER_ID}",
  181. key_content: "#{FASTLANE_KEY}"
  182. )
  183. match_nuke(
  184. type: "appstore",
  185. team_id: "#{TEAMID}",
  186. skip_confirmation: true,
  187. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}")
  188. )
  189. end
  190. end