Skip to content

Commit

Permalink
feat: Add ios and web compilation in the ci and add web deploy to the…
Browse files Browse the repository at this point in the history
… CD (#86)
  • Loading branch information
mirland authored Feb 1, 2023
1 parent b43ee9d commit 41c9140
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 10 deletions.
96 changes: 91 additions & 5 deletions .github/workflows/flutter-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

jobs:
build:
checks_and_tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -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/[email protected]
with:
Expand All @@ -56,8 +52,98 @@ jobs:
uses: maierj/[email protected]
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/[email protected]
- 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/[email protected]
with:
fileName: 'google-services.json'
fileDir: 'android/app/'
encodedString: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON_BASE_64 }}
- name: Get dependencies
uses: maierj/[email protected]
with:
lane: 'fetch_dependencies'
- name: 'Build android app'
uses: maierj/[email protected]
with:
lane: 'android build_dev_debug_apk'
subdirectory: 'android'
- name: 'Build web app'
uses: maierj/[email protected]
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/[email protected]
- 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/[email protected]
with:
fileName: 'google-services.json'
fileDir: 'android/app/'
encodedString: ${{ secrets.ANDROID_GOOGLE_SERVICES_JSON_BASE_64 }}
- name: Get dependencies
uses: maierj/[email protected]
with:
lane: 'fetch_dependencies'
- name: 'Build ios app'
uses: maierj/[email protected]
with:
lane: 'ios build_ipa_dev'
subdirectory: 'ios'
1 change: 1 addition & 0 deletions Gemfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions android/fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 9 additions & 5 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]

Expand All @@ -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|
Expand Down
8 changes: 8 additions & 0 deletions fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@
<array>
<string>youtube</string>
</array>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
</dict>
</plist>
11 changes: 11 additions & 0 deletions ios/fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
16 changes: 16 additions & 0 deletions ios/fastlane/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions scripts/regenerate_fastlane_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
1 change: 1 addition & 0 deletions web/.ruby-version
25 changes: 25 additions & 0 deletions web/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions web/fastlane/Pluginfile
Original file line number Diff line number Diff line change
@@ -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'
Loading

0 comments on commit 41c9140

Please sign in to comment.