Created
July 11, 2018 19:53
-
-
Save RubenSandwich/e1d93cddb97c2814dbb2baa68a19658f to your computer and use it in GitHub Desktop.
Fastlane File
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
fastlane_version "2.81.0" | |
# Project Variables | |
MATCH_GIT_URL = "Match Git URL" | |
ios_project = { | |
"name" => "App Name", | |
"bundleID" => "App Bundle ID", | |
} | |
android_project = { | |
"packageName" => "App Package Name", | |
} | |
def update_android_build_number(version_code) | |
path = '../android/app/build.gradle' | |
re = /versionCode\s+(\d+)/ | |
s = File.read(path) | |
s[re, 1] = version_code.to_s | |
f = File.new(path, 'w') | |
f.write(s) | |
f.close | |
end | |
# Otherwise the lane prints everytime is_ci? is called | |
ci_server = is_ci? | |
platform :ios do | |
desc "Download and deencrypt the required keys to sign the app. Provides the option 'release' to download the release keys, e.g. 'bundle exec fastlane sign release:true', sign defaults to development keys." | |
lane :sign do |options| | |
MATCH_KEYCHAIN_NAME = "travisKeychain" | |
MATCH_KEYCHAIN_PASSWORD = ci_server ? ENV["MATCH_PASSWORD"] : nil | |
if ci_server | |
create_keychain( | |
name: MATCH_KEYCHAIN_NAME, | |
password: MATCH_KEYCHAIN_PASSWORD, | |
default_keychain: true, | |
unlock: true, | |
timeout: 3600, | |
add_to_search_list: true, | |
) | |
end | |
sign_for_release = ci_server || options[:release] | |
match( | |
git_url: MATCH_GIT_URL, | |
app_identifier: [ios_project["bundleID"]], | |
type: sign_for_release ? "appstore" : "development", | |
shallow_clone: sign_for_release, | |
readonly: sign_for_release, | |
force_for_new_devices: !sign_for_release, | |
keychain_name: ci_server ? MATCH_KEYCHAIN_NAME : nil, | |
keychain_password: ci_server ? MATCH_KEYCHAIN_PASSWORD : nil, | |
) | |
end | |
desc "Build the app" | |
lane :build do | |
gym( | |
project: "./ios/#{ios_project["name"]}.xcodeproj", | |
scheme: ios_project["name"], | |
) | |
end | |
desc "Sign the app and push a build onto testflight" | |
lane :deploy do | |
build_number = prompt( | |
text: "Enter build number: ", | |
ci_input: ENV["TRAVIS_BUILD_NUMBER"], | |
) | |
increment_build_number( | |
xcodeproj: "./ios/#{ios_project["name"]}.xcodeproj", | |
build_number: build_number, | |
) | |
sign(release: true) | |
gym( | |
project: "./ios/#{ios_project["name"]}.xcodeproj", | |
scheme: ios_project["name"], | |
) | |
testflight( | |
app_identifier: ios_project["bundleID"], | |
ipa: "./#{ios_project["name"]}.ipa", | |
skip_waiting_for_build_processing: true, | |
) | |
end | |
end | |
platform :android do | |
desc "Build the app" | |
lane :build do | |
gradle( | |
task: "assemble", | |
build_type: "Release", | |
project_dir: "./android/", | |
) | |
end | |
desc "Deploy a new version to Google Play" | |
lane :deploy do | |
build_number = prompt( | |
text: "Enter build number: ", | |
ci_input: ENV["TRAVIS_BUILD_NUMBER"], | |
) | |
update_android_build_number( | |
build_number, | |
) | |
gradle( | |
task: "assemble", | |
build_type: "Release", | |
project_dir: "./android/", | |
) | |
apk_loc = "../android/app/build/outputs/apk/release/app-release.apk" | |
json_key_loc = "./android/keys/Google_Play_Android_Developer_Key.json" | |
supply( | |
package_name: android_project["package_name"], | |
apk: File.absolute_path(apk_loc), | |
track: "beta", | |
skip_upload_metadata: true, | |
skip_upload_images: true, | |
skip_upload_screenshots: true, | |
json_key: json_key_loc, | |
) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This fast file assumes you have the following variable defined for your CI/CD environment:
This is the password you used for signing your certs in your match repo.
It also assumes that you store a Google Developers Service Account key at:
(Relative to the react native directory project directory.)
See the supply documentation on generating this key: https://docs.fastlane.tools/actions/supply/#setup