setup fastlane for android

This commit is contained in:
Gergely Hegedus 2023-09-01 17:18:08 +03:00
parent bf2fab3aa1
commit c28bf2449e
10 changed files with 485 additions and 3 deletions

2
android/fastlane/Appfile Normal file
View file

@ -0,0 +1,2 @@
json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one
package_name("com.initproject") # e.g. com.krausefx.app

91
android/fastlane/Fastfile Normal file
View file

@ -0,0 +1,91 @@
# 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(:android)
platform :android do
before_all do
FIREBASE_APP_DISTRIBUTION_APP_STAGING = "1:64659984801:android:7a0514333a32b8c5f43be0"
FIREBASE_APP_DISTRIBUTION_GROUPS_QA = "android-qa"
FIREBASE_SERVICE_ACCOUNT_FILE = ENV['CI_EVALUATION_FIREBASE_SERVICE_ACCOUNT_FILE']
PLAYSTORE_SERVICE_ACCOUNT_FILE = ENV['CI_EVALUATION_PLAYSTORE_SERVICE_ACCOUNT_FILE']
end
desc "Submit a new Internal Build to Firebase"
desc ">Optionally release notes can be added like so:"
desc "```sh"
desc "[bundle exec] fastlane deployInternalFirebase release_notes:testing"
desc "```"
lane :deployInternalFirebase do |options|
release_notes = options[:release_notes]
gradle(task: 'clean', flags: "--no-daemon")
gradle(
task: 'assemble',
build_type: 'release',
flags: "--no-daemon",
properties: {
"applicationId" => "com.initproject.staging"
}
)
internal_apk = lane_context[SharedValues::GRADLE_ALL_APK_OUTPUT_PATHS].find{ |i| i[/app-*release*.apk/] }
firebase_app_distribution(
service_credentials_file: FIREBASE_SERVICE_ACCOUNT_FILE,
app: FIREBASE_APP_DISTRIBUTION_APP_STAGING,
groups: FIREBASE_APP_DISTRIBUTION_GROUPS_QA,
android_artifact_type: 'APK',
android_artifact_path: internal_apk,
release_notes: "#{release_notes}",
)
end
desc "Submit a new Production Build to Play Store"
lane :deployProdPlayStore do |options|
version_code = options[:version_code] # optional, if not set, it gets the last from PlayStore then adds + 1
package_name = "com.initproject.prod"
if version_code.nil?
last_version_codes = google_play_track_version_codes(
track: 'internal',
json_key: PLAYSTORE_SERVICE_ACCOUNT_FILE,
package_name: package_name
)
last_version_code = last_version_codes[0]
version_code = last_version_code + 1
end
gradle(task: 'clean', flags: "--no-daemon")
gradle(
task: 'bundle',
build_type: 'release',
flags: "--no-daemon",
properties: {
"versionCode" => version_code
}
)
production_aab = lane_context[SharedValues::GRADLE_ALL_AAB_OUTPUT_PATHS].find{ |i| i[/app-*release*.aab/] }
upload_to_play_store(
track: 'internal',
release_status: 'draft', # can remove once app is released to the public
aab: production_aab,
json_key: PLAYSTORE_SERVICE_ACCOUNT_FILE,
skip_upload_apk: true,
package_name: package_name,
)
end
end

View file

@ -0,0 +1,5 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!
gem 'fastlane-plugin-firebase_app_distribution'

View file

@ -0,0 +1,48 @@
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
## Android
### android deployInternalFirebase
```sh
[bundle exec] fastlane android deployInternalFirebase
```
Submit a new Internal Build to Firebase
>Optionally release notes can be added like so:
```sh
[bundle exec] fastlane deployInternalFirebase release_notes:testing
```
### android deployProdPlayStore
```sh
[bundle exec] fastlane android deployProdPlayStore
```
Submit a new Production Build to Play Store
----
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).