From 9834b246a838d8a590478ecf3f4cb221cf8f0951 Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Wed, 1 Mar 2023 11:41:56 +0700 Subject: [PATCH 01/21] Set the correct provisioning profile after match sync --- fastlane/Fastfile.swift | 14 ----------- fastlane/Helpers/Match.swift | 45 ++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 14 deletions(-) diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index f6724110..b88ecfd0 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -145,20 +145,6 @@ class Fastfile: LaneFile { ) } - func updateProvisionSettingsLane() { - desc("Update Provision Profile") - syncAppStoreCodeSigningLane() - updateCodeSigningSettings( - path: Constant.projectPath, - useAutomaticSigning: .userDefined(false), - teamId: .userDefined(EnvironmentParser.string(key: "sigh_\(Constant.productionBundleId)_appstore_team-id")), - codeSignIdentity: .userDefined("iPhone Distribution"), - profileName: .userDefined(EnvironmentParser.string( - key: "sigh_\(Constant.productionBundleId)_appstore_profile-name" - )) - ) - } - func setUpTestProjectLane() { desc("Disable Exempt Encryption") Test.disableExemptEncryption() diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index f19aab1e..66de9b57 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -32,6 +32,51 @@ enum Match { gitUrl: Constant.matchURL, force: .userDefined(isForce) ) + updateCodeSigning(type: type, appIdentifier: appIdentifier) + } + } + + static func updateCodeSigning(type: MatchType, appIdentifier: [String]) { + // Update Code signing from automatic to manual + switch type { + case .development: + updateCodeSigningSettings( + path: Constant.projectPath, + useAutomaticSigning: .userDefined(false), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["Release Staging"]), + codeSignIdentity: .userDefined("iPhone Developer"), + profileName: .userDefined("match AdHoc \(Constant.stagingBundleId)") + ) + case .adHoc: + if appIdentifier.first == Constant.productionBundleId { + updateCodeSigningSettings( + path: Constant.projectPath, + useAutomaticSigning: .userDefined(false), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["Debug Production"]), + codeSignIdentity: .userDefined("iPhone Distribution"), + profileName: .userDefined("match AdHoc \(Constant.productionBundleId)") + ) + } else { + updateCodeSigningSettings( + path: Constant.projectPath, + useAutomaticSigning: .userDefined(false), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["Release Staging"]), + codeSignIdentity: .userDefined("iPhone Distribution"), + profileName: .userDefined("match AdHoc \(Constant.stagingBundleId)") + ) + } + case .appStore: + updateCodeSigningSettings( + path: Constant.projectPath, + useAutomaticSigning: .userDefined(false), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["Release Production"]), + codeSignIdentity: .userDefined("iPhone Distribution"), + profileName: .userDefined("match AppStore \(Constant.productionBundleId)") + ) } } } From e3c67cead035ecbb0aa812818a528ff0c3cbc4c9 Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Wed, 1 Mar 2023 11:48:40 +0700 Subject: [PATCH 02/21] Update code signing for CI too --- fastlane/Helpers/Match.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index 66de9b57..cb08e052 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -32,8 +32,8 @@ enum Match { gitUrl: Constant.matchURL, force: .userDefined(isForce) ) - updateCodeSigning(type: type, appIdentifier: appIdentifier) } + updateCodeSigning(type: type, appIdentifier: appIdentifier) } static func updateCodeSigning(type: MatchType, appIdentifier: [String]) { From 85c403da3f7d3c3506e21d84c85fa6a194a058cb Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Thu, 2 Mar 2023 10:14:28 +0700 Subject: [PATCH 03/21] Fix Debug staging config --- fastlane/Helpers/Match.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index cb08e052..0c5121fb 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -44,9 +44,9 @@ enum Match { path: Constant.projectPath, useAutomaticSigning: .userDefined(false), targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Release Staging"]), + buildConfigurations: .userDefined(["Debug Staging"]), codeSignIdentity: .userDefined("iPhone Developer"), - profileName: .userDefined("match AdHoc \(Constant.stagingBundleId)") + profileName: .userDefined("match Development \(Constant.stagingBundleId)") ) case .adHoc: if appIdentifier.first == Constant.productionBundleId { From 1535c5cb0d5bbf270591150c474651edb75713e8 Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Thu, 2 Mar 2023 10:39:28 +0700 Subject: [PATCH 04/21] Change Debug Production Profile --- fastlane/Helpers/Match.swift | 38 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index 0c5121fb..c9975c0b 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -40,34 +40,34 @@ enum Match { // Update Code signing from automatic to manual switch type { case .development: - updateCodeSigningSettings( - path: Constant.projectPath, - useAutomaticSigning: .userDefined(false), - targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Debug Staging"]), - codeSignIdentity: .userDefined("iPhone Developer"), - profileName: .userDefined("match Development \(Constant.stagingBundleId)") - ) - case .adHoc: if appIdentifier.first == Constant.productionBundleId { updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), targets: .userDefined([Constant.projectName]), buildConfigurations: .userDefined(["Debug Production"]), - codeSignIdentity: .userDefined("iPhone Distribution"), - profileName: .userDefined("match AdHoc \(Constant.productionBundleId)") + codeSignIdentity: .userDefined("iPhone Developer"), + profileName: .userDefined("match \(type.method) \(Constant.productionBundleId)") ) } else { updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Release Staging"]), - codeSignIdentity: .userDefined("iPhone Distribution"), - profileName: .userDefined("match AdHoc \(Constant.stagingBundleId)") + buildConfigurations: .userDefined(["Debug Staging"]), + codeSignIdentity: .userDefined("iPhone Developer"), + profileName: .userDefined("match \(type.method) \(Constant.stagingBundleId)") ) } + case .adHoc: + updateCodeSigningSettings( + path: Constant.projectPath, + useAutomaticSigning: .userDefined(false), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["Release Staging"]), + codeSignIdentity: .userDefined("iPhone Distribution"), + profileName: .userDefined("match \(type.method) \(Constant.stagingBundleId)") + ) case .appStore: updateCodeSigningSettings( path: Constant.projectPath, @@ -75,7 +75,7 @@ enum Match { targets: .userDefined([Constant.projectName]), buildConfigurations: .userDefined(["Release Production"]), codeSignIdentity: .userDefined("iPhone Distribution"), - profileName: .userDefined("match AppStore \(Constant.productionBundleId)") + profileName: .userDefined("match \(type.method) \(Constant.productionBundleId)") ) } } @@ -90,5 +90,13 @@ extension Match { case appStore = "appstore" var value: String { return rawValue } + + var method: String { + switch self { + case .development: return "Development" + case .adHoc: return "AdHoc" + case .appStore: return "AppStore" + } + } } } From 9bc943cca5002036bd3dd42168db968fe8df75d9 Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Thu, 2 Mar 2023 10:47:58 +0700 Subject: [PATCH 05/21] add match development Production lane --- fastlane/Fastfile.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index b88ecfd0..c4abc877 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -12,13 +12,21 @@ class Fastfile: LaneFile { // MARK: - Code signing - func syncDevelopmentCodeSigningLane() { + func syncDevelopmentStagingCodeSigningLane() { desc("Sync the Development match signing for the Staging build") Match.syncCodeSigning( type: .development, appIdentifier: [Constant.stagingBundleId] ) } + + func syncDevelopmentProductionCodeSigningLane() { + desc("Sync the Development match signing for the Staging build") + Match.syncCodeSigning( + type: .development, + appIdentifier: [Constant.productionBundleId] + ) + } func syncAdHocStagingCodeSigningLane() { desc("Sync the Ad Hoc match signing for the Staging build") From f86b7dcc4d1f7a3b69f115db4b0f72d5dc877e01 Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Wed, 8 Mar 2023 10:57:53 +0700 Subject: [PATCH 06/21] Refactored to use enums more --- fastlane/Fastfile.swift | 14 +++--- fastlane/Helpers/Match.swift | 84 +++++++++++++++++------------------- 2 files changed, 46 insertions(+), 52 deletions(-) diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index c4abc877..b5be4b11 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -16,7 +16,7 @@ class Fastfile: LaneFile { desc("Sync the Development match signing for the Staging build") Match.syncCodeSigning( type: .development, - appIdentifier: [Constant.stagingBundleId] + environment: .staging ) } @@ -24,7 +24,7 @@ class Fastfile: LaneFile { desc("Sync the Development match signing for the Staging build") Match.syncCodeSigning( type: .development, - appIdentifier: [Constant.productionBundleId] + environment: .production ) } @@ -32,7 +32,7 @@ class Fastfile: LaneFile { desc("Sync the Ad Hoc match signing for the Staging build") Match.syncCodeSigning( type: .adHoc, - appIdentifier: [Constant.stagingBundleId] + environment: .staging ) } @@ -40,7 +40,7 @@ class Fastfile: LaneFile { desc("Sync the Ad Hoc match signing for the Production build") Match.syncCodeSigning( type: .adHoc, - appIdentifier: [Constant.productionBundleId] + environment: .production ) } @@ -48,7 +48,7 @@ class Fastfile: LaneFile { desc("Sync the App Store match signing for the Production build") Match.syncCodeSigning( type: .appStore, - appIdentifier: [Constant.productionBundleId] + environment: .production ) } @@ -170,8 +170,8 @@ class Fastfile: LaneFile { teamId: .userDefined(Constant.teamId) ) - Match.syncCodeSigning(type: .development, appIdentifier: [], isForce: true) - Match.syncCodeSigning(type: .adHoc, appIdentifier: [], isForce: true) + Match.syncCodeSigning(type: .development, environment: .staging, isForce: true) + Match.syncCodeSigning(type: .adHoc, environment: .staging, isForce: true) } // MARK: - Utilities diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index c9975c0b..4a5cf4e9 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -8,13 +8,13 @@ enum Match { - static func syncCodeSigning(type: MatchType, appIdentifier: [String], isForce: Bool = false) { + static func syncCodeSigning(type: MatchType, environment: Environment, isForce: Bool = false) { if isCi() { Keychain.create() match( type: type.value, readonly: .userDefined(!isForce), - appIdentifier: appIdentifier, + appIdentifier: [environment.bundleId], username: .userDefined(Constant.userName), teamId: .userDefined(Constant.teamId), gitUrl: Constant.matchURL, @@ -26,62 +26,42 @@ enum Match { match( type: type.value, readonly: .userDefined(!isForce), - appIdentifier: appIdentifier, + appIdentifier: [environment.bundleId], username: .userDefined(Constant.userName), teamId: .userDefined(Constant.teamId), gitUrl: Constant.matchURL, force: .userDefined(isForce) ) } - updateCodeSigning(type: type, appIdentifier: appIdentifier) + updateCodeSigning(type: type, environment: environment) } - static func updateCodeSigning(type: MatchType, appIdentifier: [String]) { + static func updateCodeSigning(type: MatchType, environment: Environment) { // Update Code signing from automatic to manual - switch type { - case .development: - if appIdentifier.first == Constant.productionBundleId { - updateCodeSigningSettings( - path: Constant.projectPath, - useAutomaticSigning: .userDefined(false), - targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Debug Production"]), - codeSignIdentity: .userDefined("iPhone Developer"), - profileName: .userDefined("match \(type.method) \(Constant.productionBundleId)") - ) - } else { - updateCodeSigningSettings( - path: Constant.projectPath, - useAutomaticSigning: .userDefined(false), - targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Debug Staging"]), - codeSignIdentity: .userDefined("iPhone Developer"), - profileName: .userDefined("match \(type.method) \(Constant.stagingBundleId)") - ) - } - case .adHoc: - updateCodeSigningSettings( - path: Constant.projectPath, - useAutomaticSigning: .userDefined(false), - targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Release Staging"]), - codeSignIdentity: .userDefined("iPhone Distribution"), - profileName: .userDefined("match \(type.method) \(Constant.stagingBundleId)") - ) - case .appStore: - updateCodeSigningSettings( - path: Constant.projectPath, - useAutomaticSigning: .userDefined(false), - targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["Release Production"]), - codeSignIdentity: .userDefined("iPhone Distribution"), - profileName: .userDefined("match \(type.method) \(Constant.productionBundleId)") - ) - } + updateCodeSigningSettings( + path: Constant.projectPath, + useAutomaticSigning: .userDefined(false), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["\(type.buildConfiguration) \(environment.rawValue)"]), + codeSignIdentity: .userDefined(type.codeSignIdentity), + profileName: .userDefined("match \(type.method) \(environment.bundleId)") + ) } } extension Match { + + enum Environment: String { + case staging = "Staging" + case production = "Production" + + var bundleId: String { + switch self { + case .staging: return Constant.stagingBundleId + case .production: return Constant.productionBundleId + } + } + } enum MatchType: String { @@ -98,5 +78,19 @@ extension Match { case .appStore: return "AppStore" } } + + var buildConfiguration: String { + switch self { + case .development: return "Debug" + case .adHoc, .appStore: return "Release" + } + } + + var codeSignIdentity: String { + switch self { + case .development: return "iPhone Developer" + case .adHoc, . appStore: return "iPhone Distribution" + } + } } } From 160be0c3b3e896f463a6d2eba80706a6334f34eb Mon Sep 17 00:00:00 2001 From: Edgars Simanovskis Date: Wed, 8 Mar 2023 16:01:08 +0700 Subject: [PATCH 07/21] [330] Use correct lane in github workflow --- .github/workflows/test_upload_build_to_test_flight.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test_upload_build_to_test_flight.yml b/.github/workflows/test_upload_build_to_test_flight.yml index 744aa635..4e0b390d 100644 --- a/.github/workflows/test_upload_build_to_test_flight.yml +++ b/.github/workflows/test_upload_build_to_test_flight.yml @@ -56,7 +56,7 @@ jobs: run: bundle exec fastlane setUpTestProject - name: Update Provision Profile - run: bundle exec fastlane updateProvisionSettings + run: bundle exec fastlane syncAppStoreCodeSigning env: MATCH_PASSWORD: ${{ secrets.MATCH_PASS }} From 17edf5948e440a073a33bfe6d834738da5b17ce2 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 13 Apr 2023 09:41:19 +0700 Subject: [PATCH 08/21] [#330] Update updateCodeSingingSettings with environment value --- fastlane/Helpers/Match.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index 4a5cf4e9..ddddaf4a 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -41,10 +41,13 @@ enum Match { updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), - targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["\(type.buildConfiguration) \(environment.rawValue)"]), + teamId: .userDefined(EnvironmentParser.string( + key: "sigh_\(Constant.productionBundleId)_\(type.rawValue)_team-id" + )), codeSignIdentity: .userDefined(type.codeSignIdentity), - profileName: .userDefined("match \(type.method) \(environment.bundleId)") + profileName: .userDefined(EnvironmentParser.string( + key: "sigh_\(environment.bundleId)_\(type.rawValue)_profile-name" + )) ) } } From f4cc8b600c1bfd1435c89cf36d959df9803e6be3 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 13 Apr 2023 10:09:59 +0700 Subject: [PATCH 09/21] [#330] Update updateCodeSingingSettings --- fastlane/Helpers/Match.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index ddddaf4a..b30cf837 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -42,7 +42,7 @@ enum Match { path: Constant.projectPath, useAutomaticSigning: .userDefined(false), teamId: .userDefined(EnvironmentParser.string( - key: "sigh_\(Constant.productionBundleId)_\(type.rawValue)_team-id" + key: "sigh_\(environment.bundleId)_\(type.rawValue)_team-id" )), codeSignIdentity: .userDefined(type.codeSignIdentity), profileName: .userDefined(EnvironmentParser.string( From c21cd1297d3a4b4f42c56249e0ffdbd550f3ab53 Mon Sep 17 00:00:00 2001 From: David Date: Thu, 13 Apr 2023 11:32:01 +0700 Subject: [PATCH 10/21] [#330] Update updateCodeSingingSettings --- fastlane/Helpers/Match.swift | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index b30cf837..ef68e149 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -7,7 +7,7 @@ // enum Match { - + static func syncCodeSigning(type: MatchType, environment: Environment, isForce: Bool = false) { if isCi() { Keychain.create() @@ -41,13 +41,11 @@ enum Match { updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), - teamId: .userDefined(EnvironmentParser.string( - key: "sigh_\(environment.bundleId)_\(type.rawValue)_team-id" - )), + teamId: .userDefined(Constant.teamId), + targets: .userDefined([Constant.projectName]), + buildConfigurations: .userDefined(["\(type.buildConfiguration) \(environment.rawValue)"]), codeSignIdentity: .userDefined(type.codeSignIdentity), - profileName: .userDefined(EnvironmentParser.string( - key: "sigh_\(environment.bundleId)_\(type.rawValue)_profile-name" - )) + profileName: .userDefined("match \(type.method) \(environment.bundleId)") ) } } @@ -55,6 +53,7 @@ enum Match { extension Match { enum Environment: String { + case staging = "Staging" case production = "Production" @@ -65,13 +64,13 @@ extension Match { } } } - + enum MatchType: String { - + case development case adHoc = "adhoc" case appStore = "appstore" - + var value: String { return rawValue } var method: String { @@ -88,7 +87,6 @@ extension Match { case .adHoc, .appStore: return "Release" } } - var codeSignIdentity: String { switch self { case .development: return "iPhone Developer" From 9c321705148be40c1316e7104cb298ccdf890eda Mon Sep 17 00:00:00 2001 From: David Date: Thu, 13 Apr 2023 11:57:39 +0700 Subject: [PATCH 11/21] [#330] Update SET UP TEST TESTFLIGHT SH --- set_up_test_testflight.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh index 350baa71..73711b39 100644 --- a/set_up_test_testflight.sh +++ b/set_up_test_testflight.sh @@ -1,5 +1,6 @@ echo "import('./Tests/Fastfile')" | cat - fastlane/Fastfile | tee fastlane/Fastfile &> /dev/null +readonly CONSTANT_TEAM_ID="<#teamId#>" readonly CONSTANT_API_KEY_ID="<#API_KEY_ID#>" readonly CONSTANT_ISSUER_ID="<#ISSUER_ID#>" readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" @@ -7,6 +8,7 @@ readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") +LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/4TWS7E2EPE/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} + From 91aa28d70199d73e6750613e760bddd79876e661 Mon Sep 17 00:00:00 2001 From: David Date: Wed, 19 Apr 2023 10:33:53 +0700 Subject: [PATCH 12/21] [#330] Update desc of syncDevelopmentProductionCodeSigningLane and buildProductionAndUploadToFirebaseLane --- fastlane/Fastfile.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fastlane/Fastfile.swift b/fastlane/Fastfile.swift index b5be4b11..b1dc07bd 100644 --- a/fastlane/Fastfile.swift +++ b/fastlane/Fastfile.swift @@ -21,7 +21,7 @@ class Fastfile: LaneFile { } func syncDevelopmentProductionCodeSigningLane() { - desc("Sync the Development match signing for the Staging build") + desc("Sync the Development match signing for the Production build") Match.syncCodeSigning( type: .development, environment: .production @@ -88,7 +88,7 @@ class Fastfile: LaneFile { } func buildProductionAndUploadToFirebaseLane() { - desc("Build Staging app and upload to Firebase") + desc("Build Production app and upload to Firebase") setAppVersion() bumpBuild() From 8f222130d26de31d470037e755dfbdb56d41285a Mon Sep 17 00:00:00 2001 From: David Date: Thu, 20 Apr 2023 13:47:38 +0700 Subject: [PATCH 13/21] [#330] Add TEAM_ID in GitHub Secret. Then import and use it as a env variable Update code format --- .github/workflows/test_upload_build_to_test_flight.yml | 2 ++ fastlane/Helpers/Match.swift | 6 +++--- set_up_test_testflight.sh | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_upload_build_to_test_flight.yml b/.github/workflows/test_upload_build_to_test_flight.yml index 4e0b390d..91cdf243 100644 --- a/.github/workflows/test_upload_build_to_test_flight.yml +++ b/.github/workflows/test_upload_build_to_test_flight.yml @@ -7,6 +7,7 @@ name: Test Upload Build to TestFlight ### API_KEY_ID ### ISSUER_ID ### APPSTORE_CONNECT_API_KEY +### TEAM_ID on: pull_request @@ -51,6 +52,7 @@ jobs: MATCH_REPO: ${{ secrets.MATCH_REPO }} API_KEY_ID: ${{ secrets.API_KEY_ID }} ISSUER_ID: ${{ secrets.ISSUER_ID }} + TEAM_ID: ${{ secrets.TEAM_ID }} - name: Set Up Test Project for App Store run: bundle exec fastlane setUpTestProject diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index ef68e149..e4131d5b 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -66,13 +66,13 @@ extension Match { } enum MatchType: String { - + case development case adHoc = "adhoc" case appStore = "appstore" - + var value: String { return rawValue } - + var method: String { switch self { case .development: return "Development" diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh index 73711b39..7455f34a 100644 --- a/set_up_test_testflight.sh +++ b/set_up_test_testflight.sh @@ -8,7 +8,7 @@ readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/4TWS7E2EPE/g" {} + +LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/$TEAM_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} + From 4ef406174c5f39c644b68300fb1bf20e366716e4 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 09:17:17 +0700 Subject: [PATCH 14/21] [#330] Update code format --- fastlane/Helpers/Match.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index e4131d5b..c807249a 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -7,7 +7,7 @@ // enum Match { - + static func syncCodeSigning(type: MatchType, environment: Environment, isForce: Bool = false) { if isCi() { Keychain.create() From 30152ccf1330397d42c56fb45274ccb8329bd4d8 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 13:14:25 +0700 Subject: [PATCH 15/21] [#330] Remove Match.Environment and MatchType Merge Match.Environment to Constant.Environment Merge Match.MatchType to Constant.BuildType --- fastlane/Constants/Constant.swift | 20 ++++++++++-- fastlane/Helpers/Match.swift | 54 +++++-------------------------- 2 files changed, 26 insertions(+), 48 deletions(-) diff --git a/fastlane/Constants/Constant.swift b/fastlane/Constants/Constant.swift index adc32ed8..dd45ef98 100644 --- a/fastlane/Constants/Constant.swift +++ b/fastlane/Constants/Constant.swift @@ -79,7 +79,7 @@ extension Constant { enum Environment: String { case staging = "Staging" - case production = "" + case production = "Production" var productName: String { "\(Constant.projectName) \(rawValue)".trimmed } @@ -116,13 +116,29 @@ extension Constant { enum BuildType: String { + case development case adHoc = "ad-hoc" case appStore = "app-store" var value: String { return rawValue } - + + var configuration: String { + switch self { + case .development: return "Debug" + case .adHoc, .appStore: return "Release" + } + } + + var codeSignIdentity: String { + switch self { + case .development: return "iPhone Developer" + case .adHoc, . appStore: return "iPhone Distribution" + } + } + var method: String { switch self { + case .development: return "Development" case .adHoc: return "AdHoc" case .appStore: return "AppStore" } diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index c807249a..8e7f0dd8 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -8,7 +8,7 @@ enum Match { - static func syncCodeSigning(type: MatchType, environment: Environment, isForce: Bool = false) { + static func syncCodeSigning(type: Constant.BuildType, environment: Constant.Environment, isForce: Bool = false) { if isCi() { Keychain.create() match( @@ -36,62 +36,24 @@ enum Match { updateCodeSigning(type: type, environment: environment) } - static func updateCodeSigning(type: MatchType, environment: Environment) { + static func updateCodeSigning(type: Constant.BuildType, environment: Constant.Environment) { // Update Code signing from automatic to manual updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), teamId: .userDefined(Constant.teamId), targets: .userDefined([Constant.projectName]), - buildConfigurations: .userDefined(["\(type.buildConfiguration) \(environment.rawValue)"]), + buildConfigurations: .userDefined([Self.createBuildConfiguration(type: type, environment: environment)]), codeSignIdentity: .userDefined(type.codeSignIdentity), - profileName: .userDefined("match \(type.method) \(environment.bundleId)") + profileName: .userDefined(Self.createProfileName(type: type, environment: environment)) ) } -} - -extension Match { - enum Environment: String { - - case staging = "Staging" - case production = "Production" - - var bundleId: String { - switch self { - case .staging: return Constant.stagingBundleId - case .production: return Constant.productionBundleId - } - } + static func createBuildConfiguration(type: Constant.BuildType, environment: Constant.Environment) -> String { + "\(type.configuration) \(environment.rawValue)" } - enum MatchType: String { - - case development - case adHoc = "adhoc" - case appStore = "appstore" - - var value: String { return rawValue } - - var method: String { - switch self { - case .development: return "Development" - case .adHoc: return "AdHoc" - case .appStore: return "AppStore" - } - } - - var buildConfiguration: String { - switch self { - case .development: return "Debug" - case .adHoc, .appStore: return "Release" - } - } - var codeSignIdentity: String { - switch self { - case .development: return "iPhone Developer" - case .adHoc, . appStore: return "iPhone Distribution" - } - } + static func createProfileName(type: Constant.BuildType, environment: Constant.Environment) -> String { + "match \(type.method) \(environment.bundleId)" } } From 6fcb7fbbd59efe486c51032996fa9f79ba9d5504 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 13:16:20 +0700 Subject: [PATCH 16/21] [#330] Revert to use hard code team id for test test flight --- set_up_test_testflight.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh index 7455f34a..5428a5c2 100644 --- a/set_up_test_testflight.sh +++ b/set_up_test_testflight.sh @@ -1,5 +1,3 @@ -echo "import('./Tests/Fastfile')" | cat - fastlane/Fastfile | tee fastlane/Fastfile &> /dev/null - readonly CONSTANT_TEAM_ID="<#teamId#>" readonly CONSTANT_API_KEY_ID="<#API_KEY_ID#>" readonly CONSTANT_ISSUER_ID="<#ISSUER_ID#>" @@ -8,7 +6,7 @@ readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/$TEAM_ID/g" {} + +LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/4TWS7E2EPE/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} + From 253e367c20d91f14c0e42ff4672002bbcc8873ba Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 13:18:51 +0700 Subject: [PATCH 17/21] [#330] Improve code --- fastlane/Helpers/Build.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastlane/Helpers/Build.swift b/fastlane/Helpers/Build.swift index b1e3682f..587b62d9 100644 --- a/fastlane/Helpers/Build.swift +++ b/fastlane/Helpers/Build.swift @@ -52,7 +52,7 @@ enum Build { exportMethod: .userDefined(type.value), exportOptions: .userDefined([ "provisioningProfiles": [ - environment.bundleId: "match \(type.method) \(environment.bundleId)" + environment.bundleId: Match.createProfileName(type: type, environment: environment) ] ]), buildPath: .userDefined(Constant.buildPath), From 6666c185a80688dec507e602b7d17de42ea455c2 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 13:28:41 +0700 Subject: [PATCH 18/21] [#330] Update match type --- fastlane/Constants/Constant.swift | 8 ++++++++ fastlane/Helpers/Match.swift | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fastlane/Constants/Constant.swift b/fastlane/Constants/Constant.swift index dd45ef98..5de3e928 100644 --- a/fastlane/Constants/Constant.swift +++ b/fastlane/Constants/Constant.swift @@ -122,6 +122,14 @@ extension Constant { var value: String { return rawValue } + var match: String { + switch self { + case .development: return "development" + case .adHoc: return "adhoc" + case .appStore: return "appstore" + } + } + var configuration: String { switch self { case .development: return "Debug" diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index 8e7f0dd8..7065e442 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -12,7 +12,7 @@ enum Match { if isCi() { Keychain.create() match( - type: type.value, + type: type.match, readonly: .userDefined(!isForce), appIdentifier: [environment.bundleId], username: .userDefined(Constant.userName), @@ -24,7 +24,7 @@ enum Match { ) } else { match( - type: type.value, + type: type.match, readonly: .userDefined(!isForce), appIdentifier: [environment.bundleId], username: .userDefined(Constant.userName), From fd3b3ba45e95290b8be3e7b53da90f1cb87d51e5 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 13:36:26 +0700 Subject: [PATCH 19/21] [#330] Remove setting team id --- fastlane/Constants/Constant.swift | 7 ++++++- fastlane/Helpers/Match.swift | 1 - set_up_test_testflight.sh | 2 -- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/fastlane/Constants/Constant.swift b/fastlane/Constants/Constant.swift index 5de3e928..e8dfa15c 100644 --- a/fastlane/Constants/Constant.swift +++ b/fastlane/Constants/Constant.swift @@ -83,7 +83,12 @@ extension Constant { var productName: String { "\(Constant.projectName) \(rawValue)".trimmed } - var scheme: String { "\(Constant.projectName) \(rawValue)".trimmed } + var scheme: String { + switch self { + case .staging: return "\(Constant.projectName) \(rawValue)".trimmed + case .production: return Constant.projectName + } + } var bundleId: String { switch self { diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index 7065e442..86bbac82 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -41,7 +41,6 @@ enum Match { updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), - teamId: .userDefined(Constant.teamId), targets: .userDefined([Constant.projectName]), buildConfigurations: .userDefined([Self.createBuildConfiguration(type: type, environment: environment)]), codeSignIdentity: .userDefined(type.codeSignIdentity), diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh index 5428a5c2..ad855795 100644 --- a/set_up_test_testflight.sh +++ b/set_up_test_testflight.sh @@ -1,4 +1,3 @@ -readonly CONSTANT_TEAM_ID="<#teamId#>" readonly CONSTANT_API_KEY_ID="<#API_KEY_ID#>" readonly CONSTANT_ISSUER_ID="<#ISSUER_ID#>" readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" @@ -6,7 +5,6 @@ readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/4TWS7E2EPE/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} + From 57a3c1ad786bcad2d66f21776f848a6d9b278ca5 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Apr 2023 14:43:18 +0700 Subject: [PATCH 20/21] [#330] Update setting teamId in Match updateCodeSingingSettings Update hard-code teamId in set_up_test_testflight.sh --- fastlane/Helpers/Match.swift | 1 + set_up_test_testflight.sh | 2 ++ 2 files changed, 3 insertions(+) diff --git a/fastlane/Helpers/Match.swift b/fastlane/Helpers/Match.swift index 86bbac82..7065e442 100644 --- a/fastlane/Helpers/Match.swift +++ b/fastlane/Helpers/Match.swift @@ -41,6 +41,7 @@ enum Match { updateCodeSigningSettings( path: Constant.projectPath, useAutomaticSigning: .userDefined(false), + teamId: .userDefined(Constant.teamId), targets: .userDefined([Constant.projectName]), buildConfigurations: .userDefined([Self.createBuildConfiguration(type: type, environment: environment)]), codeSignIdentity: .userDefined(type.codeSignIdentity), diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh index ad855795..5428a5c2 100644 --- a/set_up_test_testflight.sh +++ b/set_up_test_testflight.sh @@ -1,3 +1,4 @@ +readonly CONSTANT_TEAM_ID="<#teamId#>" readonly CONSTANT_API_KEY_ID="<#API_KEY_ID#>" readonly CONSTANT_ISSUER_ID="<#ISSUER_ID#>" readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" @@ -5,6 +6,7 @@ readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") +LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/4TWS7E2EPE/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} + From 67d66bac83466a6668fa623b5a36844017ce7d6c Mon Sep 17 00:00:00 2001 From: David Date: Fri, 28 Apr 2023 09:32:46 +0700 Subject: [PATCH 21/21] [#330] Update set teamId from env variable in set_up_test_testflight.sh --- set_up_test_testflight.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/set_up_test_testflight.sh b/set_up_test_testflight.sh index 5428a5c2..c1e1290e 100644 --- a/set_up_test_testflight.sh +++ b/set_up_test_testflight.sh @@ -6,7 +6,7 @@ readonly CONSTANT_MATCH_REPO="git@github.com:{organization}\/{repo}.git" readonly WORKING_DIR=$(cd -P -- "$(dirname -- "$0")" && pwd -P) MATCH_REPO_ESCAPED=$(echo "${MATCH_REPO//\//\\\/}") -LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/4TWS7E2EPE/g" {} + +LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_TEAM_ID/$TEAM_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_API_KEY_ID/$API_KEY_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_ISSUER_ID/$ISSUER_ID/g" {} + LC_ALL=C find $WORKING_DIR -type f -exec sed -i "" "s/$CONSTANT_MATCH_REPO/$MATCH_REPO_ESCAPED/g" {} +