diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000000..2369228816 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +--- +BUNDLE_PATH: "vendor/bundle" diff --git a/.github/workflows/build-deploy-alpha.yml b/.github/workflows/build-deploy-alpha.yml index 754dacc9f8..ba3d5472b9 100644 --- a/.github/workflows/build-deploy-alpha.yml +++ b/.github/workflows/build-deploy-alpha.yml @@ -1,57 +1,118 @@ -name: Alpha - Build and Deploy +name: Alpha - Build and Deploy on: + push: + branches: + - test/IOS-8112_ci_cd_alpha_builds_workflow # TODO: Test only, remove workflow_dispatch: - -env: - APP_PATH: /tmp/app.ipa - ARTIFACT_NAME: Application - + inputs: + xcode_version_override: + description: > + Optional Xcode version override. Leave blank (default value) to use the default Xcode version; + pass a custom value (e.g. '16.0', '10.2.1', '11 Beta 7', '11.2 GM seed', etc) to use a different Xcode version for the build + type: string + +concurrency: + group: '${{ github.workflow }} (${{ github.head_ref || github.ref_name }})' + cancel-in-progress: true + jobs: - build: - name: Build - runs-on: self-hosted - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: true - token: ${{ secrets.GH_MOBILE_PAT }} - - - name: Bundle install - run: bundle install --jobs 4 --retry 3 - - - name: Pods install - run: bundle exec pod install - - - name: TEST - run: echo ${{ github.head_ref }} - - - name: Get Jira Issue Number from Branch Name - id: issue_number - uses: tangem/jira-action@master - with: - action: getBranchId - branch-name: ${{ github.head_ref }} - - - name: TEST - run: echo ${{ steps.issue_number.outputs.result }} - -# - name: Build -# run: bundle exec fastlane build scheme:"Tangem Alpha" version:${{ steps.issue_number.outputs.result }} - -# - name: Upload binary artifact -# uses: actions/upload-artifact@v3 -# with: -# name: $ARTIFACT_NAME -# path: $APP_PATH - -# deploy: -# name: Deploy -# needs: build -# runs-on: self-hosted -# steps: -# - name: Download a single artifact -# uses: actions/download-artifact@v3 -# with: -# name: $ARTIFACT_NAME + prepare: + name: Prepare information + runs-on: self-hosted + outputs: + version: '${{ steps.jira.outputs.key }}' + stage: Alpha + build_number: '${{ github.run_number }}' + changelog: '${{ steps.jira.outputs.summary }}' + steps: + - name: Jira Login + uses: atlassian/gajira-login@master + env: + JIRA_BASE_URL: '${{ secrets.JIRA_URL }}' + JIRA_USER_EMAIL: '${{ secrets.JIRA_USER }}' + JIRA_API_TOKEN: '${{ secrets.JIRA_TOKEN }}' + + - name: Get Jira Issue Number from Branch Name + id: jira + uses: tangem/jira-action@master + with: + action: getBranchSummary + branch-name: '${{ github.ref_name }}' + + - name: Find sec identities test + run: | + echo "concurrency_group: ${{ github.workflow }} (${{ github.head_ref || github.ref_name }})" + echo "find-identity: $(security find-identity -p codesigning -v)" + echo "Provisioning Profiles: $(ls -ltra ~/Library/MobileDevice/Provisioning\ Profiles)" + # mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles\ Backup + # echo "Provisioning Profiles: $(ls -ltra ~/Library/MobileDevice/Provisioning\ Profiles)" + # echo "Provisioning Profiles Backup: $(ls -ltra ~/Library/MobileDevice/Provisioning\ Profiles\ Backup)" + # xcodebuild -allowProvisioningUpdates -workspace 'TangemApp.xcworkspace' -scheme 'Tangem Alpha' + + build: + name: Tangem Alpha + needs: prepare + uses: tangem/actions/.github/workflows/build.yml@main + with: + stage: '${{ needs.prepare.outputs.stage }}' + version: '${{ needs.prepare.outputs.version }}' + build_number: '${{ needs.prepare.outputs.build_number }}' + path: fastlane/builds/ + filename: Tangem-${{ needs.prepare.outputs.stage }}-${{ needs.prepare.outputs.version }}(${{ needs.prepare.outputs.build_number }}).ipa + secrets: + GH_MOBILE_PAT: '${{ secrets.GH_MOBILE_PAT }}' + + deploy: + name: Google Distribution + needs: + - prepare + - build + uses: tangem/actions/.github/workflows/deploy-firebase.yml@main + with: + stage: '${{ needs.prepare.outputs.stage }}' + version: '${{ needs.prepare.outputs.version }}' + build_number: '${{ needs.prepare.outputs.build_number }}' + changelog: '${{ needs.prepare.outputs.changelog }}' + filename: Tangem-${{ needs.prepare.outputs.stage }}-${{ needs.prepare.outputs.version }}(${{ needs.prepare.outputs.build_number }}).ipa + secrets: + FIREBASE_APP_ID: '${{ secrets.FIREBASE_APP_ID }}' + FIREBASE_CLI_TOKEN: '${{ secrets.FIREBASE_CLI_TOKEN }}' + GH_MOBILE_PAT: '${{ secrets.GH_MOBILE_PAT }}' + + notification: + name: Deploy Notification + needs: + - prepare + - deploy + #if: false # TODO: Temp disabled, enable + uses: tangem/actions/.github/workflows/notification.yml@main + with: + channel: '${{ vars.SLACK_CHANNEL_DEPLOYMENTS_IOS }}' + status: success + app_name: '${{ vars.APP_ALPHA }}' + deploy_to: '${{ vars.DEPLOYMENT_GOOGLE_DISTRIBUTION }}' + version: '${{ needs.prepare.outputs.version }}' + build_number: '${{ needs.prepare.outputs.build_number }}' + changelog: '${{ needs.prepare.outputs.changelog }}' + secrets: + SLACK_BOT_TOKEN: '${{ secrets.SLACK_BOT_TOKEN }}' + + error_notification: + name: Error Notification + #if: failure() + if: false # TODO: Temp disabled, enable + needs: + - prepare + - deploy + uses: tangem/actions/.github/workflows/notification.yml@main + with: + channel: '${{ vars.SLACK_CHANNEL_DEPLOYMENTS_IOS }}' + status: error + app_name: '${{ vars.APP_ALPHA }}' + deploy_to: '${{ vars.DEPLOYMENT_GOOGLE_DISTRIBUTION }}' + version: '${{ needs.prepare.outputs.version }}' + build_number: '${{ needs.prepare.outputs.build_number }}' + changelog: '${{ needs.prepare.outputs.changelog }}' + secrets: + SLACK_BOT_TOKEN: '${{ secrets.SLACK_BOT_TOKEN }}' diff --git a/.github/workflows/build-deploy-beta.yml b/.github/workflows/build-deploy-beta.yml index 742629704d..2eedbdac58 100644 --- a/.github/workflows/build-deploy-beta.yml +++ b/.github/workflows/build-deploy-beta.yml @@ -1,12 +1,9 @@ name: Beta - Build and Deploy on: - pull_request: - branches: - - develop - types: - - open - + push: + branches: + - 'develop' workflow_dispatch: jobs: @@ -15,48 +12,111 @@ jobs: runs-on: ubuntu-latest outputs: version: "Develop" + stage: "Beta" build_number: ${{ github.run_number }} - changelog: ${{ steps.jira.outputs.summary }} + changelog: ${{ steps.changelog.outputs.result }} steps: + - name: Get unreleased tasks + id: git-diff + uses: tangem/github-action@main + with: + github-token: ${{ secrets.GH_MOBILE_PAT}} + base: 'master' + head: 'develop' + - name: Jira Login uses: atlassian/gajira-login@master env: - JIRA_BASE_URL: ${{ secrets.JIRA_URL }} - JIRA_USER_EMAIL: ${{ secrets.JIRA_USER }} - JIRA_API_TOKEN: ${{ secrets.JIRA_TOKEN }} - - - name: Get Issues keys from git commits - id: github-issues - uses: tangem/github-action@main + JIRA_BASE_URL: ${{ secrets.JIRA_URL }} + JIRA_USER_EMAIL: ${{ secrets.JIRA_USER }} + JIRA_API_TOKEN: ${{ secrets.JIRA_TOKEN }} + + - name: Jira Get Issues Summary + uses: tangem/jira-action@master + id: changelog with: - github-token: ${{ secrets.GH_MOBILE_PAT}} - pull-number: ${{ github.event.number }} + action: getIssuesSummary + issues: ${{ steps.git-diff.outputs.issues }} - # TEST - - name: Output issues - run: echo ${{ steps.github-issues.outputs.issues }} - ### - - name: Jira Check Version id: jira-check-version uses: tangem/jira-action@master with: action: checkVersion project: IOS - version: NextRelease + version: "Next Release" - name: Jira Create Version - if: ${{ steps.jira-check-version.outputs.result }} == false + if: ${{ steps.jira-check-version.outputs.result == 'false' }} uses: tangem/jira-action@master with: action: createVersion project: IOS - version: NextRelease + version: "Next Release" - name: Jira Set Version To Issues uses: tangem/jira-action@master with: action: setVersionToIssues project: IOS - version: NextRelease - issues: ${{ steps.github-issues.outputs.issues }} + version: "Next Release" + issues: ${{ steps.git-diff.outputs.issues }} + + build: + name: Tangem Beta + needs: prepare + uses: tangem/actions/.github/workflows/build.yml@main + with: + stage: ${{needs.prepare.outputs.stage}} + version: "${{needs.prepare.outputs.version}}" + build_number: ${{needs.prepare.outputs.build_number}} + path: "fastlane/builds/" + filename: "Tangem-${{needs.prepare.outputs.stage}}-${{needs.prepare.outputs.version}}(${{needs.prepare.outputs.build_number}}).ipa" + secrets: + GH_MOBILE_PAT: ${{ secrets.GH_MOBILE_PAT}} + + deploy: + name: Google Distribution + needs: [prepare,build] + uses: tangem/actions/.github/workflows/deploy-firebase.yml@main + with: + stage: ${{needs.prepare.outputs.stage}} + version: "${{needs.prepare.outputs.version}}" + build_number: ${{needs.prepare.outputs.build_number}} + changelog: "${{needs.prepare.outputs.changelog}}" + filename: "Tangem-${{needs.prepare.outputs.stage}}-${{needs.prepare.outputs.version}}(${{needs.prepare.outputs.build_number}}).ipa" + secrets: + FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID}} + FIREBASE_CLI_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN}} + GH_MOBILE_PAT: ${{ secrets.GH_MOBILE_PAT}} + + notification: + name: Deploy Notification + needs: [prepare,deploy] + uses: tangem/actions/.github/workflows/notification.yml@main + with: + channel: ${{vars.SLACK_CHANNEL_DEPLOYMENTS_IOS}} + status: "success" + app_name: ${{vars.APP_BETA}} + deploy_to: ${{vars.DEPLOYMENT_GOOGLE_DISTRIBUTION}} + version: ${{needs.prepare.outputs.version}} + build_number: ${{needs.prepare.outputs.build_number}} + changelog: ${{needs.prepare.outputs.changelog}} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN}} + + error_notification: + name: Error Notification + if: failure() + needs: [prepare,deploy] + uses: tangem/actions/.github/workflows/notification.yml@main + with: + channel: ${{vars.SLACK_CHANNEL_DEPLOYMENTS_IOS}} + status: "error" + app_name: ${{vars.APP_BETA}} + deploy_to: ${{vars.DEPLOYMENT_GOOGLE_DISTRIBUTION}} + version: ${{needs.prepare.outputs.version}} + build_number: ${{needs.prepare.outputs.build_number}} + changelog: ${{needs.prepare.outputs.changelog}} + secrets: + SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN}} diff --git a/.github/workflows/create-release.yml b/.github/workflows/create-release.yml index e0ed1da77f..8da035d7af 100644 --- a/.github/workflows/create-release.yml +++ b/.github/workflows/create-release.yml @@ -16,10 +16,10 @@ on: jobs: prepare: name: Prepare Release - uses: tangem/actions/.github/workflows/build.yml@main + uses: tangem/actions/.github/workflows/prepare-release.yml@main with: versionName: ${{ github.event.inputs.versionName }} - versionType: ${{ github.event.inputs.versionType }} + releaseType: ${{ github.event.inputs.versionType }}s secrets: GH_MOBILE_PAT: ${{ secrets.GH_MOBILE_PAT}} JIRA_BASE_URL: ${{ secrets.JIRA_URL }} @@ -32,7 +32,7 @@ jobs: uses: tangem/actions/.github/workflows/build.yml@main with: stage: ${{needs.prepare.outputs.stage}} - version: "${{ github.event.inputs.name }}" + version: "RC" build_number: ${{needs.prepare.outputs.build_number}} path: "fastlane/builds/" filename: "Tangem-${{needs.prepare.outputs.stage}}-${{needs.prepare.outputs.version}}(${{needs.prepare.outputs.build_number}}).ipa" @@ -44,14 +44,16 @@ jobs: needs: [prepare,build] uses: tangem/actions/.github/workflows/deploy-testflight.yml@main with: - stage: ${{needs.prepare.outputs.stage}} - version: "${{needs.prepare.outputs.version}}" - build_number: ${{needs.prepare.outputs.build_number}} - changelog: "${{needs.prepare.outputs.changelog}}" - filename: "Tangem-${{needs.prepare.outputs.stage}}-${{needs.prepare.outputs.version}}(${{needs.prepare.outputs.build_number}}).ipa" + stage: "RC" + version: ${{ github.event.inputs.versionName }} + build_number: ${{ github.run_number }} + changelog: "" + filename: "Tangem-RC-${{ github.event.inputs.versionName }}(${{ github.run_number }}).ipa" secrets: - FIREBASE_APP_ID: ${{ secrets.FIREBASE_IOS_ALPHA_ID}} - FIREBASE_CLI_TOKEN: ${{ secrets.FIREBASE_CLI_TOKEN}} + ASC_KEY_ID: ${{ secrets.ASC_KEY_ID}} + ASC_PRIVATE_KEY: ${{ secrets.ASC_PRIVATE_KEY}} + ASC_ISSUER_ID: ${{ secrets.ASC_ISSUER_ID}} + GH_MOBILE_PAT: ${{ secrets.GH_MOBILE_PAT}} notification: name: Deploy Notification diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 03bf19b275..5888b7808a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,8 @@ jobs: test: name: Test runs-on: macos-14 - if: github.event.pull_request.draft == false + if: false # TODO: Temp disabled, remove + #if: github.event.pull_request.draft == false steps: - name: Checkout uses: actions/checkout@v3 @@ -43,8 +44,9 @@ jobs: check_bsdk_example_buildable: name: Check BSDK example project - runs-on: macos-14 - if: false # TODO: Andrey Fedorov - Requires code signing, enable after migration to self-hosted runners (IOS-8112) + runs-on: self-hosted + if: true # TODO: Temp enabled, remove + #if: github.event.pull_request.draft == false steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.gitignore b/.gitignore index abda627387..45b19581f3 100644 --- a/.gitignore +++ b/.gitignore @@ -72,3 +72,6 @@ fastlane/report.xml # Generated Tangem/Resources/Generated/Localizable+Generated.swift Tangem/Resources/Generated/XCAssets+Generated.swift + +# Rubygems +vendor/bundle diff --git a/fastlane/Appfile b/fastlane/Appfile index 8ebd93d732..460f79e3af 100644 --- a/fastlane/Appfile +++ b/fastlane/Appfile @@ -1,17 +1,17 @@ itc_team_id "118990352" -for_lane :alpha do +for_lane :build_Alpha do app_identifier 'com.tangem.TangemAlpha' end -for_lane :beta do +for_lane :build_Beta do app_identifier 'com.tangem.TangemBeta' end -for_lane :release do +for_lane :build_RC do app_identifier 'com.tangem.Tangem' end for_lane :refresh_dsyms do app_identifier 'com.tangem.Tangem' -end \ No newline at end of file +end diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 23f22902c6..4eb972bd20 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -40,7 +40,7 @@ desc """ Options: - xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) """ -lane :test do |options| +lane :test do run_tests( workspace: WORKSPACE_NAME, scheme: PRODUCTION_SCHEME, @@ -50,36 +50,9 @@ lane :test do |options| end desc """ - A lane that builds a \"Tangem\" scheme and uploads the archive to TestFlight for release. - Using enviroment: Production + A lane that builds a \"BlockchainSdkExample\" scheme without running or publishing it, just to check that the scheme is buildable. Options: - - version: app version - - build: optional build number - - changelog: string for description archive - xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) - """ -lane :release do |options| - app_store_connect_api_key(duration: 1200, is_key_content_base64: true) - increment_version_number(version_number: options[:version]) - increment_testflight_build_number(version: options[:version], build: options[:build]) - - build(scheme: PRODUCTION_SCHEME, version: options[:version]) - upload_dsyms(app_id: ENV["APP_ID_PRODUCTION"], name: PRODUCTION_SCHEME) - - upload_testflight( - name: PRODUCTION_SCHEME, - version: options[:version], - changelog: options[:changelog] - ) - clean_artifacts - slack_message( - message: "Tangem Release successfully uploaded to TestFlight", - changelog: options[:changelog] - ) -end - -desc """ -A lane that builds a \"BlockchainSdkExample\" scheme without running or publishing it, just to check that the scheme is buildable. """ lane :check_bsdk_example_buildable do |options| xcodebuild( @@ -92,111 +65,89 @@ lane :check_bsdk_example_buildable do |options| end desc """ -A lane that builds a \"Tangem Beta\" scheme and uploads the archive to Firebase for testing. -Using enviroment: Production -Options: -- version: app version -- build: optional build number -- changelog: string for description archive -- xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) + This lane builds a \"Tangem Alpha\" scheme binary. Result binary can be used only for ad-hoc distribution. + Options: + - version: App version + - build: Build number + - filename: Name of the resulting artefact (IPA file) + - path: Path to binary + - xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) """ -lane :beta do |options| +lane :build_Alpha do |options| increment_version_number(version_number: options[:version]) increment_firebase_build_number(app_id: ENV["APP_ID_BETA"], build: options[:build]) - build(scheme: BETA_SCHEME, export_method: "ad-hoc") - upload_dsyms(app_id: ENV["APP_ID_BETA"], name: BETA_SCHEME) - upload_firebase( - name: BETA_SCHEME, - app_id: ENV["APP_ID_BETA"], - changelog: options[:changelog] - ) - clean_artifacts - slack_message( - message: "Tangem Beta successfully uploaded to Firebase", - changelog: options[:changelog] + build( + export_method: "ad-hoc", + scheme: ALPHA_SCHEME, + version: options[:version], + build: options[:build], + filename: options[:filename], + path: options[:path] ) end desc """ -A lane that builds a \"Tangem Alpha\" scheme and uploads the archive to Firebase for testing. -Using enviroment: Test -Options: -- version: app version -- build: optional build number -- changelog: string for description archive -- xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) + A lane that builds a \"Tangem Beta\" scheme binary. Result binary can be used only for ad-hoc distribution. + Options: + - version: App version + - build: Build number + - filename: Name of the resulting artefact (IPA file) + - path: Path to binary + - xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) """ -lane :alpha do |options| +lane :build_Beta do |options| increment_version_number(version_number: options[:version]) - increment_firebase_build_number(app_id: ENV["APP_ID_ALPHA"], build: options[:build]) - build(scheme: ALPHA_SCHEME, export_method: "ad-hoc") + increment_firebase_build_number(app_id: ENV["APP_ID_BETA"], build: options[:build]) - upload_dsyms(app_id: ENV["APP_ID_ALPHA"], name: ALPHA_SCHEME) - upload_firebase( - name: ALPHA_SCHEME, - app_id: ENV["APP_ID_ALPHA"], - changelog: options[:changelog] - ) - clean_artifacts - slack_message( - message: "Tangem Aplha successfully uploaded to Firebase", - changelog: options[:changelog] + build( + export_method: "ad-hoc", + scheme: BETA_SCHEME, + version: options[:version], + build: options[:build], + filename: options[:filename], + path: options[:path] ) end +# TODO: changelog isn't used at all? desc """ -Load from testFlight dSyms and upload it to Firebase -Options: -- version: app version -- build: build number -""" -lane :refresh_dsyms do |options| - app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) - app_store_connect_api_key(duration: 1200, is_key_content_base64: true) - download_dsyms( - app_identifier: app_identifier, - version: options[:version], - build_number: options[:build] - ) - upload_symbols_to_crashlytics(app_id: ENV["PRODUCTION_SCHEME"]) - clean_build_artifacts -end - -desc """ -Fetches and updates localization bundles using Localise fastlane action (https://github.com/lokalise/lokalise-fastlane-actions). -Uses `LOKALISE_API_TOKEN` and `LOKALISE_PROJECT_ID` env vars. -Options: -- languages: A comma-delimited string of languages to update, like `en,fr,de,ja,ru,es,uk_UA`. Pass an empty string to update all available languages. -- destination: A file path to save localization files to. -""" -lane :update_translations do |options| - # Can't pass an array as a param for a lane, see https://github.com/fastlane-community/fastlane-plugin-appicon/issues/41 for details - languages = options[:languages]&.split(",") - - destination = options[:destination] - UI.user_error!("Invalid destination path '#{destination}' for localization files") unless (destination and not destination.empty?) + A lane that builds a \"Tangem\" scheme and uploads the archive to TestFlight for release. + Using enviroment: Production + Options: + - version: app version + - build: optional build number + - changelog: string for description archive + - filename: Name of the resulting artefact (IPA file) + - path: Path to binary + - xcode_version_override: Xcode version to use, optional (uses https://github.com/XcodesOrg/xcodes under the hood) + """ +lane :build_RC do |options| + increment_version_number(version_number: options[:version]) + increment_testflight_build_number(version: options[:version], build: options[:build]) - lokalise( - destination: destination, - replace_breaks: true, - use_original: true, - languages: languages, - export_sort: "a_z", - export_empty_as: "base" + build( + scheme: PRODUCTION_SCHEME, + version: options[:version], + filename: options[:filename], + path: options[:path] ) end private_lane :build do |options| + clean_artifacts + app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) + build_app( xcargs: "-allowProvisioningUpdates", - output_directory: BUILD_PATH, - output_name: options[:scheme], + output_directory: options[:path], + output_name: options[:filename], scheme: options[:scheme], clean: true, silent: false, export_method: options[:export_method], + destination: "generic/platform=iOS", export_options: { distributionBundleIdentifier: app_identifier, iCloudContainerEnvironment: "Production" @@ -204,6 +155,57 @@ private_lane :build do |options| ) end +desc """ + This lane deploy binary to Google Distribution + Options: + - app_id: Firebase App ID + - path: Path to binary + - firebase_token: Firebase CLI Token + - changelog: [optional] Changelog will be added to Google Distribution release notes along with the last commit hash. +""" +lane :deploy_firebase do |options| + path = options[:path] + release_notes = "#{options[:changelog]}\nGitHash: #{last_git_commit[:commit_hash]}" + firebase_app_distribution( + app: options[:app_id], + ipa_path: path, + groups: FIREBASE_TESTERS_GROUP, + firebase_cli_token: options[:firebase_token], + release_notes: release_notes + ) +end + +desc """ + This lane deploy binary to TestFLight + Options: + - version: app version + - build: optional build number + - binary_path: Path to binary + - asc_key_id: TBD + - asc_issuer_id: TBD + - asc_key: TBD + - changelog: [optional] Changelog will be added to TestFlight release notes along with the last commit hash. +""" +lane :deploy_testflight do |options| + # Get AppStore API Key + api_key = app_store_connect_api_key( + key_id: options[:asc_key_id], + issuer_id: options[:asc_issuer_id], + key_content: options[:asc_key], + is_key_content_base64: true, + in_house: false # detecting this via ASC private key not currently supported + ) + + # Upload binary to TestFlight + upload_to_testflight( + api_key:api_key, + skip_waiting_for_build_processing: true, + ipa: options[:binary_path], + app_version: options[:version], + changelog: options[:changelog] + ) +end + private_lane :increment_firebase_build_number do |options| if options[:build].nil? latest_release = firebase_app_distribution_get_latest_release( @@ -231,68 +233,54 @@ private_lane :increment_testflight_build_number do |options| end end -private_lane :upload_dsyms do |options| - filename = options[:name] + ".app.dSYM.zip" - path = BUILD_PATH + filename - upload_symbols_to_crashlytics( - app_id: options[:app_id], - dsym_path: path - ) -end +desc """ + Fetches and updates localization bundles using Localise fastlane action (https://github.com/lokalise/lokalise-fastlane-actions). + Uses `LOKALISE_API_TOKEN` and `LOKALISE_PROJECT_ID` env vars. + Options: + - languages: A comma-delimited string of languages to update, like `en,fr,de,ja,ru,es,uk_UA`. Pass an empty string to update all available languages. + - destination: A file path to save localization files to. +""" +lane :update_translations do |options| + # Can't pass an array as a param for a lane, see https://github.com/fastlane-community/fastlane-plugin-appicon/issues/41 for details + languages = options[:languages]&.split(",") -private_lane :upload_firebase do |options| - filename = options[:name] + ".ipa" - path = BUILD_PATH + filename - release_notes = "#{options[:changelog]}\nGitHash: #{last_git_commit[:commit_hash]}" + destination = options[:destination] + UI.user_error!("Invalid destination path '#{destination}' for localization files") unless (destination and not destination.empty?) - firebase_app_distribution( - app: options[:app_id], - ipa_path: path, - groups: FIREBASE_TESTERS_GROUP, - firebase_cli_token: ENV["FIREBASE_CREDITIONAL_KEY"], - release_notes: release_notes + lokalise( + destination: destination, + replace_breaks: true, + use_original: true, + languages: languages, + export_sort: "a_z", + export_empty_as: "base" ) end -private_lane :upload_testflight do |options| - filename = options[:name] + ".ipa" - path = BUILD_PATH + filename - release_notes = "#{options[:changelog]}\nGitHash: #{last_git_commit[:commit_hash]}" - - upload_to_testflight( - skip_waiting_for_build_processing: true, - ipa: path, - app_version: options[:version], - changelog: release_notes +desc """ + Load from testFlight dSyms and upload it to Firebase + Options: + - version: app version + - build: build number +""" +lane :refresh_dsyms do |options| + app_identifier = CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier) + app_store_connect_api_key(duration: 1200, is_key_content_base64: true) + download_dsyms( + app_identifier: app_identifier, + version: options[:version], + build_number: options[:build] ) + upload_symbols_to_crashlytics(app_id: ENV["PRODUCTION_SCHEME"]) + clean_build_artifacts end -private_lane :slack_message do |options| - slack( - message: options[:message] + " @qa", - default_payloads: [:git_branch, :last_git_commit], - slack_url: ENV["SLACK_WEBHOOK_URL"], - attachment_properties: { - fields: [ - { - title: "Git Hash", - value: last_git_commit[:commit_hash], - }, - { - title: "Version", - value: get_version_number(xcodeproj: "TangemApp.xcodeproj", target: "Tangem"), - }, - { - title: "Build number", - value: get_build_number(xcodeproj: "TangemApp.xcodeproj"), - }, - { - title: "Changelog", - value: options[:changelog], - } - ] - }, - link_names: true +private_lane :upload_dsyms do |options| + filename = options[:name] + ".app.dSYM.zip" + path = BUILD_PATH + filename + upload_symbols_to_crashlytics( + app_id: options[:app_id], + dsym_path: path ) end