---
format_version: '11'
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
project_type: flutter
trigger_map:
- push_branch: master
  workflow: primary
- pull_request_source_branch: "*"
  workflow: primary
  pull_request_target_branch: master
workflows:
  deploy:
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@4: {}
    - script@1:
        title: Do anything with Script step
    - certificate-and-profile-installer@1: {}
    - flutter-installer@0:
        inputs:
        - is_update: 'false'
    - cache-pull@2: {}
    - flutter-analyze@0:
        inputs:
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION"
    - flutter-test@0:
        inputs:
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION"
    - flutter-build@0:
        inputs:
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION"
        - platform: both
    - xcode-archive@2:
        inputs:
        - project_path: "$BITRISE_PROJECT_PATH"
        - scheme: "$BITRISE_SCHEME"
        - export_method: "$BITRISE_EXPORT_METHOD"
        - configuration: Release
    - deploy-to-bitrise-io@1: {}
    - cache-push@2: {}
    meta:
      bitrise.io:
        stack: osx-xcode-13.1.x
  primary:
    steps:
    - activate-ssh-key@4:
        run_if: '{{getenv "SSH_RSA_PRIVATE_KEY" | ne ""}}'
    - git-clone@6: {}
    - flutter-installer@0:
        inputs:
        - installation_bundle_url: https://storage.googleapis.com/flutter_infra_release/releases/stable/macos/flutter_macos_3.0.1-stable.zip
        - is_update: 'false'
    - script@1:
        title: Do anything with Script step
        inputs:
        - content: |-
            #!/usr/bin/env bash
            # fail if any commands fails
            set -e
            # debug log
            set -x

            cd core
            flutter pub get

            # Install necessary pods
            cd ../ios
            flutter pub get && pod install

            cd ../model
            flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs

            cd ../contact
            flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs

            cd ..
            flutter pub get && flutter pub run build_runner build --delete-conflicting-outputs

            flutter pub get && flutter pub run intl_generator:extract_to_arb --output-dir=./lib/l10n lib/main/localizations/app_localizations.dart

            flutter pub get && flutter pub run intl_generator:generate_from_arb --output-dir=lib/l10n --no-use-deferred-loading lib/main/localizations/app_localizations.dart lib/l10n/intl*.arb

            # Workaround solution for issue: https://github.com/bitrise-steplib/bitrise-step-flutter-test/issues/34
            dart pub global activate junitreport
        is_always_run: true
    - flutter-analyze@0:
        inputs:
        - additional_params: ''
        - project_location: "$BITRISE_FLUTTER_PROJECT_LOCATION/core"
    - flutter-test@1:
        inputs:
        - additional_params: "--verbose"
    - flutter-test@1:
        inputs:
        - additional_params: core
    - flutter-test@1:
        inputs:
        - additional_params: model
    - flutter-test@1:
        inputs:
        - additional_params: contact
    - certificate-and-profile-installer@1:
        is_always_run: true
    - set-xcode-build-number@1:
        inputs:
        - build_version_offset: alpha$BITRISE_BUILD_NUMBER
        - build_short_version_string: 0.3.7
        - plist_path: "$BITRISE_FLUTTER_PROJECT_LOCATION/ios/Runner/Info.plist"
    - flutter-build@0:
        inputs:
        - is_debug_mode: 'true'
        - ios_additional_params: "--release"
        - additional_build_params: "--dart-define=SERVER_URL=$SERVER_URL"
        - ios_codesign_identity: 'iPhone Developer: Tung Tran (B8V9X882MX)'
    - sign-apk@1: {}
    - xcode-archive@3:
        inputs:
        - team_id: KUT463DS29
        - force_team_id: KUT463DS29
        - force_code_sign_identity: 'iPhone Developer: Tung Tran (B8V9X882MX)'
        - force_provisioning_profile: 431f914f-5662-422a-8fc1-263b41e1bb4b
        - force_provisioning_profile_specifier: ''
        - export_method: development
    - deploy-to-bitrise-io@2: {}
    - slack@3:
        inputs:
        - channel: 'channel: #ft-mobile '
        - text: |
            Commit Author: ${GIT_CLONE_COMMIT_AUTHOR_NAME}
            Message: ${GIT_CLONE_COMMIT_MESSAGE_SUBJECT}
            App: ${BITRISE_APP_TITLE}
            Branch: ${BITRISE_GIT_BRANCH}
            Workflow: ${BITRISE_TRIGGERED_WORKFLOW_ID}
            View App: ${BITRISE_APP_URL}
            View Build: ${BITRISE_BUILD_URL}
            Install Page: ${BITRISE_PUBLIC_INSTALL_PAGE_URL}
            Status: ${BITRISE_BUILD_STATUS}
        - emoji: ":sunny:"
        - from_username: mobile_bot
        - from_username_on_error: mobile_bot
        - channel_on_error: 'channel: #ft-mobile'
        - footer: Linagora Mobile Team
        - text_on_error: |-
            Commit Author: ${GIT_CLONE_COMMIT_AUTHOR_NAME}
            Message: ${GIT_CLONE_COMMIT_MESSAGE_SUBJECT}
            App: ${BITRISE_APP_TITLE}
            Branch: ${BITRISE_GIT_BRANCH}
            Workflow: ${BITRISE_TRIGGERED_WORKFLOW_ID}
            View App: ${BITRISE_APP_URL}
            View Build: ${BITRISE_BUILD_URL}
            Install Page: ${BITRISE_PUBLIC_INSTALL_PAGE_URL}
            Status: ${BITRISE_BUILD_STATUS}
        - emoji_on_error: ":rain_cloud:"
        - icon_url: ''
        - footer_icon: ''
        - icon_url_on_error: ''
        - webhook_url: "$TWAKE_WEBHOOK_API"
    meta:
      bitrise.io:
        stack: osx-xcode-13.1.x
app:
  envs:
  - opts:
      is_expand: false
    BITRISE_FLUTTER_PROJECT_LOCATION: "."
  - opts:
      is_expand: false
    BITRISE_PROJECT_PATH: ios/Runner.xcworkspace
  - opts:
      is_expand: false
    BITRISE_SCHEME: Runner
  - opts:
      is_expand: false
    BITRISE_EXPORT_METHOD: development
meta:
  bitrise.io:
    stack: osx-xcode-13.1.x
