Skip to content

Instantly share code, notes, and snippets.

View shafayathossain's full-sized avatar

Shafayat Hossain shafayathossain

  • Dhaka, Bangladesh
View GitHub Profile
@shafayathossain
shafayathossain / fastfile before_all.rb
Last active December 1, 2021 17:02
`before_all` block of fastfile
fastlane_require "dotenv"
PACKAGE_NAME = "<package name here>"
FIREBASE_APP_ID = "<firebase app id here>"
KEYSTORE_PATH = nil
FIREBASE_KEY_PATH = nil
PLAYSTORE_KEY_PATH = nil
BUNDLE_FILE_PATH = nil
UPDATED_VERSION_CODE = nil
before_all do
Dotenv.overload ".env.secret"
@shafayathossain
shafayathossain / Fastfile increment_version_code_in_project_gradle.rb
Created December 1, 2021 17:01
Responsible for fetching version code from play console and incrementing version code.
desc "Responsible for fetching version code from play console and incrementing version code."
lane :increment_version_code_in_project_gradle do
version_code_from_play_store_strings = google_play_track_version_codes(
package_name: PACKAGE_NAME, # PACKAGE_NAME is a global variable defined earlier
track: "production", # this can be alpha, beta etc.
json_key: PLAYSTORE_KEY_PATH,
)
version_code_from_play_store = version_code_from_play_store_strings[0].to_i
UPDATED_VERSION_CODE = version_code_from_play_store + 1
increment_version_code(
desc "Run unit tests."
lane :run_unit_tests do
gradle(
task: "test"
)
end
@shafayathossain
shafayathossain / Fastfile build.rb
Created December 1, 2021 17:06
Build the .aab file
desc "Build the .aab file"
lane :build do
gradle(
task: "bundle",
build_type: "Release",
properties: {
"android.injected.signing.store.file" => KEYSTORE_PATH,
"android.injected.signing.store.password" => ENV['KEYSTORE_PASSWORD'],
"android.injected.signing.key.alias" => ENV['KEYSTORE_ALIAS'],
"android.injected.signing.key.password" => ENV['KEYSTORE_PASSWORD']
@shafayathossain
shafayathossain / Fastfile distribute_to_firebase.rb
Created December 1, 2021 17:08
Responsible for uploading .aab to Firebase app distribution.
desc "Responsible for uploading .aab to Firebase app distribution."
lane :distribute_to_firebase do
firebase_app_distribution(
app: FIREBASE_APP_ID,
release_notes: "Uploaded from CI/CD",
android_artifact_type: "AAB",
android_artifact_path: BUNDLE_FILE_PATH,
service_credentials_file: FIREBASE_KEY_PATH,
groups: "tester-team"
)
@shafayathossain
shafayathossain / Fastfile distribute_playstore.rb
Created December 1, 2021 17:09
Responsible for uploading aab to playstore
desc "Responsible for uploading aab to playstore"
lane :distribute_playstore do
upload_to_play_store(
track: "production",
aab: BUNDLE_FILE_PATH,
json_key: PLAYSTORE_KEY_PATH,
package_name: PACKAGE_NAME
)
end
@shafayathossain
shafayathossain / Fastfile after_all.rb
Created December 1, 2021 17:10
After successful execution of all task, this block is called
desc "After successful execution of all task, this block is called"
after_all do
git_add(path: "*")
git_commit(
path: "*",
message: "#" + UPDATED_VERSION_CODE + " released"
)
push_to_git_remote(
local_branch: buildConfigs.key(options[:buildConfig]),
remote: "origin",
@shafayathossain
shafayathossain / Fastfile build_and_distribute.rb
Created December 1, 2021 17:13
Responsible for test, build and upload bundle to firebase app distribution and playstore by calling other private lanes.
desc "Responsible for testing, building and uploading bundle to firebase app distribution and playstore by calling other private lanes."
lane build_and_distribute:
increment_version_code_in_project_gradle()
run_unit_tests()
build()
distribute_to_firebase()
distribute_playstore()
end
@shafayathossain
shafayathossain / Fastfile
Created December 1, 2021 17:17
Final fastfile for integrating continuous delivery using fastlane
fastlane_require "dotenv"
PACKAGE_NAME = "<package name here>"
FIREBASE_APP_ID = "<firebase app id here>"
KEYSTORE_PATH = nil
FIREBASE_KEY_PATH = nil
PLAYSTORE_KEY_PATH = nil
BUNDLE_FILE_PATH = nil
UPDATED_VERSION_CODE = nil
@shafayathossain
shafayathossain / Base Structure of Workflow File.yml
Created December 3, 2021 04:02
Base structure of a github workflow file.
name: CI workflow
# Events when the workflow will dispatch/run.
on: push
jobs:
# Define jobs and their steps that will be executed.
deploy:
steps:
# Define steps to complete the current job.