Skip to content

Instantly share code, notes, and snippets.

@indranil32
Created February 15, 2020 09:41
Show Gist options
  • Save indranil32/b5d60c83630cee7a7355b1696c93a4d0 to your computer and use it in GitHub Desktop.
Save indranil32/b5d60c83630cee7a7355b1696c93a4d0 to your computer and use it in GitHub Desktop.
# 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
#ensure_git_status_clean
#ENV["VERSION_CODE"]
#ENV["SLACK_URL"]
end
desc "Local Build"
lane :adhoc do
gradle(task: "clean assembleRelease")
# upload_to_play_store(track: 'beta')
#crashlytics
# sh "your_script.sh"
# You can also use other beta testing services here
slack(message: "ANDROID: Successfully built a new adhoc build", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
desc "Submit a new internal Build to Play console"
lane :internal do
increment_version_code(gradle_file_path: "app/build.gradle", version_code: ENV["VERSION_CODE"].to_i)
gradle(task: "clean assembleRelease")
upload_to_play_store(track: 'internal')
#crashlytics
# sh "your_script.sh"
# You can also use other beta testing services here
slack(message: "ANDROID: Successfully built a new internal build and pushed it to Play console internal track", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
desc "Submit a new Beta Build to Play console Beta"
lane :beta do
increment_version_code(gradle_file_path: "app/build.gradle", version_code: ENV["VERSION_CODE"].to_i)
gradle(task: "clean assembleRelease")
upload_to_play_store(track: 'beta')
#crashlytics
# sh "your_script.sh"
# You can also use other beta testing services here
slack(message: "ANDROID: Successfully built a new beta build and pushed it to Play console beta track", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
desc "Deploy a new version to the Google Play"
lane :release do
increment_version_code(gradle_file_path: "app/build.gradle", version_code: ENV["VERSION_CODE"].to_i)
# Commit the version bump
#commit_version_bump(xcodeproj: "MyApp.xcodeproj")
# Add a git tag for this build. This will automatically
# use an appropriate git tag name
#add_git_tag
# Push the new commit and tag back to your git remote
#push_to_git_remote
gradle(task: "clean assembleRelease")
upload_to_play_store
slack(message: "ANDROID: Successfully built a new release build and pushed to production", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
after_all do |lane|
# This lane is called, only if the executed lane was successful
end
# This lane is called, in case of error
error do |lane, exception|
slack(message: exception.message, success: false, channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
end
platform :ios do
before_all do
#ensure_git_status_clean
#ENV["SLACK_URL"]
ENV["FASTLANE_SESSION"] = retrieve_fastlane_session
#puts ENV["FASTLANE_SESSION"]
end
desc "Generate a local build"
lane :adhoc do
sync_code_signing(type: "adhoc", app_identifier: "com.navis.appointments", readonly: true)
build_app(workspace: "MyApp.xcworkspace", scheme: "MyApp", configuration: "Debug", export_method: "ad-hoc")
slack(message: "IOS: Successfully built a new adhoc build", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
lane :internal do
sync_code_signing(type: "development", app_identifier: "com.navis.appointments", readonly: true)
# Increment the build number (not the version number)
# Providing the xcodeproj is optional
increment_build_number(xcodeproj: "MyApp.xcodeproj")
build_app(workspace: "MyApp.xcworkspace", scheme: "MyApp", configuration: "Debug", export_method: "development")
#upload_to_testflight
slack(message: "IOS: Successfully built a new internal build", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
desc "Push a new beta build to TestFlight"
lane :beta do
sync_code_signing(type: "appstore", app_identifier: "com.navis.appointments", readonly: true)
# Increment the build number (not the version number)
# Providing the xcodeproj is optional
increment_build_number(xcodeproj: "MyApp.xcodeproj")
build_app(workspace: "MyApp.xcworkspace", scheme: "MyApp", configuration: "Release", export_method: "app-store")
upload_to_testflight
slack(message: "IOS: Successfully distributed a new beta build", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
desc "Push to App store and for review"
lane :release do
sync_code_signing(type: "appstore", app_identifier: "com.navis.appointments", readonly: true) # see code signing guide for more information
# Increment the build number (not the version number)
# Providing the xcodeproj is optional
increment_build_number(xcodeproj: "MyApp.xcodeproj")
# Commit the version bump
#commit_version_bump(xcodeproj: "MyApp.xcodeproj")
# Add a git tag for this build. This will automatically
# use an appropriate git tag name
#add_git_tag
# Push the new commit and tag back to your git remote
#push_to_git_remote
build_app(workspace: "MyApp.xcworkspace", scheme: "MyApp", configuration: "Release", export_method: "app-store")
upload_to_app_store # upload your app to App Store Connect --submit-for-review
slack(message: "IOS: Successfully uploaded a new App Store build", channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
private_lane :retrieve_fastlane_session do
# runs shell
spaceauth_output = `bundle exec fastlane spaceauth`
# regex the output for the value we need
fastlane_session_regex = %r{Pass the following via the FASTLANE_SESSION environment variable:\n(?<session>.+)\n\n\nExample:\n.+}
new_session = nil
if match = spaceauth_output.match(fastlane_session_regex)
# Strip out the fancy formatting
new_session = match[:session].gsub("\e[4m\e[36m", "").gsub("\e[0m\e[0m", "")
end
# Yell and quit if unable to parse out session from spaceauth output
if new_session.nil?
puts "Unable to obtain new session via fastlane spaceauth"
exit 1
else
new_session
end
end
after_all do |lane|
# This lane is called, only if the executed lane was successful
end
# This lane is called, in case of error
error do |lane, exception|
slack(message: exception.message, success: false, channel:"#bitrise_build", payload: { "Build Date" => Time.new.to_s, "Built by" => "Bitrise+Fastlane"})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment