Last active
August 18, 2022 14:44
-
-
Save rodydavis/b44fe53f003e05333a3ab51f72b63b97 to your computer and use it in GitHub Desktop.
Top-level Fastfile for Flutter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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(nightly: true) | |
# You can either generate the build number on commits or increment by 1 | |
# version: 0.0.1+1 in pubspec.yaml | |
# Change to false if not setup for project level version and build number | |
# true: generated build number off of commits in Git Repo | |
# false: increments build number | |
# Android Lane Need to Install: https://github.com/Jems22/fastlane-plugin-increment_version_code | |
# To Change with |options|: | |
# bundle exec fastlane beta flutter_version:true | |
flutterVersion = false | |
app_name = "APP_NAME_HERE" #{app_name} | |
project_path = "PROJECT_PATH_HERE" #{project_path} | |
username = "APPLE_ID_HERE" #{username} // Apple ID | |
crashlytics_api_key = "CRASHLYTICS_API_KEY_HERE" | |
crashlytics_build_secret = "CRASHLYTICS_BUILD_SECRET_HERE" | |
slack_url = "SLACK_WEBHOOK_INCOMING_URL_HERE" | |
build_number = 0 | |
changelog = "" | |
# At the Project root you can run: | |
# 1. fastlane beta | |
# 2. fastlane release | |
desc "Deploy a new version to the Google Play Beta and TestFlight" | |
lane :beta do |options| | |
if options[:flutter_version] | |
flutterVersion = true | |
end | |
self.runner.current_platform = :android | |
beta | |
self.runner.current_platform = :ios | |
beta | |
end | |
desc "Deploy a new version to the Google Play and the App Store" | |
lane :release do |options| | |
if options[:flutter_version] | |
flutterVersion = true | |
end | |
ensure_git_status_clean | |
changelog = prompt( | |
text: "Changelog: ", | |
multi_line_end_keyword: "END" | |
) | |
self.runner.current_platform = :android | |
release | |
self.runner.current_platform = :ios | |
release | |
end | |
lane :build do |options| | |
if options[:flutter_version] | |
flutterVersion = true | |
end | |
self.runner.current_platform = :android | |
prepare | |
self.runner.current_platform = :ios | |
prepare | |
end | |
# default_platform(:android) | |
platform :android do | |
desc "Add Badge to Launcher Icon" | |
lane :beta_badge do |options| | |
Dir.chdir "#{project_path}/android" do | |
if options[:hide] | |
add_badge(no_badge: true, glob: "/android/app/src/main/res/mipmap-*/ic_launcher.png",) | |
else | |
add_badge(dark: true, glob: "/android/app/src/main/res/mipmap-*/ic_launcher.png",) | |
end | |
end | |
end | |
desc "Prepare and archive app" | |
lane :prepare do |options| | |
Dir.chdir ".." do | |
sh("flutter", "packages", "get") | |
sh("flutter", "clean") | |
if flutterVersion == true | |
build_number = number_of_commits(all: true) | |
sh("flutter", "build", "apk", "--build-number=#{build_number}") | |
else # Just Increment Build Number | |
Dir.chdir "#{project_path}/android" do | |
build_number = increment_version_code | |
end | |
sh("flutter", "build", "apk") | |
end | |
end | |
# beta_badge(hide: options[:release]) | |
end | |
desc "Deploy a new version to the Google Play Beta" | |
lane :beta do | |
prepare(release: false) | |
# crashlytics( | |
# # crashlytics_path: "#{project_path}/ios/Pods/Crashlytics/", # path to your Crashlytics submit binary. | |
# api_token: crashlytics_api_key, | |
# build_secret: crashlytics_build_secret, | |
# apk_path: "#{project_path}/build/app/outputs/apk/release/app-release.apk", | |
# notes: changelog_from_git_commits, | |
# ) | |
upload_to_play_store( | |
track: 'beta', | |
apk: "#{project_path}/build/app/outputs/apk/release/app-release.apk", | |
skip_upload_screenshots: true, | |
skip_upload_images: true) | |
# slack( | |
# message: "#{app_name} (#{build_number}): Android sent to beta", | |
# slack_url: slack_url, | |
# ) | |
add_git_tag(build_number: build_number) | |
end | |
desc "Deploy a new version to the Google Play Production" | |
lane :release do | |
prepare(release: true) | |
upload_to_play_store( | |
track: 'production', | |
apk: "#{project_path}/build/app/outputs/apk/release/app-release.apk", | |
skip_upload_screenshots: true, | |
skip_upload_images: true, | |
) | |
# slack( | |
# message: "#{app_name} (#{build_number}): Android sent to production", | |
# slack_url: slack_url, | |
# ) | |
add_git_tag(build_number: build_number) | |
end | |
end | |
platform :ios do | |
desc "Capture Screenshots" | |
lane :screenshots do | |
# sh "cd /Users/Shared/CrossMedia/Projects/MyUnifyMobile && flutter build ios" | |
#SNAPSHOT_FORCE_DELETE=1 fastlane snapshot reset_simulators && fastlane snapshot --number_of_retries 3 | |
# reset_simulators | |
# sh "xcrun simctl erase all" | |
capture_ios_screenshots( | |
workspace: "#{project_path}/ios/Runner.xcworkspace", | |
erase_simulator: true, | |
concurrent_simulators: false, | |
number_of_retries: 1 | |
) | |
# frame_screenshots(white: true) | |
upload_to_app_store | |
# slack( | |
# message: "#{app_name} (#{build_number}): Successfully captured new screenshots for iOS", | |
# slack_url: slack_url, | |
# ) | |
end | |
desc "Add Badge to App Icon" | |
lane :beta_badge do |options| | |
Dir.chdir "#{project_path}/ios" do | |
if options[:hide] | |
add_badge(no_badge: true) | |
# sh 'git checkout -- <path>/Assets.xcassets/' | |
else | |
add_badge(dark: true) | |
end | |
end | |
end | |
desc "Prepare and archive app" | |
lane :prepare do |options| | |
Dir.chdir "#{project_path}/ios" do | |
sh('xcodebuild -sdk "${TARGET_SDK}" -xcconfig "${CONFIG_FILE_PATH}" -configuration Release clean') | |
end | |
Dir.chdir ".." do | |
sh("flutter", "packages", "get") | |
sh("flutter", "clean") | |
if flutterVersion == true | |
build_number = number_of_commits(all: true) | |
sh("flutter", "build", "ios", "--build-number=#{build_number}") | |
else # Just Increment Build Number | |
Dir.chdir "#{project_path}/ios" do | |
build_number = increment_build_number(xcodeproj: "#{project_path}/ios/Runner.xcodeproj") | |
end | |
sh("flutter", "build", "ios") | |
end | |
end | |
# beta_badge(hide: options[:release]) | |
build_ios_app(workspace: "#{project_path}/ios/Runner.xcworkspace", scheme: "Runner") | |
end | |
desc "Push a new beta build to TestFlight" | |
lane :beta do | |
prepare(release: false) | |
# crashlytics( | |
# crashlytics_path: "#{project_path}/ios/Pods/Crashlytics/", | |
# api_token: crashlytics_api_key, | |
# build_secret: crashlytics_build_secret, | |
# ipa_path: "#{project_path}/Runner.ipa", | |
# notes: changelog_from_git_commits, | |
# ) | |
upload_to_testflight( | |
skip_waiting_for_build_processing: true, | |
ipa: "#{project_path}/Runner.ipa", | |
username: username, | |
changelog: changelog_from_git_commits, | |
) | |
# slack( | |
# message: "#{app_name}: iOS sent to beta", | |
# slack_url: slack_url, | |
# ) | |
add_git_tag(build_number: build_number) | |
end | |
desc "Push a new release build to the App Store" | |
lane :release do | |
prepare(release: true) | |
upload_to_app_store( | |
submit_for_review: true, | |
automatic_release: true, | |
skip_screenshots: true, | |
force: true, | |
ipa: "#{project_path}/Runner.ipa", | |
username: username, | |
) | |
# slack( | |
# message: "#{app_name} (#{build_number}): iOS sent to production", | |
# slack_url: slack_url, | |
# ) | |
add_git_tag(build_number: build_number) | |
end | |
end |
Ahh -- how would one actually use this .. I also have a fastlane (that works) under the iOS and android folders. But I'd like to have a higher level one at the top level .. but a "fastlane init" complains there is no iOS project found, etc. etc. I'd also like a Gemfile etc. to make sure it's all included ??
I have the same question.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uncomment what you need. i.e. Slack, Crashlytics...