Fastfile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 FreeAPS X"
  25. lane :build_fax 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: "FAX.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: "FAX.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. ])
  130. configure_bundle_id("FreeAPSWatch WatchKit Extension", "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension", [
  131. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS,
  132. Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT
  133. ])
  134. configure_bundle_id("FreeAPSWatch", "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp", [
  135. Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS
  136. ])
  137. end
  138. desc "Provision Certificates"
  139. lane :certs do
  140. setup_ci if ENV['CI']
  141. ENV["MATCH_READONLY"] = false.to_s
  142. app_store_connect_api_key(
  143. key_id: "#{FASTLANE_KEY_ID}",
  144. issuer_id: "#{FASTLANE_ISSUER_ID}",
  145. key_content: "#{FASTLANE_KEY}"
  146. )
  147. match(
  148. type: "appstore",
  149. force: true,
  150. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"),
  151. app_identifier: [
  152. "ru.artpancreas.#{TEAMID}.FreeAPS",
  153. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp.watchkitextension",
  154. "ru.artpancreas.#{TEAMID}.FreeAPS.watchkitapp",
  155. ]
  156. )
  157. end
  158. desc "Nuke Certs"
  159. lane :nuke_certs do
  160. setup_ci if ENV['CI']
  161. ENV["MATCH_READONLY"] = false.to_s
  162. app_store_connect_api_key(
  163. key_id: "#{FASTLANE_KEY_ID}",
  164. issuer_id: "#{FASTLANE_ISSUER_ID}",
  165. key_content: "#{FASTLANE_KEY}"
  166. )
  167. match_nuke(
  168. type: "appstore",
  169. team_id: "#{TEAMID}",
  170. skip_confirmation: true,
  171. git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}")
  172. )
  173. end
  174. end