|
| 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 | + |
| 13 | +default_platform(:ios) |
| 14 | + |
| 15 | +TEAMID = ENV["TEAMID"] |
| 16 | +GH_PAT = ENV["GH_PAT"] |
| 17 | +GITHUB_WORKSPACE = ENV["GITHUB_WORKSPACE"] |
| 18 | +GITHUB_REPOSITORY_OWNER = ENV["GITHUB_REPOSITORY_OWNER"] |
| 19 | +FASTLANE_KEY_ID = ENV["FASTLANE_KEY_ID"] |
| 20 | +FASTLANE_ISSUER_ID = ENV["FASTLANE_ISSUER_ID"] |
| 21 | +FASTLANE_KEY = ENV["FASTLANE_KEY"] |
| 22 | +DEVICE_NAME = ENV["DEVICE_NAME"] |
| 23 | +DEVICE_ID = ENV["DEVICE_ID"] |
| 24 | +ENV["FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT"] = "120" |
| 25 | + |
| 26 | +platform :ios do |
| 27 | + desc "Build Loop" |
| 28 | + lane :build_loop do |
| 29 | + setup_ci if ENV['CI'] |
| 30 | + |
| 31 | + update_project_team( |
| 32 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 33 | + teamid: "#{TEAMID}" |
| 34 | + ) |
| 35 | + |
| 36 | + api_key = app_store_connect_api_key( |
| 37 | + key_id: "#{FASTLANE_KEY_ID}", |
| 38 | + issuer_id: "#{FASTLANE_ISSUER_ID}", |
| 39 | + key_content: "#{FASTLANE_KEY}" |
| 40 | + ) |
| 41 | + |
| 42 | + previous_build_number = latest_testflight_build_number( |
| 43 | + app_identifier: "com.#{TEAMID}.loopkit.Loop", |
| 44 | + api_key: api_key, |
| 45 | + ) |
| 46 | + |
| 47 | + current_build_number = previous_build_number + 1 |
| 48 | + |
| 49 | + increment_build_number( |
| 50 | + xcodeproj: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 51 | + build_number: current_build_number |
| 52 | + ) |
| 53 | + |
| 54 | + match( |
| 55 | + type: "appstore", |
| 56 | + git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"), |
| 57 | + app_identifier: [ |
| 58 | + "com.#{TEAMID}.loopkit.Loop", |
| 59 | + "com.#{TEAMID}.loopkit.Loop.statuswidget", |
| 60 | + "com.#{TEAMID}.loopkit.Loop.LoopWatch.watchkitextension", |
| 61 | + "com.#{TEAMID}.loopkit.Loop.LoopWatch", |
| 62 | + "com.#{TEAMID}.loopkit.Loop.Loop-Intent-Extension", |
| 63 | + "com.#{TEAMID}.loopkit.Loop.SmallStatusWidget" |
| 64 | + ] |
| 65 | + ) |
| 66 | + |
| 67 | + previous_build_number = latest_testflight_build_number( |
| 68 | + app_identifier: "com.#{TEAMID}.loopkit.Loop", |
| 69 | + api_key: api_key, |
| 70 | + ) |
| 71 | + |
| 72 | + current_build_number = previous_build_number + 1 |
| 73 | + |
| 74 | + increment_build_number( |
| 75 | + xcodeproj: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 76 | + build_number: current_build_number |
| 77 | + ) |
| 78 | + |
| 79 | + mapping = Actions.lane_context[ |
| 80 | + SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING |
| 81 | + ] |
| 82 | + |
| 83 | + update_code_signing_settings( |
| 84 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 85 | + profile_name: mapping["com.#{TEAMID}.loopkit.Loop"], |
| 86 | + code_sign_identity: "iPhone Distribution", |
| 87 | + targets: ["Loop"] |
| 88 | + ) |
| 89 | + |
| 90 | + update_code_signing_settings( |
| 91 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 92 | + code_sign_identity: "iPhone Distribution", |
| 93 | + targets: ["LoopCore", "LoopCore-watchOS", "LoopUI"] |
| 94 | + ) |
| 95 | + |
| 96 | + update_code_signing_settings( |
| 97 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 98 | + profile_name: mapping["com.#{TEAMID}.loopkit.Loop.statuswidget"], |
| 99 | + code_sign_identity: "iPhone Distribution", |
| 100 | + targets: ["Loop Status Extension"] |
| 101 | + ) |
| 102 | + |
| 103 | + update_code_signing_settings( |
| 104 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 105 | + profile_name: mapping["com.#{TEAMID}.loopkit.Loop.LoopWatch.watchkitextension"], |
| 106 | + code_sign_identity: "iPhone Distribution", |
| 107 | + targets: ["WatchApp Extension"] |
| 108 | + ) |
| 109 | + |
| 110 | + update_code_signing_settings( |
| 111 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 112 | + profile_name: mapping["com.#{TEAMID}.loopkit.Loop.LoopWatch"], |
| 113 | + code_sign_identity: "iPhone Distribution", |
| 114 | + targets: ["WatchApp"] |
| 115 | + ) |
| 116 | + |
| 117 | + update_code_signing_settings( |
| 118 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 119 | + profile_name: mapping["com.#{TEAMID}.loopkit.Loop.Loop-Intent-Extension"], |
| 120 | + code_sign_identity: "iPhone Distribution", |
| 121 | + targets: ["Loop Intent Extension"] |
| 122 | + ) |
| 123 | + |
| 124 | + update_code_signing_settings( |
| 125 | + path: "#{GITHUB_WORKSPACE}/Loop/Loop.xcodeproj", |
| 126 | + profile_name: mapping["com.#{TEAMID}.loopkit.Loop.SmallStatusWidget"], |
| 127 | + code_sign_identity: "iPhone Distribution", |
| 128 | + targets: ["SmallStatusWidgetExtension"] |
| 129 | + ) |
| 130 | + |
| 131 | + gym( |
| 132 | + export_method: "app-store", |
| 133 | + scheme: "Loop (Workspace)", |
| 134 | + output_name: "Loop.ipa", |
| 135 | + configuration: "Release", |
| 136 | + destination: 'generic/platform=iOS' |
| 137 | + ) |
| 138 | + end |
| 139 | + |
| 140 | + desc "Push to TestFlight" |
| 141 | + lane :release do |
| 142 | + api_key = app_store_connect_api_key( |
| 143 | + key_id: "#{FASTLANE_KEY_ID}", |
| 144 | + issuer_id: "#{FASTLANE_ISSUER_ID}", |
| 145 | + key_content: "#{FASTLANE_KEY}" |
| 146 | + ) |
| 147 | + |
| 148 | + upload_to_testflight( |
| 149 | + api_key: api_key, |
| 150 | + skip_submission: false, |
| 151 | + ipa: "Loop.ipa", |
| 152 | + skip_waiting_for_build_processing: true, |
| 153 | + ) |
| 154 | + end |
| 155 | + |
| 156 | + desc "Provision Identifiers and Certificates" |
| 157 | + lane :identifiers do |
| 158 | + setup_ci if ENV['CI'] |
| 159 | + ENV["MATCH_READONLY"] = false.to_s |
| 160 | + |
| 161 | + app_store_connect_api_key( |
| 162 | + key_id: "#{FASTLANE_KEY_ID}", |
| 163 | + issuer_id: "#{FASTLANE_ISSUER_ID}", |
| 164 | + key_content: "#{FASTLANE_KEY}" |
| 165 | + ) |
| 166 | + |
| 167 | + def configure_bundle_id(name, identifier, capabilities) |
| 168 | + bundle_id = Spaceship::ConnectAPI::BundleId.find(identifier) || Spaceship::ConnectAPI::BundleId.create(name: name, identifier: identifier) |
| 169 | + capabilities.each { |capability| |
| 170 | + bundle_id.create_capability(capability) |
| 171 | + } |
| 172 | + end |
| 173 | + |
| 174 | + configure_bundle_id("Loop", "com.#{TEAMID}.loopkit.Loop", [ |
| 175 | + Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS, |
| 176 | + Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT, |
| 177 | + Spaceship::ConnectAPI::BundleIdCapability::Type::PUSH_NOTIFICATIONS, |
| 178 | + Spaceship::ConnectAPI::BundleIdCapability::Type::SIRIKIT |
| 179 | + ]) |
| 180 | + |
| 181 | + configure_bundle_id("Loop Intent Extension", "com.#{TEAMID}.loopkit.Loop.Loop-Intent-Extension", [ |
| 182 | + Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS |
| 183 | + ]) |
| 184 | + |
| 185 | + configure_bundle_id("Loop Status Extension", "com.#{TEAMID}.loopkit.Loop.statuswidget", [ |
| 186 | + Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS |
| 187 | + ]) |
| 188 | + |
| 189 | + configure_bundle_id("WatchApp", "com.#{TEAMID}.loopkit.Loop.LoopWatch", []) |
| 190 | + |
| 191 | + configure_bundle_id("WatchApp Extension", "com.#{TEAMID}.loopkit.Loop.LoopWatch.watchkitextension", [ |
| 192 | + Spaceship::ConnectAPI::BundleIdCapability::Type::HEALTHKIT, |
| 193 | + Spaceship::ConnectAPI::BundleIdCapability::Type::SIRIKIT |
| 194 | + ]) |
| 195 | + |
| 196 | + configure_bundle_id("Small Status Widget", "com.#{TEAMID}.loopkit.Loop.SmallStatusWidget", [ |
| 197 | + Spaceship::ConnectAPI::BundleIdCapability::Type::APP_GROUPS |
| 198 | + ]) |
| 199 | + |
| 200 | + end |
| 201 | + |
| 202 | + desc "Provision Certificates" |
| 203 | + lane :certs do |
| 204 | + setup_ci if ENV['CI'] |
| 205 | + ENV["MATCH_READONLY"] = false.to_s |
| 206 | + |
| 207 | + app_store_connect_api_key( |
| 208 | + key_id: "#{FASTLANE_KEY_ID}", |
| 209 | + issuer_id: "#{FASTLANE_ISSUER_ID}", |
| 210 | + key_content: "#{FASTLANE_KEY}" |
| 211 | + ) |
| 212 | + |
| 213 | + match( |
| 214 | + type: "appstore", |
| 215 | + force: true, |
| 216 | + git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}"), |
| 217 | + app_identifier: [ |
| 218 | + "com.#{TEAMID}.loopkit.Loop", |
| 219 | + "com.#{TEAMID}.loopkit.Loop.statuswidget", |
| 220 | + "com.#{TEAMID}.loopkit.Loop.LoopWatch.watchkitextension", |
| 221 | + "com.#{TEAMID}.loopkit.Loop.LoopWatch", |
| 222 | + "com.#{TEAMID}.loopkit.Loop.Loop-Intent-Extension", |
| 223 | + "com.#{TEAMID}.loopkit.Loop.SmallStatusWidget", |
| 224 | + ] |
| 225 | + ) |
| 226 | + end |
| 227 | + |
| 228 | + desc "Nuke Certs" |
| 229 | + lane :nuke_certs do |
| 230 | + setup_ci if ENV['CI'] |
| 231 | + ENV["MATCH_READONLY"] = false.to_s |
| 232 | + |
| 233 | + app_store_connect_api_key( |
| 234 | + key_id: "#{FASTLANE_KEY_ID}", |
| 235 | + issuer_id: "#{FASTLANE_ISSUER_ID}", |
| 236 | + key_content: "#{FASTLANE_KEY}" |
| 237 | + ) |
| 238 | + |
| 239 | + match_nuke( |
| 240 | + type: "appstore", |
| 241 | + team_id: "#{TEAMID}", |
| 242 | + skip_confirmation: true, |
| 243 | + git_basic_authorization: Base64.strict_encode64("#{GITHUB_REPOSITORY_OWNER}:#{GH_PAT}") |
| 244 | + ) |
| 245 | + end |
| 246 | +end |
0 commit comments