From 37926631d4bc1a3a0b2dd695f3c6203ee6f59f47 Mon Sep 17 00:00:00 2001 From: Ricki Bin Yamin Date: Sun, 19 Nov 2023 05:19:03 +0700 Subject: [PATCH] Add Workflow Build TestFlight --- .github/workflows/build_testflight.yml | 57 ++++++++++++++++++++++++++ .github/workflows/prepare_profiles.yml | 25 ----------- Configuration/AdHoc.xcconfig | 1 + Configuration/Development.xcconfig | 1 + Configuration/Release.xcconfig | 1 + Fastlane/Appfile | 6 +++ Fastlane/Fastfile | 41 ++++++++++++++++-- Scandocs/Supporting Files/Info.plist | 8 ++++ Tooling/change_build_number.sh | 11 +++++ project.yml | 1 + 10 files changed, 124 insertions(+), 28 deletions(-) create mode 100644 .github/workflows/build_testflight.yml delete mode 100644 .github/workflows/prepare_profiles.yml create mode 100644 Fastlane/Appfile create mode 100755 Tooling/change_build_number.sh diff --git a/.github/workflows/build_testflight.yml b/.github/workflows/build_testflight.yml new file mode 100644 index 0000000..1f29ef6 --- /dev/null +++ b/.github/workflows/build_testflight.yml @@ -0,0 +1,57 @@ +# This workflow will build a Swift project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift + +name: Build TestFlight + +on: + workflow_dispatch: + +jobs: + prepare_provisioning_profiles: + name: Build TestFlight + runs-on: macos-latest + + steps: + - name: Xcode Select Version + uses: maxim-lobanov/setup-xcode@v1 + with: + xcode-version: '14.1' + + - name: Checkout Branch + uses: actions/checkout@v2 + + - name: Install Bundle Dependency + run: | + bundle install + + - name: Install XcodeGen + run: | + brew install xcodegen + + - name: Setup CI Keychain + env: + MATCH_KEYCHAIN: ${{ vars.MATCH_KEYCHAIN }} + MATCH_PASSWORD: ${{ vars.MATCH_PASSWORD }} + run: | + bundle exec fastlane setupCIKeychain + + - name: Change Build Number + run: | + ./Tooling/change_build_number.sh ${{ github.run_number }} + + - name: Setup Project + run: | + ./setup.sh + + - name: Build IPA and Upload to TestFlight using Fastlane + env: + APP_STORE_CONNECT_API_KEY_IN_HOUSE: ${{ vars.APP_STORE_CONNECT_API_KEY_IN_HOUSE }} + APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ vars.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} + APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64: ${{ vars.APP_STORE_CONNECT_API_KEY_IS_KEY_CONTENT_BASE64 }} + APP_STORE_CONNECT_API_KEY_KEY: ${{ vars.APP_STORE_CONNECT_API_KEY_KEY }} + APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ vars.APP_STORE_CONNECT_API_KEY_KEY_ID }} + MATCH_GIT_BASIC_AUTHORIZATION: ${{ vars.MATCH_GIT_BASIC_AUTHORIZATION }} + MATCH_KEYCHAIN: ${{ vars.MATCH_KEYCHAIN }} + MATCH_PASSWORD: ${{ vars.MATCH_PASSWORD }} + run: | + bundle exec fastlane build_testflight \ No newline at end of file diff --git a/.github/workflows/prepare_profiles.yml b/.github/workflows/prepare_profiles.yml deleted file mode 100644 index 4a0c2e0..0000000 --- a/.github/workflows/prepare_profiles.yml +++ /dev/null @@ -1,25 +0,0 @@ -# This workflow will build a Swift project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift - -name: Prepare Provisioning Profiles - -on: - workflow_dispatch: - -jobs: - prepare_provisioning_profiles: - name: Prepare Provisioning Profiles - runs-on: macos-latest - - steps: - - name: Checkout Branch - uses: actions/checkout@v2 - - - name: Install Bundle Dependency - run: | - bundle install - - - name: Run Match - run: | - bundle exec fastlane prepare - \ No newline at end of file diff --git a/Configuration/AdHoc.xcconfig b/Configuration/AdHoc.xcconfig index 8dd5a85..9cc3c7b 100644 --- a/Configuration/AdHoc.xcconfig +++ b/Configuration/AdHoc.xcconfig @@ -11,6 +11,7 @@ APP_NAME = Scandocs (AdHoc) BUNDLE_ID = com.scandocs.ios APP_PROVISIONING_PROFILE = match AdHoc com.scandocs.ios +CODE_SIGN_IDENTITY = Apple Distribution: Ricki Bin Yamin (6NMANHT3A2) VALIDATE_PRODUCT = NO DEBUG_INFORMATION_FORMAT = dwarf-with-dsym TARGETED_DEVICE_FAMILY = 1 diff --git a/Configuration/Development.xcconfig b/Configuration/Development.xcconfig index fcddbd3..4e086a0 100644 --- a/Configuration/Development.xcconfig +++ b/Configuration/Development.xcconfig @@ -11,6 +11,7 @@ APP_NAME = Scandocs (Development) BUNDLE_ID = com.scandocs.ios APP_PROVISIONING_PROFILE = match Development com.scandocs.ios +CODE_SIGN_IDENTITY = Apple Development: Ricki Bin Yamin (BWBZZ27H86) VALIDATE_PRODUCT = NO DEBUG_INFORMATION_FORMAT = dwarf TARGETED_DEVICE_FAMILY = 1 diff --git a/Configuration/Release.xcconfig b/Configuration/Release.xcconfig index e8ddd05..dab673d 100644 --- a/Configuration/Release.xcconfig +++ b/Configuration/Release.xcconfig @@ -11,6 +11,7 @@ APP_NAME = Scandocs BUNDLE_ID = com.scandocs.ios APP_PROVISIONING_PROFILE = match AppStore com.scandocs.ios +CODE_SIGN_IDENTITY = Apple Distribution: Ricki Bin Yamin (6NMANHT3A2) VALIDATE_PRODUCT = YES DEBUG_INFORMATION_FORMAT = dwarf-with-dsym TARGETED_DEVICE_FAMILY = 1 diff --git a/Fastlane/Appfile b/Fastlane/Appfile new file mode 100644 index 0000000..6cac0de --- /dev/null +++ b/Fastlane/Appfile @@ -0,0 +1,6 @@ +app_identifier("com.scandocs.ios") # The bundle identifier of your app +apple_id("ricki.bin.yamin@gmail.com") # Your Apple Developer Portal username + + +# For more information about the Appfile, see: +# https://docs.fastlane.tools/advanced/#appfile \ No newline at end of file diff --git a/Fastlane/Fastfile b/Fastlane/Fastfile index 40e7062..b0b9724 100644 --- a/Fastlane/Fastfile +++ b/Fastlane/Fastfile @@ -16,28 +16,63 @@ default_platform(:ios) platform :ios do + + desc "Setup CI Keychain to prevent stack due to default keychain locked" + lane :setupCIKeychain do + create_keychain( + name: ENV["MATCH_KEYCHAIN"], + password: ENV["MATCH_PASSWORD"], + default_keychain: true, + unlock: true, + timeout: 3600, + add_to_search_list: true, + verbose: true + ) + end desc "Preparing Certificate and Provisioning Profiles on New Device Setup" lane :prepare do match( - git_basic_authorization: ENV["MATCH_GIT_BASIC_AUTHORIZATION"], app_identifier: "com.scandocs.ios", type: "development", readonly: true ) match( - git_basic_authorization: ENV["MATCH_GIT_BASIC_AUTHORIZATION"], app_identifier: "com.scandocs.ios", type: "adhoc", readonly: true ) match( - git_basic_authorization: ENV["MATCH_GIT_BASIC_AUTHORIZATION"], app_identifier: "com.scandocs.ios", type: "appstore", readonly: true ) end + + desc "Build TestFlight" + lane :build_testflight do + match( + keychain_name: ENV["MATCH_KEYCHAIN"] || "login.keychain" , + keychain_password: ENV["MATCH_PASSWORD"] || "", + app_identifier: "com.scandocs.ios", + type: "appstore", + readonly: true + ) + + build_app( + workspace: "Scandocs.xcworkspace", + scheme: "Scandocs", + configuration: "Release", + export_method: "app-store" + ) + + app_store_connect_api_key + + upload_to_testflight( + skip_waiting_for_build_processing: true, + skip_submission: true + ) + end end diff --git a/Scandocs/Supporting Files/Info.plist b/Scandocs/Supporting Files/Info.plist index f628db4..b9492be 100644 --- a/Scandocs/Supporting Files/Info.plist +++ b/Scandocs/Supporting Files/Info.plist @@ -10,6 +10,12 @@ $(VERSION_NAME) CFBundleVersion $(BUILD_NUMBER) + CFBundlePackageType + APPL + CFBundleDisplayName + $(APP_NAME) + CFBundleName + $(APP_NAME) UIApplicationSceneManifest UIApplicationSupportsMultipleScenes @@ -41,5 +47,7 @@ The app needs access to save scanned documents in your photo library NSCameraUsageDescription The app needs access your camera to capture the document that will be scanned + ITSAppUsesNonExemptEncryption + diff --git a/Tooling/change_build_number.sh b/Tooling/change_build_number.sh new file mode 100755 index 0000000..ae1e88d --- /dev/null +++ b/Tooling/change_build_number.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +# Input Param +new_build_number="$1" + +# Change BUILD_NUMBER in .xcconfig files +echo -e "\033[0;33mChange BUILD_NUMBER in all .xcconfig files into $new_build_number...\033[0m" +xcconfig_path="Configuration" + +find "$xcconfig_path" -type f -name "*.xcconfig" -exec sed -i '' -e "s/BUILD_NUMBER = .*/BUILD_NUMBER = $new_build_number/" {} \; +echo -e "\033[0;32m✅ Successfully update BUILD_NUMBER to $new_build_number in all .xcconfig files\033[0m" \ No newline at end of file diff --git a/project.yml b/project.yml index 328419a..3d9faff 100644 --- a/project.yml +++ b/project.yml @@ -11,6 +11,7 @@ settings: BUILD_NUMBER: $(BUILD_NUMBER) VERSION_NAME: $(VERSION_NAME) PROVISIONING_PROFILE_SPECIFIER: $(APP_PROVISIONING_PROFILE) + CODE_SIGN_IDENTITY: $(CODE_SIGN_IDENTITY) targets: Scandocs: