From 41c9140755c08fe0b657db28e731ca2d29f35c5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Irland?= Date: Wed, 1 Feb 2023 13:17:41 -0300 Subject: [PATCH] feat: Add ios and web compilation in the ci and add web deploy to the CD (#86) --- .github/workflows/flutter-ci.yml | 96 ++++++++++++++++- Gemfile.lock | 1 + android/fastlane/README.md | 8 ++ fastlane/Fastfile | 14 ++- fastlane/README.md | 8 ++ ios/Runner/Info.plist | 2 + ios/fastlane/Fastfile | 11 ++ ios/fastlane/README.md | 16 +++ scripts/regenerate_fastlane_docs.sh | 1 + web/.ruby-version | 1 + web/fastlane/Fastfile | 25 +++++ web/fastlane/Pluginfile | 6 ++ web/fastlane/README.md | 155 ++++++++++++++++++++++++++++ 13 files changed, 334 insertions(+), 10 deletions(-) create mode 120000 web/.ruby-version create mode 100644 web/fastlane/Fastfile create mode 100644 web/fastlane/Pluginfile create mode 100644 web/fastlane/README.md diff --git a/.github/workflows/flutter-ci.yml b/.github/workflows/flutter-ci.yml index 9e33757..102209b 100644 --- a/.github/workflows/flutter-ci.yml +++ b/.github/workflows/flutter-ci.yml @@ -6,7 +6,7 @@ on: - main jobs: - build: + checks_and_tests: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -30,10 +30,6 @@ jobs: - uses: ruby/setup-ruby@v1 with: bundler-cache: true - - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - working-directory: 'android' - name: Create google-services.json uses: timheuer/base64-to-file@v1.2 with: @@ -56,8 +52,98 @@ jobs: uses: maierj/fastlane-action@v3.0.0 with: lane: 'tests' + build_android_web: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + - uses: dart-lang/setup-dart@v1.3 + - name: Cache FVM & Flutter + uses: actions/cache@v3 + with: + path: /home/runner/fvm/versions/ + key: ${{ runner.os }}-${{ hashFiles('**/fvm_config.json') }} + - name: Cache pub cache + uses: actions/cache@v3 + with: + path: /home/runner/.pub-cache/ + key: ${{ runner.os }}-pub-cache + - name: Install FVM && Flutter + run: dart pub global activate fvm --verbose && fvm install --verbose && fvm use --force --verbose + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + working-directory: 'android' + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + working-directory: 'web' + - name: Create google-services.json + uses: timheuer/base64-to-file@v1.2 + with: + fileName: 'google-services.json' + fileDir: 'android/app/' + encodedString: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON_BASE_64 }} + - name: Get dependencies + uses: maierj/fastlane-action@v3.0.0 + with: + lane: 'fetch_dependencies' - name: 'Build android app' uses: maierj/fastlane-action@v3.0.0 with: lane: 'android build_dev_debug_apk' subdirectory: 'android' + - name: 'Build web app' + uses: maierj/fastlane-action@v3.0.0 + with: + lane: 'web build_dev' + subdirectory: 'web' + build_ios: + runs-on: macOS-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-java@v3 + with: + distribution: 'zulu' + java-version: '11' + - uses: dart-lang/setup-dart@v1.3 + - name: Cache FVM & Flutter + uses: actions/cache@v3 + with: + path: /home/runner/fvm/versions/ + key: ${{ runner.os }}-${{ hashFiles('**/fvm_config.json') }} + - name: Cache pub cache + uses: actions/cache@v3 + with: + path: /home/runner/.pub-cache/ + key: ${{ runner.os }}-pub-cache + - name: Install FVM && Flutter + run: dart pub global activate fvm --verbose && fvm install --verbose && fvm use --force --verbose + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + working-directory: 'ios' + - name: Create google-services.json + uses: timheuer/base64-to-file@v1.2 + with: + fileName: 'google-services.json' + fileDir: 'android/app/' + encodedString: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON_BASE_64 }} + - name: Get dependencies + uses: maierj/fastlane-action@v3.0.0 + with: + lane: 'fetch_dependencies' + - name: 'Build ios app' + uses: maierj/fastlane-action@v3.0.0 + with: + lane: 'ios build_ipa_dev' + subdirectory: 'ios' diff --git a/Gemfile.lock b/Gemfile.lock index b1b2806..0255d54 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -277,6 +277,7 @@ GEM PLATFORMS arm64-darwin-21 x86_64-darwin-20 + x86_64-darwin-19 x86_64-linux DEPENDENCIES diff --git a/android/fastlane/README.md b/android/fastlane/README.md index ceddd3f..210509b 100644 --- a/android/fastlane/README.md +++ b/android/fastlane/README.md @@ -13,6 +13,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do # Available Actions +### sh_on_root + +```sh +[bundle exec] fastlane sh_on_root +``` + + + ### fetch_dependencies ```sh diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 74f7ca1..dc9bbf7 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -12,10 +12,10 @@ def compilation_envs end def root_path - Dir.pwd.sub(/.*\Kfastlane/, '').sub(/.*\Kandroid/, '').sub(/.*\Kios/, '').sub(/.*\K\/\//, '') + Dir.pwd.sub(/.*\Kfastlane/, '').sub(/.*\Kandroid/, '').sub(/.*\Kweb/, '').sub(/.*\Kios/, '').sub(/.*\K\/\//, '') end -private_lane :sh_on_root do |options| +lane :sh_on_root do |options| command = options[:command] sh("cd #{root_path} && #{command}") end @@ -105,8 +105,7 @@ lane :build_flutter do |options| build_type = "--#{build_type}" end - sign_enabled = options[:sign_enabled] || true - sign_param = sign_enabled ? '' : '--no-codesign' + sign_param = options.fetch(:sign_enabled, true) ? '' : '--no-codesign' build_platform = options[:build_platform] @@ -123,7 +122,12 @@ lane :build_flutter do |options| export_method = "--export-method #{export_method}" end - flutter_command(command: "build #{build_platform} #{build_type} --suppress-analytics #{sign_param} #{config_param} --flavor #{flavor} --dart-define=ENV=#{flavor} --build-name #{version_name} #{export_method} #{compilation_envs}") + flavour_arg = options[:export_method] || '' + if build_platform != 'web' + flavour_arg = " --flavor #{flavor}" + end + + flutter_command(command: "build #{build_platform} #{build_type} --suppress-analytics #{sign_param} #{config_param} #{flavour_arg} --dart-define=ENV=#{flavor} --build-name #{version_name} #{export_method} #{compilation_envs}") end private_lane :calculate_version_name do |options| diff --git a/fastlane/README.md b/fastlane/README.md index 8a3d91b..f47148c 100644 --- a/fastlane/README.md +++ b/fastlane/README.md @@ -13,6 +13,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do # Available Actions +### sh_on_root + +```sh +[bundle exec] fastlane sh_on_root +``` + + + ### fetch_dependencies ```sh diff --git a/ios/Runner/Info.plist b/ios/Runner/Info.plist index 620384a..f357046 100644 --- a/ios/Runner/Info.plist +++ b/ios/Runner/Info.plist @@ -52,5 +52,7 @@ youtube + UIApplicationSupportsIndirectInputEvents + diff --git a/ios/fastlane/Fastfile b/ios/fastlane/Fastfile index b82a51a..24a3d81 100644 --- a/ios/fastlane/Fastfile +++ b/ios/fastlane/Fastfile @@ -15,6 +15,17 @@ provisioning_name = 'fluttips_fastlane' ENV['ITMSTRANSPORTER_FORCE_ITMS_PACKAGE_UPLOAD'] = 'true' platform :ios do + desc "**Build dev debug app**" + lane :build_ipa_dev do + build_flutter( + build_platform: 'ipa', + build_type: 'debug', + flavor: 'dev', + include_git_version_suffix: false, + export_method: 'ad-hoc', + sign_enabled: false, + ) + end desc "Creates a temporal keystore and import the distribution certificate" desc "#### Envs\n" + diff --git a/ios/fastlane/README.md b/ios/fastlane/README.md index e777105..66b9e1c 100644 --- a/ios/fastlane/README.md +++ b/ios/fastlane/README.md @@ -13,6 +13,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do # Available Actions +### sh_on_root + +```sh +[bundle exec] fastlane sh_on_root +``` + + + ### fetch_dependencies ```sh @@ -106,6 +114,14 @@ For _fastlane_ installation instructions, see [Installing _fastlane_](https://do ## iOS +### ios build_ipa_dev + +```sh +[bundle exec] fastlane ios build_ipa_dev +``` + +**Build dev debug app** + ### ios set_signing ```sh diff --git a/scripts/regenerate_fastlane_docs.sh b/scripts/regenerate_fastlane_docs.sh index 77b08ab..4f25cbc 100755 --- a/scripts/regenerate_fastlane_docs.sh +++ b/scripts/regenerate_fastlane_docs.sh @@ -3,3 +3,4 @@ fastlane fetch_dependencies cd android && fastlane fetch_dependencies && cd - cd ios && fastlane fetch_dependencies && cd - +cd web && fastlane fetch_dependencies && cd - diff --git a/web/.ruby-version b/web/.ruby-version new file mode 120000 index 0000000..5e66ef4 --- /dev/null +++ b/web/.ruby-version @@ -0,0 +1 @@ +../.ruby-version \ No newline at end of file diff --git a/web/fastlane/Fastfile b/web/fastlane/Fastfile new file mode 100644 index 0000000..e06d1e1 --- /dev/null +++ b/web/fastlane/Fastfile @@ -0,0 +1,25 @@ +import "../../fastlane/Fastfile" + +default_platform(:web) +platform :web do + desc "**Build dev debug app**" + lane :build_dev do |options| + build_flutter(build_platform: 'web', flavor: 'dev') + end + + desc "**Submit a new Staging Build to Firebase Hosting**" + desc "#### Envs\n" + + " * **`FIREBASE_SERVICE_ACCOUNT_FILE`**: The path to your Google service account json file.\n" + lane :deploy_firebase_app_distribution_dev_staging do |options| + build_dev + sh_on_root(command: 'firebase hosting:channel:deploy staging') + end + + desc "**Submit a new Staging Build to Firebase Hosting**" + desc "#### Envs\n" + + " * **`FIREBASE_SERVICE_ACCOUNT_FILE`**: The path to your Google service account json file.\n" + lane :deploy_firebase_app_distribution_prod do |options| + build_flutter(build_platform: 'web', flavor: 'prod') + sh_on_root(command: 'firebase deploy') + end +end diff --git a/web/fastlane/Pluginfile b/web/fastlane/Pluginfile new file mode 100644 index 0000000..fa81426 --- /dev/null +++ b/web/fastlane/Pluginfile @@ -0,0 +1,6 @@ +# Autogenerated by fastlane +# +# Ensure this file is checked in to source control! + +gem 'fastlane-plugin-flutter_version' +gem 'fastlane-plugin-firebase_app_distribution' diff --git a/web/fastlane/README.md b/web/fastlane/README.md new file mode 100644 index 0000000..607ff34 --- /dev/null +++ b/web/fastlane/README.md @@ -0,0 +1,155 @@ +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 + +### sh_on_root + +```sh +[bundle exec] fastlane sh_on_root +``` + + + +### fetch_dependencies + +```sh +[bundle exec] fastlane fetch_dependencies +``` + +**Fetch flutter dependencies** + +### build_autogenerated_code + +```sh +[bundle exec] fastlane build_autogenerated_code +``` + +**Generate flutter generated code** + +### lint_format + +```sh +[bundle exec] fastlane lint_format +``` + +**Lint: Check code format** + +### lint_check_language_sorting + +```sh +[bundle exec] fastlane lint_check_language_sorting +``` + +**Lint: Check code format** + +### lint_analyze + +```sh +[bundle exec] fastlane lint_analyze +``` + +**Lint: Analyze code** + +### lint_code_metrics + +```sh +[bundle exec] fastlane lint_code_metrics +``` + +**Lint: Code metrics** + +### lints + +```sh +[bundle exec] fastlane lints +``` + +**Run linters** + +### ensure_no_change_in_generated_code + +```sh +[bundle exec] fastlane ensure_no_change_in_generated_code +``` + +**Check generated code is fine** + +### tests + +```sh +[bundle exec] fastlane tests +``` + +**Run tests** + +### clean_up + +```sh +[bundle exec] fastlane clean_up +``` + +**Clean up project** + +### build_flutter + +```sh +[bundle exec] fastlane build_flutter +``` + + + +---- + + +## web + +### web build_dev + +```sh +[bundle exec] fastlane web build_dev +``` + +**Build dev debug app** + +### web deploy_firebase_app_distribution_dev_staging + +```sh +[bundle exec] fastlane web deploy_firebase_app_distribution_dev_staging +``` + +**Submit a new Staging Build to Firebase Hosting** + +#### Envs + * **`FIREBASE_SERVICE_ACCOUNT_FILE`**: The path to your Google service account json file. + + +### web deploy_firebase_app_distribution_prod + +```sh +[bundle exec] fastlane web deploy_firebase_app_distribution_prod +``` + +**Submit a new Staging Build to Firebase Hosting** + +#### Envs + * **`FIREBASE_SERVICE_ACCOUNT_FILE`**: The path to your Google service account json file. + + +---- + +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).