What is Fastlane? It\'s a ci/cd tool that\'s based on ruby and I think I
like it as much as Bitrise. This isn\'t a Bitrise replacement at all.
You can use them together and there is 1 reason why\...Incrementing the
app version number. Let\'s just talk about it all so I can get this
excitement out and explain the why.
Why did I use Fastlane?
-----------------------
I just wanted to try a pure Fastlane ci/cd setup. I have seen it in a
lot of setups but I didn\'t have it in any of mine so when the chance
came up for Pet Log I took it.
I thought Bitrise was your fav
------------------------------
I LOVE Bitrise for sure, BUT there is nothing wrong with playing with
what works for you. I think an ideal setup would be Bitrise and Fastlane
together. Let Bitrise handle all the testing and deploying and then use
fastlane to increment the version code. Bitrise can override the version
code before deploying your app which is cool, but it\'s cooler if you
can actually see that change in your local changes.
I\'m not sure if Fastlane allows you to also set the version to file
because it wasn\'t important at the time. I want to just end this saying
s/o to whoever wrote the plugin to make this work. Your such a blessing.
Do you need to learn ruby?
--------------------------
Not at all. If you know me I\'m always complaining about people\'s
documentation. The documentation for Fastlane is so good that you can
copy and paste. Don\'t even stress yourself past that.
Does this work for Android and iOS?
-----------------------------------
Yes, Fastlane works for both platforms. It even works for hybrid
projects(stares in React Native). I will post my Fastfile below for
Android.
Is this automated if there is still manual steps?
-------------------------------------------------
Yes and no. Yes it automates portions (testing and deploying), but to
get things going you do have to run a manual command. If you want to go
full automation based on commits and/or tags then you suggest Bitrise or
Github Actions. I don\'t want to tell you which one to pick here so go
with whatever floats your boat.
Where is the file???
--------------------
default_platform(:android)
platform :android do
desc "Runs all the tests"
lane :test do
gradle(task: "test")
end
desc "Build local release"
lane :local do
gradle(task: 'bundle', build_type: 'Release')
end
desc "Deploy a new version to Alpha Track"
lane :alpha do
gradle(
task: 'bundle',
build_type: 'Release',
properties: {
"android.injected.signing.store.file" => "KEYSTORE.jks",
"android.injected.signing.store.password" => "PASSWORD",
"android.injected.signing.key.alias" => "ALIAS",
"android.injected.signing.key.password" => "PASSWORD",
}
)
upload_to_play_store(track: 'alpha')
increment_version_code(gradle_file_path: "./app/build.gradle")
end
desc "Deploy a new version to Beta Track"
lane :beta do
gradle(
task: 'bundle',
build_type: 'Release',
properties: {
"android.injected.signing.store.file" => "KEYSTORE.jks",
"android.injected.signing.store.password" => "PASSWORD",
"android.injected.signing.key.alias" => "ALIAS",
"android.injected.signing.key.password" => "PASSWORD",
}
)
upload_to_play_store(track: 'beta')
increment_version_code(gradle_file_path: "./app/build.gradle")
end
desc "Deploy a new version to the Google Play"
lane :deploy do
gradle(
task: "clean bundleRelease",
properties: {
"android.injected.signing.store.file" => "KEYSTORE.jks",
"android.injected.signing.store.password" => "PASSWORD",
"android.injected.signing.key.alias" => "ALIAS",
"android.injected.signing.key.password" => "PASSWORD",
}
)
upload_to_play_store
increment_version_code(gradle_file_path: "./app/build.gradle")
end
end
Fastfile
TLDR Me
-------
Fastlane is a good local ci/cd tool to have in your toolbox as a mobile
developer because it can automate test, deployments, and directly
updates the app version in code. You can download Fastlane from
[here](https://docs.fastlane.tools/getting-started/android/setup/), and
use the snippet of my Android workflow above so you don\'t have to read
the docs or a full quickstart. For \"full\" automation I suggest you use
Bitrise or Github Actions to call your Fastlane file.