diff --git a/.github/actions/install-and-build-sdk/action.yml b/.github/actions/install-and-build-sdk/action.yml index 726232c302..5ba82e4bc2 100644 --- a/.github/actions/install-and-build-sdk/action.yml +++ b/.github/actions/install-and-build-sdk/action.yml @@ -22,7 +22,6 @@ runs: yarn shell: bash - name: Install & Build the Sample App - run: | - cd examples/SampleApp/ - yarn + working-directory: examples/SampleApp + run: yarn shell: bash diff --git a/.github/actions/ruby-cache/action.yml b/.github/actions/ruby-cache/action.yml new file mode 100644 index 0000000000..68360bfca9 --- /dev/null +++ b/.github/actions/ruby-cache/action.yml @@ -0,0 +1,10 @@ +name: 'Ruby Cache' +description: 'Cache Ruby dependencies' +runs: + using: "composite" + steps: + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1 + bundler-cache: true + working-directory: examples/SampleApp diff --git a/.github/workflows/legacy-sample-distribution.yml b/.github/workflows/legacy-sample-distribution.yml deleted file mode 100644 index 5016e82632..0000000000 --- a/.github/workflows/legacy-sample-distribution.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: legacy-sample-distribution - -on: - push: - branches: - - v4.0.0 -jobs: - build_and_deploy_ios_firebase: - runs-on: [macos-latest] - steps: - - uses: actions/checkout@v2 - - name: Install RubyGems - run: | - cd examples/SampleApp/ios - bundle update --bundler - - name: Install firebase-tools - run: npm install -g firebase-tools - - name: RN setup - run: | - cd package - yarn; - cd native-package - yarn; - cd ../../examples/SampleApp - yarn; - cd ios - pod install - - name: Build and release Firebase - env: - MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} - MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }} - FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} - run: | - cd examples/SampleApp/ios - bundle exec fastlane deploy_to_firebase - - build_and_deploy_android_firebase: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: RN setup - run: | - yarn add global react-native-cli; - cd package - yarn; - cd native-package - yarn; - cd ../../examples/SampleApp - yarn; - - name: Build - run: | - cd examples/SampleApp - mkdir android/app/src/main/assets - mkdir tmp - yarn react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest tmp - cd android - rm -rf $HOME/.gradle/caches/ && ./gradlew assembleRelease - - name: Deploy - uses: wzieba/Firebase-Distribution-Github-Action@v1.2.1 - with: - appId: ${{secrets.ANDROID_FIREBASE_APP_ID}} - token: ${{secrets.FIREBASE_TOKEN}} - groups: android-react-native-testers - file: examples/SampleApp/android/app/build/outputs/apk/release/app-release.apk diff --git a/.github/workflows/sample-distribution.yml b/.github/workflows/sample-distribution.yml index 03ac0f0ead..740f9a0562 100644 --- a/.github/workflows/sample-distribution.yml +++ b/.github/workflows/sample-distribution.yml @@ -16,14 +16,12 @@ jobs: name: Build SampleApp iOS and Deploy-${{ github.ref == 'refs/heads/develop' }} runs-on: [macos-14] steps: - - uses: actions/checkout@v2 - with: - token: ${{ secrets.DOCUSAURUS_GH_TOKEN }} - - name: Install Ruby and Gems - uses: ruby/setup-ruby@v1 + - name: Connect Bot + uses: webfactory/ssh-agent@v0.7.0 with: - working-directory: examples/SampleApp - bundler-cache: true + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} + - uses: actions/checkout@v2 + - uses: ./.github/actions/ruby-cache - name: Install && Build - SDK and Sample App uses: ./.github/actions/install-and-build-sdk - name: Cache iOS pods @@ -34,24 +32,15 @@ jobs: restore-keys: | ${{ runner.os }}-pods- - name: iOS Pods setup - uses: nick-invision/retry@v2 - with: - timeout_minutes: 30 - max_attempts: 3 - command: | - cd examples/SampleApp - cd ios - bundle exec pod install + working-directory: examples/SampleApp/ios + run: bundle exec pod install - name: Build and release Testflight QA + working-directory: examples/SampleApp + run: bundle exec fastlane deploy_to_testflight_qa deploy:${{ github.ref == 'refs/heads/develop' }}; env: MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} MATCH_GIT_BASIC_AUTHORIZATION: ${{ secrets.MATCH_GIT_BASIC_AUTHORIZATION }} - APP_STORE_CONNECT_API_KEY_KEY_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY_ID }} - APP_STORE_CONNECT_API_KEY_ISSUER_ID: ${{ secrets.APP_STORE_CONNECT_API_KEY_ISSUER_ID }} - APP_STORE_CONNECT_API_KEY_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY_KEY }} - run: | - cd examples/SampleApp - bundle exec fastlane deploy_to_testflight_qa deploy:${{ github.ref == 'refs/heads/develop' }}; + APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }} build_and_deploy_android_s3: name: Build SampleApp Android and Deploy-${{ github.ref == 'refs/heads/develop' }} @@ -66,14 +55,13 @@ jobs: - name: Install && Build - SDK and Sample App uses: ./.github/actions/install-and-build-sdk - name: Build + working-directory: examples/SampleApp run: | - cd examples/SampleApp mkdir android/app/src/main/assets mkdir tmp yarn react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest tmp cd android rm -rf $HOME/.gradle/caches/ && ./gradlew assembleRelease - - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1 if: ${{ github.ref == 'refs/heads/develop' }} diff --git a/.github/workflows/sdk-size-metrics.yml b/.github/workflows/sdk-size-metrics.yml new file mode 100644 index 0000000000..0e799c5c07 --- /dev/null +++ b/.github/workflows/sdk-size-metrics.yml @@ -0,0 +1,44 @@ +name: SDK Size + +on: + pull_request: + + workflow_dispatch: + + push: + branches: + - develop + - main + +env: + HOMEBREW_NO_INSTALL_CLEANUP: 1 # Disable cleanup for homebrew, we don't need it on CI + +jobs: + sdk_size: + name: Metrics + runs-on: ubuntu-latest + steps: + - name: Connect Bot + uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.BOT_SSH_PRIVATE_KEY }} + + - uses: actions/checkout@v3.1.0 + + - uses: ./.github/actions/ruby-cache + + - uses: actions/setup-node@v3 + with: + node-version: 18.x + cache: 'yarn' + + - name: Run SDK Size Metrics + run: bundle exec fastlane show_frameworks_sizes update_readme:$UPDATE_README open_pr:$UPDATE_README + working-directory: examples/SampleApp + timeout-minutes: 60 + env: + GITHUB_PR_NUM: ${{ github.event.pull_request.number }} + MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }} + APPSTORE_API_KEY: ${{ secrets.APPSTORE_API_KEY }} + GITHUB_TOKEN: ${{ secrets.CI_BOT_GITHUB_TOKEN }} + UPDATE_README: ${{ github.ref == 'refs/heads/main' }} diff --git a/.gitignore b/.gitignore index 984b4c1299..5ecbf803c8 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,13 @@ e2e/.env .DS_STORE *.db .idea + +# Testing +examples/SampleApp/fastlane/fastlane.log +examples/SampleApp/fastlane/report.xml +examples/SampleApp/fastlane/metrics/ +examples/SampleApp/tmp/ +index.android.bundle +*.app +*.DSYM.zip +**/metrics/ diff --git a/README.md b/README.md index 56b4e1c192..021859f161 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ [![NPM](https://img.shields.io/npm/v/stream-chat-react-native.svg)](https://www.npmjs.com/package/stream-chat-react-native) [![Build Status](https://github.com/GetStream/stream-chat-react-native/actions/workflows/release.yml/badge.svg)](https://github.com/GetStream/stream-chat-react-native/actions) [![Component Reference](https://img.shields.io/badge/docs-component%20reference-blue.svg)](https://getstream.io/chat/docs/sdk/reactnative) +![JS Bundle Size](https://img.shields.io/badge/js_bundle_size-439%20KB-blue) diff --git a/examples/SampleApp/.ruby-version b/examples/SampleApp/.ruby-version deleted file mode 100644 index 460b6fd404..0000000000 --- a/examples/SampleApp/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.5 \ No newline at end of file diff --git a/examples/SampleApp/Gemfile b/examples/SampleApp/Gemfile index 6cdcc82085..545df02c7d 100644 --- a/examples/SampleApp/Gemfile +++ b/examples/SampleApp/Gemfile @@ -1,13 +1,15 @@ source 'https://rubygems.org' -# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby ">= 2.6.10" +# You may use http://rbenv.org to install and use this version +ruby '>= 3.1' # Cocoapods 1.15 introduced a bug which break the build. We will remove the upper # bound in the template on Cocoapods with next React Native release. -gem 'cocoapods', '>= 1.13', '< 1.15' gem 'activesupport', '>= 6.1.7.5', '< 7.1.0' +gem 'cocoapods', '>= 1.13', '< 1.15' +gem 'fastlane' +gem 'rubocop-performance' +gem 'rubocop-require_tools' -gem "fastlane" plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile') eval_gemfile(plugins_path) if File.exist?(plugins_path) diff --git a/examples/SampleApp/Gemfile.lock b/examples/SampleApp/Gemfile.lock index dacc34db00..c399cce1de 100644 --- a/examples/SampleApp/Gemfile.lock +++ b/examples/SampleApp/Gemfile.lock @@ -5,7 +5,7 @@ GEM base64 nkf rexml - activesupport (7.0.8.1) + activesupport (7.0.8.4) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) @@ -16,18 +16,19 @@ GEM httpclient (~> 2.8, >= 2.8.3) json (>= 1.5.1) artifactory (3.0.17) + ast (2.4.2) atomos (0.1.3) aws-eventstream (1.3.0) - aws-partitions (1.962.0) - aws-sdk-core (3.201.3) + aws-partitions (1.966.0) + aws-sdk-core (3.201.5) aws-eventstream (~> 1, >= 1.3.0) aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.8) + aws-sigv4 (~> 1.9) jmespath (~> 1, >= 1.6.1) aws-sdk-kms (1.88.0) aws-sdk-core (~> 3, >= 3.201.0) aws-sigv4 (~> 1.5) - aws-sdk-s3 (1.157.0) + aws-sdk-s3 (1.158.0) aws-sdk-core (~> 3, >= 3.201.0) aws-sdk-kms (~> 1) aws-sigv4 (~> 1.5) @@ -77,7 +78,7 @@ GEM colored2 (3.1.2) commander (4.6.0) highline (~> 2.0.0) - concurrent-ruby (1.2.3) + concurrent-ruby (1.3.4) declarative (0.0.20) digest-crc (0.6.5) rake (>= 12.0.0, < 14.0.0) @@ -158,11 +159,13 @@ GEM xcodeproj (>= 1.13.0, < 2.0.0) xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3, < 2.0.0) - fastlane-plugin-firebase_app_distribution (0.9.0) + fastlane-plugin-firebase_app_distribution (0.9.1) google-apis-firebaseappdistribution_v1 (~> 0.3.0) google-apis-firebaseappdistribution_v1alpha (~> 0.2.0) fastlane-plugin-load_json (0.0.1) - ffi (1.16.3) + fastlane-plugin-stream_actions (0.3.65) + xctest_list (= 1.2.1) + ffi (1.17.0) fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) @@ -207,18 +210,19 @@ GEM os (>= 0.9, < 2.0) signet (>= 0.16, < 2.a) highline (2.0.3) - http-cookie (1.0.6) + http-cookie (1.0.7) domain_name (~> 0.5) httpclient (2.8.3) - i18n (1.14.1) + i18n (1.14.5) concurrent-ruby (~> 1.0) jmespath (1.6.2) json (2.7.2) jwt (2.8.2) base64 + language_server-protocol (3.17.0.3) mini_magick (4.13.2) mini_mime (1.1.5) - minitest (5.22.2) + minitest (5.25.1) molinillo (0.8.0) multi_json (1.15.0) multipart-post (2.4.1) @@ -229,18 +233,44 @@ GEM nkf (0.2.0) optparse (0.5.0) os (1.1.4) + parallel (1.26.3) + parser (3.3.4.2) + ast (~> 2.4.1) + racc plist (3.7.1) public_suffix (4.0.7) + racc (1.8.1) + rainbow (3.1.1) rake (13.2.1) + regexp_parser (2.9.2) representable (3.2.0) declarative (< 0.1.0) trailblazer-option (>= 0.1.1, < 0.2.0) uber (< 0.2.0) retriable (3.1.2) - rexml (3.3.4) + rexml (3.3.5) strscan rouge (2.0.7) + rubocop (1.65.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.4, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.31.1, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.32.1) + parser (>= 3.3.1.0) + rubocop-performance (1.21.1) + rubocop (>= 1.48.1, < 2.0) + rubocop-ast (>= 1.31.1, < 2.0) + rubocop-require_tools (0.1.2) + rubocop (>= 0.49.1) ruby-macho (2.5.1) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) rubyzip (2.3.2) security (0.1.5) @@ -279,6 +309,7 @@ GEM rouge (~> 2.0.7) xcpretty-travis-formatter (1.0.1) xcpretty (~> 0.2, >= 0.0.7) + xctest_list (1.2.1) PLATFORMS ruby @@ -289,9 +320,12 @@ DEPENDENCIES fastlane fastlane-plugin-firebase_app_distribution fastlane-plugin-load_json + fastlane-plugin-stream_actions (= 0.3.65) + rubocop-performance + rubocop-require_tools RUBY VERSION - ruby 2.7.5p203 + ruby 3.3.4p94 BUNDLED WITH - 2.3.21 + 2.5.17 diff --git a/examples/SampleApp/fastlane/.env b/examples/SampleApp/fastlane/.env new file mode 100644 index 0000000000..e7af6b00ce --- /dev/null +++ b/examples/SampleApp/fastlane/.env @@ -0,0 +1,6 @@ +FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT=180 +FASTLANE_XCODEBUILD_SETTINGS_RETRIES=10 +FASTLANE_SKIP_ACTION_SUMMARY=true +FASTLANE_HIDE_PLUGINS_TABLE=true +FASTLANE_SKIP_UPDATE_CHECK=true +FASTLANE_HIDE_CHANGELOG=true diff --git a/examples/SampleApp/fastlane/.rubocop.yml b/examples/SampleApp/fastlane/.rubocop.yml new file mode 100755 index 0000000000..6a1e66a5ef --- /dev/null +++ b/examples/SampleApp/fastlane/.rubocop.yml @@ -0,0 +1,170 @@ +--- +require: +- rubocop/require_tools +- rubocop-performance +AllCops: + TargetRubyVersion: 2.4 + NewCops: enable + Include: + - "**/*.rb" + - "**/*file" +Style/MultipleComparison: + Enabled: false +Style/PercentLiteralDelimiters: + Enabled: false +Style/ClassCheck: + EnforcedStyle: kind_of? +Style/FrozenStringLiteralComment: + Enabled: false +Style/SafeNavigation: + Enabled: false +Performance/RegexpMatch: + Enabled: false +Performance/StringReplacement: + Enabled: false +Performance/CollectionLiteralInLoop: + Enabled: false +Style/NumericPredicate: + Enabled: false +Metrics/BlockLength: + Enabled: false +Metrics/ModuleLength: + Enabled: false +Naming/VariableNumber: + Enabled: false +Style/MissingRespondToMissing: + Enabled: false +Style/MultilineBlockChain: + Enabled: false +Style/NumericLiteralPrefix: + Enabled: false +Style/TernaryParentheses: + Enabled: false +Style/EmptyMethod: + Enabled: false +Lint/UselessAssignment: + Exclude: + - "**/spec/**/*" +Require/MissingRequireStatement: + Enabled: false +Layout/FirstHashElementIndentation: + Enabled: false +Layout/HashAlignment: + Enabled: false +Layout/DotPosition: + Enabled: false +Style/DoubleNegation: + Enabled: false +Style/SymbolArray: + Enabled: false +Layout/HeredocIndentation: + Enabled: false +Style/MixinGrouping: + Exclude: + - "**/spec/**/*" +Lint/SuppressedException: + Enabled: false +Lint/UnusedBlockArgument: + Enabled: false +Lint/AmbiguousBlockAssociation: + Enabled: false +Style/GlobalVars: + Enabled: false +Style/ClassAndModuleChildren: + Enabled: false +Style/SpecialGlobalVars: + Enabled: false +Metrics/AbcSize: + Enabled: false +Metrics/MethodLength: + Enabled: false +Metrics/CyclomaticComplexity: + Enabled: false +Style/WordArray: + MinSize: 19 +Style/SignalException: + Enabled: false +Style/RedundantReturn: + Enabled: false +Style/IfUnlessModifier: + Enabled: false +Style/AndOr: + Enabled: true + EnforcedStyle: conditionals +Metrics/ClassLength: + Max: 320 +Layout/LineLength: + Max: 370 +Metrics/ParameterLists: + Max: 17 +Metrics/PerceivedComplexity: + Max: 20 +Style/GuardClause: + Enabled: false +Style/StringLiterals: + Enabled: false +Style/ConditionalAssignment: + Enabled: false +Style/RedundantSelf: + Enabled: false +Lint/UnusedMethodArgument: + Enabled: false +Lint/ParenthesesAsGroupedExpression: + Exclude: + - "**/spec/**/*" +Naming/PredicateName: + Enabled: false +Style/PerlBackrefs: + Enabled: false +Naming/FileName: + Exclude: + - "**/Dangerfile" + - "**/Brewfile" + - "**/Gemfile" + - "**/Podfile" + - "**/Rakefile" + - "**/Fastfile" + - "**/Scanfile" + - "**/Matchfile" + - "**/Appfile" + - "**/Allurefile" + - "**/Sonarfile" + - "**/Deliverfile" + - "**/Snapfile" + - "**/Pluginfile" + - "**/*.gemspec" +Style/Documentation: + Enabled: false +Style/MutableConstant: + Enabled: false +Style/ZeroLengthPredicate: + Enabled: false +Style/IfInsideElse: + Enabled: false +Style/CollectionMethods: + Enabled: false +Style/MethodCallWithArgsParentheses: + Enabled: true + AllowedMethods: + - require + - require_relative + - fastlane_require + - gem + - program + - command + - raise + - attr_accessor + - attr_reader + - desc + - lane + - private_lane + - platform + - to + - not_to + - describe + - it + - be + - context + - before + - after + - and diff --git a/examples/SampleApp/fastlane/Appfile b/examples/SampleApp/fastlane/Appfile deleted file mode 100644 index 1803063093..0000000000 --- a/examples/SampleApp/fastlane/Appfile +++ /dev/null @@ -1,6 +0,0 @@ -# app_identifier("[[APP_IDENTIFIER]]") # The bundle identifier of your app -# apple_id("[[APPLE_ID]]") # Your Apple email address - - -# For more information about the Appfile, see: -# https://docs.fastlane.tools/advanced/#appfile diff --git a/examples/SampleApp/fastlane/Fastfile b/examples/SampleApp/fastlane/Fastfile index 61ee02df76..6e2b2169f6 100644 --- a/examples/SampleApp/fastlane/Fastfile +++ b/examples/SampleApp/fastlane/Fastfile @@ -1,125 +1,139 @@ -# This file contains the fastlane.tools configuration -# You can find the documentation at https://docs.fastlane.tools -# -# For a list of all available actions, check out -# -# https://docs.fastlane.tools/actions -# -# For a list of all available plugins, check out -# -# https://docs.fastlane.tools/plugins/available-plugins -# - -# Uncomment the line if you want fastlane to automatically update itself -# update_fastlane default_platform(:ios) +skip_docs +github_repo = ENV['GITHUB_REPOSITORY'] || 'GetStream/stream-chat-react-native' +bundle_id = 'io.getstream.reactnative.SampleApp' +xcode_project = 'ios/SampleApp.xcodeproj' +xcode_workspace = 'ios/SampleApp.xcworkspace' +root_path = File.absolute_path('../../../') +sdk_size_ext = 'KB' +@force_check = false before_all do if is_ci - setup_ci() + setup_ci + setup_git_config end end +####################### +###### iOS lanes ###### +####################### -desc "Installs all Certs and Profiles necessary for development and ad-hoc" -lane :match_me do - match( - type: "adhoc", - app_identifier: [ - "io.getstream.reactnative.SampleApp", - ], - readonly: true, - force_for_new_devices: !is_ci +lane :deploy_to_testflight_qa do |options| + match_me + + settings_to_override = { + BUNDLE_IDENTIFIER: bundle_id, + PROVISIONING_PROFILE_SPECIFIER: "match AppStore #{bundle_id}" + } + + increment_version_number( + version_number: load_json(json_path: './package.json')['version'], + xcodeproj: xcode_project ) -end -desc "Installs all Certs and Profiles necessary for appstore" -lane :match_appstore do - match( - type: "appstore", - app_identifier: [ - "io.getstream.reactnative.SampleApp", - ], - readonly: is_ci + current_build_number = app_store_build_number( + api_key: appstore_api_key, + live: false, + app_identifier: bundle_id ) -end -platform :ios do - desc "Deploy build to Firebase" - lane :deploy_to_firebase do - match_me - - gym( - workspace: "./ios/SampleApp.xcworkspace", - scheme: "SampleApp", - export_method: "ad-hoc", - export_options: "./fastlane/beta_gym_export_options.plist", - silent: true, - clean: true, - include_symbols: true, - output_directory: "./dist", - xcargs: "ENABLE_BITCODE=1" - ) - - firebase_app_distribution( - app: "1:190151624402:ios:403df895972564bd658f0b", - groups: "ios-react-native-testers", - release_notes: "Lots of amazing new features to test out!" - ) + increment_build_number( + build_number: current_build_number + 1, + xcodeproj: xcode_project + ) + + gym( + workspace: xcode_workspace, + scheme: 'SampleApp', + export_method: 'app-store', + export_options: './fastlane/testflight_gym_export_options.plist', + silent: true, + clean: true, + xcargs: settings_to_override, + include_symbols: true, + output_directory: './dist' + ) + + if options[:deploy] + begin + upload_to_testflight( + groups: ['Testers'], + changelog: 'Lots of amazing new features to test out!', + reject_build_waiting_for_review: false + ) + rescue StandardError => e + if e.message.include?('Another build is in review') + UI.important('Another build is already in beta review. Skipping beta review submission') + else + UI.user_error!(e) + end + end end end -platform :ios do - desc "Deploy build to TestFlight QA" - lane :deploy_to_testflight_qa do |options| - app_store_connect_api_key() +private_lane :appstore_api_key do + @appstore_api_key ||= app_store_connect_api_key( + key_id: 'MT3PRT8TB7', + issuer_id: '69a6de96-0738-47e3-e053-5b8c7c11a4d1', + key_content: ENV.fetch('APPSTORE_API_KEY', nil), + in_house: false + ) +end - match_appstore +desc "If `readonly: true` (by default), installs all Certs and Profiles necessary for development and ad-hoc.\nIf `readonly: false`, recreates all Profiles necessary for development and ad-hoc, updates them locally and remotely." +lane :match_me do |options| + custom_match( + api_key: appstore_api_key, + app_identifier: [bundle_id], + readonly: options[:readonly], + register_device: options[:register_device] + ) +end - settings_to_override = { - :BUNDLE_IDENTIFIER => "io.getstream.reactnative.SampleApp", - :PROVISIONING_PROFILE_SPECIFIER => "match AppStore io.getstream.reactnative.SampleApp" - } +########################### +###### Android lanes ###### +########################### - package = load_json(json_path: "./package.json") - increment_version_number(version_number: package["version"], xcodeproj: "./ios/SampleApp.xcodeproj") - current_build_number = app_store_build_number( - live: false, - app_identifier: "io.getstream.reactnative.SampleApp", - ) - increment_build_number( - build_number: current_build_number + 1, - xcodeproj: "./ios/SampleApp.xcodeproj" - ) +########################## +###### Common lanes ###### +########################## - gym( - workspace: "./ios/SampleApp.xcworkspace", - scheme: "SampleApp", - export_method: "app-store", - export_options: "./fastlane/testflight_gym_export_options.plist", - silent: true, - clean: true, - xcargs: settings_to_override, - include_symbols: true, - output_directory: "./dist", - ) +lane :file_size do |options| + File.size(options[:path]) / 1024.0 +end - if options[:deploy] - begin - upload_to_testflight( - groups: ['Testers'], - changelog: "Lots of amazing new features to test out!", - reject_build_waiting_for_review: false - ) - rescue Exception => e - if e.message.include? "Another build is in review" - UI.important("Another build is already in beta review. Skipping beta review submission") - else - raise - end - end - end +lane :yarn_all do + Dir.chdir(root_path) { sh('yarn --frozen-lockfile') } + Dir.chdir("#{root_path}/package") { sh('yarn --frozen-lockfile') } + Dir.chdir("#{root_path}/package/native-package") { sh('yarn') } + Dir.chdir("#{root_path}/package/expo-package") { sh('yarn') } +end +lane :frameworks_sizes do + Dir.chdir(root_path) do + yarn_all + sh('yarn build') + sh('yarn minify-bundle') + js_bundle_size = file_size(path: 'package/lib/module/bundle.min.js') + { js_bundle_size: js_bundle_size } end end + +lane :show_frameworks_sizes do |options| + next unless is_check_required(sources: ['package/'], force_check: @force_check) + + sizes = options[:sizes] || frameworks_sizes + show_sdk_size(branch_sizes: sizes, github_repo: github_repo, size_ext: sdk_size_ext) + update_img_shields_sdk_sizes(sizes: sizes, open_pr: options[:open_pr]) if options[:update_readme] +end + +lane :update_img_shields_sdk_sizes do |options| + update_sdk_size_in_readme( + readme_path: '../../README.md', + open_pr: options[:open_pr] || false, + sizes: options[:sizes] || frameworks_sizes, + size_ext: sdk_size_ext + ) +end diff --git a/examples/SampleApp/fastlane/Matchfile b/examples/SampleApp/fastlane/Matchfile index 2dcd276f38..f26ef457be 100644 --- a/examples/SampleApp/fastlane/Matchfile +++ b/examples/SampleApp/fastlane/Matchfile @@ -1,15 +1,5 @@ - -git_url("https://github.com/GetStream/ios-certificates") +git_url("git@github.com:GetStream/ios-certificates.git") storage_mode("git") team_id("EHV7XZLAHA") - -# app_identifier(["tools.fastlane.app", "tools.fastlane.app2"]) - -# username("user@fastlane.tools") # Your Apple Developer Portal username - -# For all available options run `fastlane match --help` -# Remove the # in the beginning of the line to enable the other options - -# The docs are available on https://docs.fastlane.tools/actions/match diff --git a/examples/SampleApp/fastlane/Pluginfile b/examples/SampleApp/fastlane/Pluginfile index 9a39b1bae1..96f8283318 100644 --- a/examples/SampleApp/fastlane/Pluginfile +++ b/examples/SampleApp/fastlane/Pluginfile @@ -4,3 +4,4 @@ gem 'fastlane-plugin-firebase_app_distribution' gem 'fastlane-plugin-load_json' +gem 'fastlane-plugin-stream_actions', '0.3.65' diff --git a/examples/SampleApp/fastlane/README.md b/examples/SampleApp/fastlane/README.md deleted file mode 100644 index e34a9507e5..0000000000 --- a/examples/SampleApp/fastlane/README.md +++ /dev/null @@ -1,59 +0,0 @@ -fastlane documentation ----- - -# Installation - -Make sure you have the latest version of the Xcode command line tools installed: - -```sh -xcode-select --install -``` - -For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane) - -# Available Actions - -### match_me - -```sh -[bundle exec] fastlane match_me -``` - -Installs all Certs and Profiles necessary for development and ad-hoc - -### match_appstore - -```sh -[bundle exec] fastlane match_appstore -``` - -Installs all Certs and Profiles necessary for appstore - ----- - - -## iOS - -### ios deploy_to_firebase - -```sh -[bundle exec] fastlane ios deploy_to_firebase -``` - -Deploy build to Firebase - -### ios deploy_to_testflight_qa - -```sh -[bundle exec] fastlane ios deploy_to_testflight_qa -``` - -Deploy build to TestFlight QA - ----- - -This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run. - -More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools). - -The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools). diff --git a/examples/SampleApp/fastlane/beta_gym_export_options.plist b/examples/SampleApp/fastlane/beta_gym_export_options.plist index 8f54367db8..6ec6583d07 100644 --- a/examples/SampleApp/fastlane/beta_gym_export_options.plist +++ b/examples/SampleApp/fastlane/beta_gym_export_options.plist @@ -1,13 +1,15 @@ - - iCloudContainerEnvironment - Development - provisioningProfiles - io.getstream.reactnative.SampleApp - match AdHoc io.getstream.reactnative.SampleApp - - + iCloudContainerEnvironment + Development + provisioningProfiles + + io.getstream.reactnative.SampleApp + match AdHoc io.getstream.reactnative.SampleApp + + signingCertificate + Apple Distribution + \ No newline at end of file diff --git a/examples/SampleApp/fastlane/report.xml b/examples/SampleApp/fastlane/report.xml deleted file mode 100644 index 9876711c51..0000000000 --- a/examples/SampleApp/fastlane/report.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples/SampleApp/fastlane/testflight_gym_export_options.plist b/examples/SampleApp/fastlane/testflight_gym_export_options.plist index e5c94d098f..dff2dc83f1 100644 --- a/examples/SampleApp/fastlane/testflight_gym_export_options.plist +++ b/examples/SampleApp/fastlane/testflight_gym_export_options.plist @@ -1,13 +1,13 @@ - - iCloudContainerEnvironment - Development - provisioningProfiles - io.getstream.reactnative.SampleApp - match AppStore io.getstream.reactnative.SampleApp - - + iCloudContainerEnvironment + Development + provisioningProfiles + + io.getstream.reactnative.SampleApp + match AppStore io.getstream.reactnative.SampleApp + + \ No newline at end of file diff --git a/package.json b/package.json index 70f26fc5e9..fd1380a2e2 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,8 @@ "husky": "^6.0.0", "jest": "^27.0.6", "lerna": "^4.0.0", - "semantic-release": "^17.4.4" + "semantic-release": "^17.4.4", + "uglify-js": "^3.19.2" }, "husky": { "hooks": { @@ -38,6 +39,7 @@ "build": "yarn lerna-workspaces run build", "test:coverage": "yarn lerna-workspaces run test:coverage", "test:unit": "yarn lerna-workspaces run test:unit", + "minify-bundle": "uglifyjs package/lib/module/**/*.js -o package/lib/module/bundle.min.js -c -m", "detox-sample-android:build": "detox build --configuration android.sample.release", "detox-sample-ios:build": "detox build --configuration ios.sample.release", "detox-sample-android:test": "PLATFORM=android detox test --configuration android.sample.release e2e/entries/SampleApp.e2e.js", diff --git a/yarn.lock b/yarn.lock index bdc2629ca0..5ca60abe32 100644 --- a/yarn.lock +++ b/yarn.lock @@ -7633,6 +7633,11 @@ uglify-js@^3.1.4: resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.17.4.tgz#61678cf5fa3f5b7eb789bb345df29afb8257c22c" integrity sha512-T9q82TJI9e/C1TAxYvfb16xO120tMVFZrGA3f9/P4424DNu6ypK103y0GPFVa17yotwSyZW5iYXgjYHkGrJW/g== +uglify-js@^3.19.2: + version "3.19.2" + resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.19.2.tgz#319ae26a5fbd18d03c7dc02496cfa1d6f1cd4307" + integrity sha512-S8KA6DDI47nQXJSi2ctQ629YzwOVs+bQML6DAtvy0wgNdpi+0ySpQK0g2pxBq2xfF2z3YCscu7NNA8nXT9PlIQ== + uid-number@0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"