From e3e261549de5d169572526768a2435067b359dc5 Mon Sep 17 00:00:00 2001 From: Harsh Vardhan Date: Fri, 8 Dec 2023 11:56:15 +0530 Subject: [PATCH] feat(INJI-541): add reusable workflows and multiple app flavors * ci(INJI-564): bump up version to 0.10.0 and other changes Signed-off-by: adityankannan-tw --- .github/workflows/internal-build.yml | 21 ++-- ios/Inji.xcodeproj/project.pbxproj | 6 +- ios/fastlane/Fastfile | 153 +++++++++++++++++---------- 3 files changed, 110 insertions(+), 70 deletions(-) diff --git a/.github/workflows/internal-build.yml b/.github/workflows/internal-build.yml index 8837dd7f..ae38aa38 100644 --- a/.github/workflows/internal-build.yml +++ b/.github/workflows/internal-build.yml @@ -86,7 +86,7 @@ jobs: uses: mosip/kattu/.github/workflows/android-publish.yml@master with: RELEASE: ${{ inputs.release }} - NODE_VERSION: '16.x' + NODE_VERSION: '18.x' RELEASE_KEYSTORE_ALIAS: androidreleasekey MIMOTO_HOST: ${{ inputs.mimotoBackendServiceUrl }} ESIGNET_HOST: ${{ inputs.esignetBackendServiceUrl }} @@ -97,9 +97,9 @@ jobs: SERVICE_LOCATION: '.' ANDROID_SERVICE_LOCATION: 'android' BUILD_SCRIPT_LOCATION: 'scripts' - SCRIPT_NAME: './${{ inputs.release }}.sh' + SCRIPT_NAME: "./${{ inputs.release }}.sh" ANDROID_ARTIFACT_NAME: ${{ inputs.buildname }} - ANDROID_ARTIFACT_PATH: 'android/app/build/outputs/apk/${{ inputs.injiFlavor }}/release/Inji_universal.apk' + ANDROID_ARTIFACT_PATH: "android/app/build/outputs/apk/${{ inputs.injiFlavor }}/release/Inji_universal.apk" secrets: ANDROID_KEYSTORE_FILE: ${{ secrets.INJI_ANDROID_RELEASE_KEYSTORE }} RELEASE_KEYSTORE_PASSWORD: '${{ secrets.INJI_ANDROID_RELEASE_STOREPASS }}' @@ -111,7 +111,7 @@ jobs: uses: mosip/kattu/.github/workflows/android-publish.yml@master with: RELEASE: ${{ inputs.release }} - NODE_VERSION: '16.x' + NODE_VERSION: '18.x' RELEASE_KEYSTORE_ALIAS: androidreleasekey MIMOTO_HOST: ${{ inputs.mimotoBackendServiceUrl }} ESIGNET_HOST: ${{ inputs.esignetBackendServiceUrl }} @@ -122,9 +122,9 @@ jobs: SERVICE_LOCATION: '.' ANDROID_SERVICE_LOCATION: 'android' BUILD_SCRIPT_LOCATION: 'scripts' - SCRIPT_NAME: './${{ inputs.release }}.sh' + SCRIPT_NAME: "./${{ inputs.release }}.sh" ANDROID_ARTIFACT_NAME: ${{ inputs.buildname }} - ANDROID_ARTIFACT_PATH: 'android/app/build/outputs/apk/${{ inputs.injiFlavor }}/release/Inji_universal.apk' + ANDROID_ARTIFACT_PATH: "android/app/build/outputs/apk/${{ inputs.injiFlavor }}/release/Inji_universal.apk" secrets: ANDROID_KEYSTORE_FILE: ${{ secrets.INJI_ANDROID_RELEASE_KEYSTORE }} RELEASE_KEYSTORE_PASSWORD: '${{ secrets.INJI_ANDROID_RELEASE_STOREPASS }}' @@ -142,11 +142,12 @@ jobs: TESTFLIGHT_BETA_APP_DESCRIPTION: ${{ inputs.buildDescription }} ALLOW_ENV_EDIT: ${{ inputs.allow_env_edit }} TESTFLIGHT_INTERNAL_TESTERS_GROUP: ${{ inputs.internal-testers }} + APP_FLAVOR: ${{ inputs.injiFlavor }} SERVICE_LOCATION: '.' IOS_SERVICE_LOCATION: 'ios' - SCRIPT_NAME: 'fastlane beta' - IOS_ARTIFACT_NAME: 'Inji' - IOS_ARTIFACT_PATH: 'ios/fastlane/Inji_app_file/Products/Applications/' + SCRIPT_NAME: "fastlane beta" + IOS_ARTIFACT_NAME: "Inji" + IOS_ARTIFACT_PATH: "ios/fastlane/Inji_app_file/Products/Applications/" secrets: APP_STORE_CONNECT_TEAM_ID: '${{ secrets.APP_STORE_CONNECT_TEAM_ID }}' DEVELOPER_APP_ID: '${{ secrets.IOS_INJI_DEVELOPER_APP_ID }}' @@ -162,4 +163,4 @@ jobs: APPLE_ISSUER_ID: '${{ secrets.APPLE_ISSUER_ID }}' APPLE_KEY_CONTENT: '${{ secrets.APPLE_KEY_CONTENT }}' MATCH_PASSWORD: '${{ secrets.INJI_IOS_MATCH_PASSWORD }}' - SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' + SLACK_WEBHOOK_URL: '${{ secrets.SLACK_WEBHOOK }}' \ No newline at end of file diff --git a/ios/Inji.xcodeproj/project.pbxproj b/ios/Inji.xcodeproj/project.pbxproj index f67e4d59..dcab48cc 100644 --- a/ios/Inji.xcodeproj/project.pbxproj +++ b/ios/Inji.xcodeproj/project.pbxproj @@ -361,7 +361,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.9.1; + MARKETING_VERSION = 0.10.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -398,7 +398,7 @@ "$(inherited)", "@executable_path/Frameworks", ); - MARKETING_VERSION = 0.9.1; + MARKETING_VERSION = 0.10.0; OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", @@ -557,4 +557,4 @@ /* End XCConfigurationList section */ }; rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} +} \ No newline at end of file diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index a99dfc75..2a920c32 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -5,7 +5,6 @@ APP_STORE_CONNECT_TEAM_ID = ENV["APP_STORE_CONNECT_TEAM_ID"] APPLE_ISSUER_ID = ENV["APPLE_ISSUER_ID"] APPLE_KEY_CONTENT = ENV["APPLE_KEY_CONTENT"] APPLE_KEY_ID = ENV["APPLE_KEY_ID"] -DEVELOPER_APP_IDENTIFIER = ENV["INJI_IOS_DEVELOPER_APP_IDENTIFIER"] TEAM_ID = ENV["INJI_IOS_DEVELOPER_PORTAL_TEAM_ID"] FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD = ENV["INJI_IOS_FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD"] FASTLANE_USER= ENV["IOS_FASTLANE_APPLE_ID"] @@ -13,12 +12,62 @@ PROVISIONING_PROFILE_SPECIFIER = ENV["INJI_IOS_PROVISIONING_PROFILE_SPECIFIER"] TEMP_KEYCHAIN_USER = ENV["INJI_IOS_TEMP_KEYCHAIN_USER"] TEMP_KEYCHAIN_PASSWORD = ENV["INJI_IOS_TEMP_KEYCHAIN_PASSWORD"] GIT_AUTHORIZATION = ENV["GIT_AUTHORIZATION"] -SLACK_URL = ENV["SLACK_URL"] +SLACK_URL = ENV["SLACK_WEBHOOK_URL"] +APP_FLAVOR = ENV["APP_FLAVOR"] MATCH_PASSWORD = ENV["MATCH_PASSWORD"] FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT = "120" -TESTFLIGHT_INTERNAL_TESTERS_GROUP = ENV["TESTFLIGHT_INTERNAL_TESTERS_GROUP"] +TESTFLIGHT_INTERNAL_TESTERS_GROUP = ENV["TESTFLIGHT_INTERNAL_TESTERS_GROUP"] TESTFLIGHT_BETA_APP_DESCRIPTION = ENV["TESTFLIGHT_BETA_APP_DESCRIPTION"] DEVELOPER_APP_ID = ENV["DEVELOPER_APP_ID"] +MIMOTO_HOST = ENV["MIMOTO_HOST"] +ESIGNET_HOST = ENV["ESIGNET_HOST"] +APPLICATION_THEME = ENV["APPLICATION_THEME"] +CREDENTIAL_REGISTRY_EDIT = ENV["CREDENTIAL_REGISTRY_EDIT"] + +def generate_app_bundle_id() + flavor = APP_FLAVOR + case flavor + when "residentapp" + # the old app flavor + return "io.mosip.inji.mobileid" + when "inji" + # io.mosip.inji is not available in iOS + return "io.mosip.inji.wallet" + when "collab" + return "io.mosip.inji.collab" + when "synergy" + return "io.mosip.inji.synergy" + when "mec" + return "io.mosip.inji.mec" + end +end + +def map_flavour_tosuffix() + flavor = APP_FLAVOR + case flavor + when "residentapp" + return "mobileid" + when "inji" + return "wallet" + end + return flavor +end + +def generate_app_name() + flavor = APP_FLAVOR + case flavor + when "residentapp" + return "Inji" + when "inji" + return "Inji Wallet" + when "collab" + return "Inji Wallet Collab" + when "synergy" + return "Inji Wallet Synergy" + when "mec" + return "Inji Wallet Mec" + end +end def delete_temp_keychain(name) delete_keychain( @@ -42,7 +91,6 @@ end platform :ios do - lane :beta do keychain_name = TEMP_KEYCHAIN_USER keychain_password = TEMP_KEYCHAIN_PASSWORD @@ -60,7 +108,7 @@ platform :ios do version = get_version_number(xcodeproj: "Inji.xcodeproj") previous_build_number = latest_testflight_build_number( - app_identifier: "#{DEVELOPER_APP_IDENTIFIER}", + app_identifier: "#{generate_app_bundle_id}", api_key: api_key, version: version ) @@ -72,9 +120,27 @@ platform :ios do build_number: current_build_number ) + update_app_identifier( + app_identifier: "#{generate_app_bundle_id}", + plist_path: "Inji/Info.plist" + ) + # replace bundle ID + s = "s/mobileid/#{map_flavour_tosuffix}/g" + sh("sed -i '' -e #{s} ios/Inji.xcodeproj/project.pbxproj") + + # replace Product name + p = "s|PRODUCT_NAME = Inji|PRODUCT_NAME = \"#{generate_app_name}\"|" + sh ("sed -i '' -e #{p} ios/Inji.xcodeproj/project.pbxproj") + + # update app display name + update_info_plist( + plist_path: 'Inji/Info.plist', + display_name: "#{generate_app_name}" + ) + match( type: 'appstore', - app_identifier: "#{DEVELOPER_APP_IDENTIFIER}", + app_identifier: "#{generate_app_bundle_id}", git_basic_authorization: Base64.strict_encode64("#{GIT_AUTHORIZATION}"), readonly: false, keychain_name: keychain_name, @@ -83,7 +149,6 @@ platform :ios do ) profile_mapping = Actions.lane_context[SharedValues::MATCH_PROVISIONING_PROFILE_MAPPING] - gym( configuration: "Release", workspace: "Inji.xcworkspace", @@ -91,20 +156,20 @@ platform :ios do export_method: "app-store", export_options: { - provisioningProfiles: { - "#{DEVELOPER_APP_ID}" => "#{PROVISIONING_PROFILE_SPECIFIER}" + provisioningProfiles: { + "#{generate_app_bundle_id}" => "match AppStore #{generate_app_bundle_id}" } } ) pilot( - app_identifier: "#{DEVELOPER_APP_IDENTIFIER}", + app_identifier: "#{generate_app_bundle_id}", api_key: api_key, ipa: "./Inji.ipa", changelog: "#{TESTFLIGHT_BETA_APP_DESCRIPTION}", localized_build_info: { "default": { - whats_new: "#{TESTFLIGHT_BETA_APP_DESCRIPTION}", + whats_new: "#{TESTFLIGHT_BETA_APP_DESCRIPTION}", } }, skip_waiting_for_build_processing: false, @@ -115,51 +180,6 @@ platform :ios do delete_temp_keychain(keychain_name) - slack( - message: "Inji - #{version} (#{current_build_number}) is uploaded to testflight.", - success: true, - slack_url: "#{SLACK_URL}", - default_payloads: [:git_branch, :last_git_commit] - ) - end - - lane :build_verify do - keychain_name = TEMP_KEYCHAIN_USER - keychain_password = TEMP_KEYCHAIN_PASSWORD - ensure_temp_keychain(keychain_name, keychain_password) - - api_key = app_store_connect_api_key( - key_id: "#{APPLE_KEY_ID}", - issuer_id: "#{APPLE_ISSUER_ID}", - key_content: "#{APPLE_KEY_CONTENT}", - duration: 1200, - in_house: false, - is_key_content_base64: true - ) - - match( - type: 'appstore', - app_identifier: "#{DEVELOPER_APP_IDENTIFIER}", - git_basic_authorization: Base64.strict_encode64("#{GIT_AUTHORIZATION}"), - readonly: false, - keychain_name: keychain_name, - keychain_password: keychain_password, - api_key: api_key - ) - - gym( - configuration: "Release", - workspace: "Inji.xcworkspace", - scheme: "Inji", - export_method: "app-store", - ) - - delete_temp_keychain(keychain_name) - - end - - lane :build_app_for_automation_on_simulator do - custom_output_directory = "./Inji_app_file" sh("mkdir -p '#{custom_output_directory}'") @@ -170,8 +190,27 @@ platform :ios do build_path: "./build", ) + find_command = "find '../build/' -type d -name 'Products'" app_path = sh(find_command, log: false).strip sh("cp -R '#{app_path}' '#{custom_output_directory}'") + + slack( + message: "#{generate_app_name} #{version} (#{current_build_number}) is uploaded to testflight.", + success: true, + slack_url: "#{SLACK_URL}", + default_payloads: [:git_branch, :last_git_commit] + ) + + end + + lane :ios_app_build do + + archive_path = gym( + skip_package_ipa: true, + destination: "generic/platform=iOS Simulator", + configuration: "Release", + build_path: "./build", + ) end -end \ No newline at end of file +end