2018-03-26 10:56:25 +00:00
|
|
|
# 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
|
|
|
|
#
|
2018-09-21 11:57:06 +00:00
|
|
|
# Fastlane is updated quite frequently with security patches
|
|
|
|
# update_fastlane
|
2018-03-26 10:56:25 +00:00
|
|
|
|
2018-08-13 11:40:24 +00:00
|
|
|
# There are a few env variables defined in the .env file in
|
|
|
|
# this directory (fastlane/.env)
|
|
|
|
|
|
|
|
|
|
|
|
# unlocks keychain if KEYCHAIN_PASSWORD variable is present
|
|
|
|
# (to be used on CI machines)
|
|
|
|
def unlock_keychain_if_needed
|
|
|
|
if ENV["KEYCHAIN_PASSWORD"]
|
|
|
|
unlock_keychain(
|
2018-08-17 09:14:11 +00:00
|
|
|
path:"login.keychain",
|
2018-08-14 09:31:11 +00:00
|
|
|
password:ENV["KEYCHAIN_PASSWORD"],
|
2018-08-13 11:40:24 +00:00
|
|
|
set_default: true)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-03-22 10:22:37 +00:00
|
|
|
def curl_upload(url, file, user, conn_timeout=5, timeout=60, retries=3)
|
|
|
|
begin
|
|
|
|
return sh(
|
|
|
|
"curl",
|
|
|
|
"--fail",
|
|
|
|
"--silent",
|
|
|
|
"--user", user,
|
|
|
|
"--request", "POST",
|
|
|
|
"--header", "Content-Type: application/octet-stream",
|
|
|
|
"--data-binary", "@../#{file}", # `fastlane` is the cwd so we go one folder up
|
|
|
|
# we retry few times if upload doesn't succeed in sensible time
|
|
|
|
"--retry-connrefused", # consider ECONNREFUSED as error too retry
|
|
|
|
"--connect-timeout", conn_timeout.to_s, # max time in sec. for establishing connection
|
|
|
|
"--max-time", timeout.to_s, # max time in sec. for whole transfer to take
|
|
|
|
"--retry", retries.to_s, # number of retries to attempt
|
|
|
|
"--retry-max-time", timeout.to_s, # same as --max-time but for retries
|
|
|
|
"--retry-delay", "0", # an exponential backoff algorithm in sec.
|
|
|
|
url
|
|
|
|
)
|
|
|
|
rescue => error
|
|
|
|
UI.error "Error: #{error}"
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def retry_curl_upload(url, file, user, conn_timeout=5, timeout=60, retries=3)
|
|
|
|
# since curl doesn't retry on connection and operation timeouts we roll our own
|
|
|
|
try = 0
|
|
|
|
begin
|
|
|
|
return curl_upload(url, file, user, conn_timeout, timeout, retries)
|
|
|
|
rescue => error
|
|
|
|
try += 1
|
|
|
|
if try <= retries
|
|
|
|
UI.important "Warning: Retrying cURL upload! (attempt #{try}/#{retries})"
|
|
|
|
retry
|
|
|
|
else
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-08-13 11:40:24 +00:00
|
|
|
|
2018-08-14 16:24:48 +00:00
|
|
|
# uploads `file` to sauce labs (overwrites if there is anoter file from the
|
|
|
|
# same commit)
|
|
|
|
def upload_to_saucelabs(file)
|
|
|
|
key = ENV["SAUCE_ACCESS_KEY"]
|
2018-11-19 17:37:04 +00:00
|
|
|
username = ENV["SAUCE_USERNAME"]
|
|
|
|
unique_name = ENV["SAUCE_LABS_NAME"]
|
2018-08-14 16:24:48 +00:00
|
|
|
|
2019-03-07 09:19:24 +00:00
|
|
|
url = "https://saucelabs.com/rest/v1/storage/#{username}/#{unique_name}?overwrite=true"
|
2018-08-14 16:24:48 +00:00
|
|
|
|
2019-03-22 10:22:37 +00:00
|
|
|
upload_result = retry_curl_upload(url, file, "#{username}:#{key}")
|
2018-08-14 16:24:48 +00:00
|
|
|
|
|
|
|
# fail the lane if upload fails
|
|
|
|
UI.user_error!(
|
2019-03-22 10:22:37 +00:00
|
|
|
"failed to upload file to saucelabs despite retries: #{upload_result}"
|
2018-08-14 16:24:48 +00:00
|
|
|
) unless upload_result.include? "filename"
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2018-08-17 09:14:11 +00:00
|
|
|
# builds an ios app with ad-hoc configuration and put it
|
2018-08-13 11:40:24 +00:00
|
|
|
# to "status-adhoc" output folder
|
2018-10-24 08:18:56 +00:00
|
|
|
# `readonly`:
|
|
|
|
# if true - only fetch existing certificates and profiles, don't upgrade from AppStoreConnect
|
|
|
|
# if false - read list of devices from AppStoreConnect, and upgrade the provisioning profiles from it
|
|
|
|
def build_ios_adhoc(readonly)
|
2018-08-13 11:40:24 +00:00
|
|
|
match(
|
|
|
|
type: "adhoc",
|
|
|
|
force_for_new_devices: true,
|
2018-10-24 08:18:56 +00:00
|
|
|
readonly: readonly,
|
2018-08-13 11:40:24 +00:00
|
|
|
keychain_name: "login.keychain"
|
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
|
2018-08-13 11:40:24 +00:00
|
|
|
build_ios_app(
|
|
|
|
scheme: "StatusIm",
|
|
|
|
workspace: "ios/StatusIm.xcworkspace",
|
|
|
|
configuration: "Release",
|
|
|
|
clean: true,
|
|
|
|
export_method: "ad-hoc",
|
2019-03-01 01:17:39 +00:00
|
|
|
# Temporary fix for Xcode 10.1
|
|
|
|
xcargs: "-UseModernBuildSystem=N",
|
2019-03-25 16:35:01 +00:00
|
|
|
output_directory: "status-adhoc",
|
|
|
|
export_options: {
|
|
|
|
"UseModernBuildSystem": "N"
|
|
|
|
}
|
2018-08-13 11:40:24 +00:00
|
|
|
)
|
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
|
2018-11-19 17:37:04 +00:00
|
|
|
# builds an ios app with e2e configuration and put it
|
|
|
|
# to "status-e2e" output folder
|
|
|
|
def build_ios_e2e
|
|
|
|
|
|
|
|
# determine a simulator SDK installed
|
|
|
|
showsdks_output = sh('xcodebuild', '-showsdks')
|
|
|
|
simulator_sdk = showsdks_output.scan(/iphonesimulator\d\d?\.\d\d?/).first
|
|
|
|
|
|
|
|
match(
|
|
|
|
type: "adhoc",
|
|
|
|
force_for_new_devices: true,
|
|
|
|
readonly: true,
|
|
|
|
keychain_name: "login.keychain"
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
build_ios_app(
|
|
|
|
# Creating a build for the iOS Simulator
|
|
|
|
# 1. https://medium.com/rocket-fuel/fastlane-to-the-simulator-87549b2601b9
|
|
|
|
sdk: simulator_sdk,
|
|
|
|
destination: "generic/platform=iOS Simulator",
|
|
|
|
# 2. fixing compilations issues as stated in https://stackoverflow.com/a/20505258
|
|
|
|
# it looks like i386 isn't supported by React Native
|
2019-03-25 16:35:01 +00:00
|
|
|
# UseModernBuildSystem: Temporary fix for Xcode 10.1
|
|
|
|
xcargs: "ARCHS=\"x86_64\" ONLY_ACTIVE_ARCH=NO -UseModernBuildSystem=N",
|
2018-11-19 17:37:04 +00:00
|
|
|
# 3. directory where to up StatusIm.app
|
|
|
|
derived_data_path: "status-e2e",
|
|
|
|
output_name: "StatusIm.app",
|
|
|
|
# -------------------------------------
|
|
|
|
# Normal stuff
|
|
|
|
scheme: "StatusIm",
|
|
|
|
workspace: "ios/StatusIm.xcworkspace",
|
|
|
|
configuration: "Release",
|
|
|
|
# Simulator apps can't be archived...
|
|
|
|
skip_archive: true,
|
|
|
|
# ...and we don't need an .ipa file for them, because we use .app directly
|
2019-03-25 16:35:01 +00:00
|
|
|
skip_package_ipa: true,
|
|
|
|
export_options: {
|
|
|
|
"UseModernBuildSystem": "N"
|
|
|
|
}
|
2018-11-19 17:37:04 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
zip(
|
|
|
|
path: "status-e2e/Build/Products/Release-iphonesimulator/StatusIm.app",
|
|
|
|
output_path: "status-e2e/StatusIm.app.zip",
|
|
|
|
verbose: false,
|
|
|
|
)
|
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
|
2018-08-27 15:32:54 +00:00
|
|
|
def upload_to_diawi(source)
|
2018-08-14 08:42:57 +00:00
|
|
|
diawi(
|
2019-04-24 14:30:37 +00:00
|
|
|
file: source,
|
|
|
|
last_hope_attempts_count: 3,
|
|
|
|
token: ENV["DIAWI_TOKEN"]
|
2018-08-14 08:42:57 +00:00
|
|
|
)
|
2019-04-24 14:30:37 +00:00
|
|
|
# save the URL to a file for use in CI
|
2018-08-15 06:15:45 +00:00
|
|
|
File.write("diawi.out", lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI])
|
2018-08-27 15:32:54 +00:00
|
|
|
end
|
|
|
|
|
2018-08-14 08:42:57 +00:00
|
|
|
|
2018-03-26 10:56:25 +00:00
|
|
|
platform :ios do
|
2018-08-13 11:40:24 +00:00
|
|
|
desc "`fastlane ios adhoc` - ad-hoc lane for iOS."
|
2018-11-19 17:37:04 +00:00
|
|
|
desc "This lane is used for PRs, Releases, etc."
|
2018-08-13 11:40:24 +00:00
|
|
|
desc "It creates an .ipa that can be used by a list of devices, registeded in the App Store Connect."
|
|
|
|
desc "This .ipa is ready to be distibuted through diawi.com"
|
|
|
|
lane :adhoc do
|
|
|
|
unlock_keychain_if_needed
|
2018-10-24 08:18:56 +00:00
|
|
|
build_ios_adhoc(true)
|
2018-08-13 11:40:24 +00:00
|
|
|
end
|
|
|
|
|
2018-11-19 17:37:04 +00:00
|
|
|
desc "`fastlane ios e2e` - e2e lane for iOS."
|
|
|
|
desc "This lane is used for SauceLabs end-to-end testing."
|
|
|
|
desc "It creates an .app that can be used inside of a iPhone simulator."
|
|
|
|
lane :e2e do
|
|
|
|
unlock_keychain_if_needed
|
|
|
|
build_ios_e2e
|
|
|
|
end
|
|
|
|
|
2018-08-29 07:43:21 +00:00
|
|
|
desc "`fastlane ios pr` - makes a new pr build"
|
|
|
|
desc "This lane builds a new adhoc build and leaves an .ipa that is ad-hoc signed (can be uploaded to diawi)"
|
|
|
|
lane :pr do
|
2018-10-24 08:18:56 +00:00
|
|
|
unlock_keychain_if_needed
|
2019-04-02 16:41:33 +00:00
|
|
|
build_ios_adhoc(false)
|
2018-08-29 07:43:21 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "`fastlane ios nightly` - makes a new nightly"
|
2018-08-21 15:17:25 +00:00
|
|
|
desc "This lane builds a new nightly and leaves an .ipa that is ad-hoc signed (can be uploaded to diawi)"
|
2018-03-26 10:56:25 +00:00
|
|
|
lane :nightly do
|
2018-10-24 08:18:56 +00:00
|
|
|
unlock_keychain_if_needed
|
2019-04-02 16:41:33 +00:00
|
|
|
build_ios_adhoc(false)
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|
2018-08-13 11:40:24 +00:00
|
|
|
|
|
|
|
desc "`fastlane ios release` builds a release & uploads it to TestFlight"
|
2018-04-04 16:36:26 +00:00
|
|
|
lane :release do
|
2018-08-13 11:40:24 +00:00
|
|
|
match(
|
|
|
|
type: "appstore",
|
|
|
|
readonly: true,
|
|
|
|
keychain_name: "login.keychain"
|
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
|
2018-08-13 11:40:24 +00:00
|
|
|
build_ios_app(
|
|
|
|
scheme: "StatusIm",
|
|
|
|
workspace: "ios/StatusIm.xcworkspace",
|
|
|
|
configuration: "Release",
|
|
|
|
clean: true,
|
|
|
|
export_method: "app-store",
|
|
|
|
output_directory: "status_appstore",
|
2019-03-01 01:17:39 +00:00
|
|
|
# Temporary fix for Xcode 10.1
|
|
|
|
xcargs: "-UseModernBuildSystem=N",
|
2018-08-13 11:40:24 +00:00
|
|
|
export_options: {
|
2019-02-05 09:35:14 +00:00
|
|
|
"UseModernBuildSystem": "N",
|
2018-08-13 11:40:24 +00:00
|
|
|
"combileBitcode": true,
|
|
|
|
"uploadBitcode": false,
|
|
|
|
"ITSAppUsesNonExemptEncryption": false
|
|
|
|
}
|
|
|
|
)
|
2018-04-04 16:36:26 +00:00
|
|
|
upload_to_testflight(
|
2018-08-14 09:31:11 +00:00
|
|
|
ipa: "status_appstore/StatusIm.ipa"
|
|
|
|
)
|
2018-04-04 16:36:26 +00:00
|
|
|
end
|
2018-08-13 11:40:24 +00:00
|
|
|
|
|
|
|
desc "`fastlane ios clean` - remove inactive TestFlight users"
|
|
|
|
desc "uses custom plugin, installed via"
|
|
|
|
desc "`sudo get install fastlane-plugin-clean_testflight_testers`"
|
2018-03-28 09:15:16 +00:00
|
|
|
lane :clean do
|
2019-04-02 16:41:33 +00:00
|
|
|
clean_testflight_testers(username: ENV["FASTLANE_APPLE_ID"])
|
2018-03-28 09:15:16 +00:00
|
|
|
end
|
2018-08-14 08:42:57 +00:00
|
|
|
|
|
|
|
desc "`fastlane ios upload-diawi` - upload .ipa to diawi"
|
|
|
|
desc "expects to have an .ipa prepared: `status-adhoc/StatusIm.ipa`"
|
|
|
|
desc "expects to have a diawi token as DIAWI_TOKEN env variable"
|
|
|
|
desc "expects to have a github token as GITHUB_TOKEN env variable"
|
|
|
|
desc "will fails if file isn't there"
|
2018-08-15 06:15:45 +00:00
|
|
|
desc "---"
|
|
|
|
desc "Output: writes `fastlane/diawi.out` file url of the uploded file"
|
2018-08-14 08:42:57 +00:00
|
|
|
lane :upload_diawi do
|
2019-03-06 17:29:32 +00:00
|
|
|
ipa = ENV["DIAWI_IPA"] || "status-adhoc/StatusIm.ipa"
|
|
|
|
upload_to_diawi(ipa)
|
2018-08-14 08:42:57 +00:00
|
|
|
end
|
2018-08-15 06:15:45 +00:00
|
|
|
|
2018-11-19 17:37:04 +00:00
|
|
|
desc "`fastlane ios saucelabs` - upload .app to sauce labs"
|
|
|
|
desc "also notifies in a GitHub comments"
|
|
|
|
desc "expects to have an .apk prepared: `android/app/build/outputs/apk/release/app-release.apk`"
|
|
|
|
desc "expects to have a saucelabs access key as SAUCE_ACCESS_KEY env variable"
|
|
|
|
desc "expects to have a saucelabs username token as SAUCE_USERNAME env variable"
|
|
|
|
desc "expects to have a saucelabs destination name as SAUCE_LABS_NAME env variable"
|
|
|
|
desc "will fails if file isn't there"
|
|
|
|
lane :saucelabs do
|
|
|
|
upload_to_saucelabs(
|
|
|
|
"status-e2e/StatusIm.app.zip"
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-08-14 18:09:52 +00:00
|
|
|
desc "This fastlane step cleans up XCode DerivedData folder"
|
|
|
|
lane :cleanup do
|
|
|
|
clear_derived_data
|
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
platform :android do
|
2019-02-11 21:24:36 +00:00
|
|
|
# Optional env variables
|
|
|
|
APK_PATH = ENV["APK_PATH"] || "android/app/build/outputs/apk/release/app-release.apk"
|
|
|
|
|
2018-03-26 10:56:25 +00:00
|
|
|
desc "Deploy a new internal build to Google Play"
|
2018-08-14 09:31:11 +00:00
|
|
|
desc "expects GOOGLE_PLAY_JSON_KEY environment variable"
|
2018-03-26 10:56:25 +00:00
|
|
|
lane :nightly do
|
|
|
|
upload_to_play_store(
|
|
|
|
track: "internal",
|
2019-02-11 21:24:36 +00:00
|
|
|
apk: APK_PATH,
|
2018-08-14 09:31:11 +00:00
|
|
|
json_key_data: ENV["GOOGLE_PLAY_JSON_KEY"]
|
|
|
|
)
|
|
|
|
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|
2018-09-21 09:21:36 +00:00
|
|
|
|
|
|
|
desc "Deploy a new alpha (public) build to Google Play"
|
|
|
|
desc "expects GOOGLE_PLAY_JSON_KEY environment variable"
|
2018-04-04 16:36:26 +00:00
|
|
|
lane :release do
|
|
|
|
upload_to_play_store(
|
|
|
|
track: "alpha",
|
2019-02-11 21:24:36 +00:00
|
|
|
apk: APK_PATH,
|
2018-08-14 09:31:11 +00:00
|
|
|
json_key_data: ENV["GOOGLE_PLAY_JSON_KEY"]
|
|
|
|
)
|
2018-04-04 16:36:26 +00:00
|
|
|
end
|
2018-08-14 08:42:57 +00:00
|
|
|
|
2018-09-21 09:21:36 +00:00
|
|
|
desc "Upload metadata to Google Play."
|
|
|
|
desc "Metadata is always updated when builds are uploaded,"
|
|
|
|
desc "but this action can update metadata without uploading a build."
|
|
|
|
desc "expects GOOGLE_PLAY_JSON_KEY environment variable"
|
|
|
|
lane :upload_metadata do
|
|
|
|
upload_to_play_store(
|
|
|
|
skip_upload_apk: true,
|
|
|
|
json_key_data: ENV["GOOGLE_PLAY_JSON_KEY"]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-08-14 16:24:48 +00:00
|
|
|
desc "`fastlane android upload_diawi` - upload .apk to diawi"
|
2018-08-14 08:42:57 +00:00
|
|
|
desc "expects to have an .apk prepared: `android/app/build/outputs/apk/release/app-release.apk`"
|
|
|
|
desc "expects to have a diawi token as DIAWI_TOKEN env variable"
|
|
|
|
desc "expects to have a github token as GITHUB_TOKEN env variable"
|
|
|
|
desc "will fails if file isn't there"
|
2018-08-15 06:15:45 +00:00
|
|
|
desc "---"
|
|
|
|
desc "Output: writes `fastlane/diawi.out` file url of the uploded file"
|
2018-08-14 08:42:57 +00:00
|
|
|
lane :upload_diawi do
|
2019-02-11 21:24:36 +00:00
|
|
|
upload_to_diawi(APK_PATH)
|
2018-08-14 08:42:57 +00:00
|
|
|
end
|
2018-08-14 16:24:48 +00:00
|
|
|
|
|
|
|
desc "`fastlane android saucelabs` - upload .apk to sauce labs"
|
|
|
|
desc "expects to have an .apk prepared: `android/app/build/outputs/apk/release/app-release.apk`"
|
|
|
|
desc "expects to have a saucelabs access key as SAUCE_ACCESS_KEY env variable"
|
|
|
|
desc "expects to have a saucelabs username token as SAUCE_USERNAME env variable"
|
2018-11-19 17:37:04 +00:00
|
|
|
desc "expects to have a saucelabs destination name as SAUCE_LABS_NAME env variable"
|
2018-08-14 16:24:48 +00:00
|
|
|
desc "will fails if file isn't there"
|
|
|
|
lane :saucelabs do
|
2019-02-11 21:24:36 +00:00
|
|
|
upload_to_saucelabs(APK_PATH)
|
2018-08-14 16:24:48 +00:00
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|