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)
|
|
|
|
|
2019-09-21 09:44:03 +00:00
|
|
|
def curl_upload(url, file, auth, conn_timeout = 5, timeout = 60, retries = 3)
|
|
|
|
rval = sh(
|
|
|
|
'curl',
|
|
|
|
'--silent',
|
|
|
|
'--user', auth,
|
|
|
|
'--write-out', "\nHTTP_CODE:%{http_code}",
|
|
|
|
'--request', 'POST',
|
|
|
|
'--header', 'Content-Type: application/octet-stream',
|
|
|
|
# we retry few times if upload doesn't succeed in sensible time
|
|
|
|
'--retry-connrefused', # consider ECONNREFUSED as error too retry
|
|
|
|
'--data-binary', "@../#{file}", # `fastlane` is the cwd so we go one folder up
|
|
|
|
'--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
|
|
|
|
)
|
|
|
|
# We're not using --fail because it suppresses server response
|
|
|
|
raise "Error:\n#{rval}" unless rval.include? 'HTTP_CODE:200'
|
|
|
|
|
|
|
|
rval
|
2019-03-22 10:22:37 +00:00
|
|
|
end
|
|
|
|
|
2019-09-21 09:44:03 +00:00
|
|
|
def retry_curl_upload(url, file, auth, conn_timeout = 5, timeout = 60, retries = 3)
|
|
|
|
# since curl doesn't retry on connection and operation timeouts we roll our own
|
|
|
|
(1..retries).each do |try|
|
2019-03-22 10:22:37 +00:00
|
|
|
begin
|
2019-09-21 09:44:03 +00:00
|
|
|
return curl_upload(url, file, auth, conn_timeout, timeout, retries)
|
|
|
|
rescue StandardError => e
|
|
|
|
if try == retries
|
|
|
|
UI.error "Error:\n#{e}"
|
|
|
|
raise
|
|
|
|
end
|
|
|
|
UI.important "Warning: Retrying cURL upload! (attempt #{try}/#{retries})"
|
2019-03-22 10:22:37 +00:00
|
|
|
end
|
2019-09-21 09:44:03 +00:00
|
|
|
end
|
2019-03-22 10:22:37 +00:00
|
|
|
end
|
2018-08-13 11:40:24 +00:00
|
|
|
|
2020-11-09 23:48:31 +00:00
|
|
|
# Creates and unlocks a keychain into which Fastlane match imports signing keys and certs.
|
2020-10-27 12:18:10 +00:00
|
|
|
class Keychain
|
2020-11-09 23:48:31 +00:00
|
|
|
attr_accessor :name, :pass
|
2020-10-27 12:18:10 +00:00
|
|
|
|
|
|
|
def initialize(name)
|
2020-11-09 23:48:31 +00:00
|
|
|
# Local devs will not have KEYCHAIN_PASSWORD set, and will be prompted for password.
|
|
|
|
return "login.keychain-db" unless ENV['KEYCHAIN_PASSWORD']
|
|
|
|
# We user the same keychain every time because we need to set a default.
|
|
|
|
@name = "#{name}.keychain-db"
|
|
|
|
@pass = ENV['KEYCHAIN_PASSWORD']
|
2020-10-27 12:18:10 +00:00
|
|
|
Fastlane::Actions::CreateKeychainAction.run(
|
|
|
|
name: @name,
|
|
|
|
password: @pass,
|
|
|
|
unlock: true,
|
2020-11-09 23:48:31 +00:00
|
|
|
# Fastlane can't find the signing cert without setting a default.
|
|
|
|
default_keychain: true,
|
|
|
|
# Deleting the keychain would cause race condition for parallel jobs.
|
|
|
|
require_create: false,
|
2020-10-27 12:18:10 +00:00
|
|
|
# Lock it up after 25 minutes just in case we don't delete it.
|
2020-11-09 23:48:31 +00:00
|
|
|
lock_when_sleeps: true,
|
|
|
|
lock_after_timeout: true,
|
|
|
|
timeout: 1500
|
2020-10-27 12:18:10 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-02-04 12:00:56 +00:00
|
|
|
# App Store Connect API is an official public API used to manage Apps.
|
|
|
|
# This includes metadata, pricing and availability, provisioning, and more.
|
|
|
|
# It provides a JSON API and auth using API Keys to generate a JSON Web Token (JWT).
|
|
|
|
def asc_api_key()
|
|
|
|
app_store_connect_api_key(
|
|
|
|
key_id: ENV['FASTLANE_ASC_API_KEY_ID'],
|
|
|
|
issuer_id: ENV['FASTLANE_ASC_API_ISSUER_ID'],
|
|
|
|
key_filepath: ENV['FASTLANE_ASC_API_KEY_FILE_PATH'],
|
2021-04-07 21:28:18 +00:00
|
|
|
duration: 1200, # seconds, session length
|
2021-02-04 12:00:56 +00:00
|
|
|
in_house: false,
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2018-08-17 09:14:11 +00:00
|
|
|
# builds an ios app with ad-hoc configuration and put it
|
2020-07-08 14:08:51 +00:00
|
|
|
# to "status-ios" 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
|
2020-06-24 15:54:28 +00:00
|
|
|
# `pr_build`:
|
|
|
|
# if true - uses StatusImPR scheme and postfixed app id with `.pr` to build an app, which can be used in parallel with release
|
2021-08-06 08:19:47 +00:00
|
|
|
# if false - uses StatusIm scheme to build the release app
|
2020-06-24 15:54:28 +00:00
|
|
|
|
|
|
|
def build_ios_adhoc(readonly: false, pr_build: false)
|
|
|
|
# PR builds should appear as a separate App on iOS
|
|
|
|
scheme = pr_build ? 'StatusImPR' : 'StatusIm'
|
|
|
|
app_id = pr_build ? 'im.status.ethereum.pr' : 'im.status.ethereum'
|
|
|
|
|
2020-11-09 23:48:31 +00:00
|
|
|
kc = Keychain.new('fastlane')
|
2019-09-21 09:44:03 +00:00
|
|
|
|
2020-11-09 23:48:31 +00:00
|
|
|
match(
|
|
|
|
type: 'adhoc',
|
|
|
|
readonly: readonly,
|
2021-02-04 12:00:56 +00:00
|
|
|
api_key: asc_api_key(),
|
2020-11-09 23:48:31 +00:00
|
|
|
app_identifier: app_id,
|
|
|
|
force_for_new_devices: true,
|
|
|
|
keychain_name: kc.name,
|
|
|
|
keychain_password: kc.pass
|
|
|
|
)
|
|
|
|
|
|
|
|
build_ios_app(
|
|
|
|
scheme: scheme,
|
|
|
|
workspace: 'ios/StatusIm.xcworkspace',
|
|
|
|
configuration: 'Release',
|
|
|
|
clean: true,
|
|
|
|
export_method: 'ad-hoc',
|
|
|
|
output_name: 'StatusIm',
|
|
|
|
output_directory: 'status-ios',
|
2023-03-09 10:07:56 +00:00
|
|
|
buildlog_path: 'ios/logs',
|
2020-11-09 23:48:31 +00:00
|
|
|
export_options: {
|
|
|
|
signingStyle: 'manual',
|
|
|
|
provisioningProfiles: {
|
|
|
|
"im.status.ethereum": "match AdHoc im.status.ethereum",
|
|
|
|
"im.status.ethereum.pr": "match AdHoc im.status.ethereum.pr"
|
2020-06-24 15:54:28 +00:00
|
|
|
}
|
2020-11-09 23:48:31 +00:00
|
|
|
}
|
|
|
|
)
|
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
|
2020-07-08 14:08:51 +00:00
|
|
|
# to "status-ios" output folder
|
2018-11-19 17:37:04 +00:00
|
|
|
def build_ios_e2e
|
2019-09-21 09:44:03 +00:00
|
|
|
# determine a simulator SDK installed
|
|
|
|
showsdks_output = sh('xcodebuild', '-showsdks')
|
|
|
|
simulator_sdk = showsdks_output.scan(/iphonesimulator\d\d?\.\d\d?/).first
|
|
|
|
|
2020-11-09 23:48:31 +00:00
|
|
|
kc = Keychain.new('fastlane')
|
2019-09-21 09:44:03 +00:00
|
|
|
|
2020-11-09 23:48:31 +00:00
|
|
|
match(
|
|
|
|
type: 'adhoc',
|
|
|
|
readonly: true,
|
2021-02-04 12:00:56 +00:00
|
|
|
api_key: asc_api_key(),
|
2020-11-09 23:48:31 +00:00
|
|
|
force_for_new_devices: true,
|
|
|
|
keychain_name: kc.name,
|
|
|
|
keychain_password: kc.pass
|
|
|
|
)
|
|
|
|
|
|
|
|
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
|
|
|
|
xcargs: 'ARCHS="x86_64" ONLY_ACTIVE_ARCH=NO',
|
|
|
|
# 3. directory where to up StatusIm.app
|
|
|
|
derived_data_path: 'status-ios',
|
|
|
|
output_name: 'StatusIm.app',
|
2023-03-09 10:07:56 +00:00
|
|
|
buildlog_path: 'ios/logs',
|
2020-11-09 23:48:31 +00:00
|
|
|
# -------------------------------------
|
|
|
|
# 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
|
|
|
|
skip_package_ipa: true
|
|
|
|
)
|
2019-09-21 09:44:03 +00:00
|
|
|
|
|
|
|
zip(
|
2020-07-08 14:08:51 +00:00
|
|
|
path: 'status-ios/Build/Products/Release-iphonesimulator/StatusIm.app',
|
|
|
|
output_path: 'status-ios/StatusIm.app.zip',
|
2019-09-21 09:44:03 +00:00
|
|
|
verbose: false
|
|
|
|
)
|
2018-11-19 17:37:04 +00:00
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
|
|
|
|
platform :ios do
|
2019-09-21 09:44:03 +00:00
|
|
|
desc '`fastlane ios adhoc` - ad-hoc lane for iOS.'
|
|
|
|
desc 'This lane is used for PRs, Releases, etc.'
|
|
|
|
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'
|
2018-08-13 11:40:24 +00:00
|
|
|
lane :adhoc do
|
2020-06-24 15:54:28 +00:00
|
|
|
build_ios_adhoc(readonly: true)
|
2018-08-13 11:40:24 +00:00
|
|
|
end
|
|
|
|
|
2019-09-21 09:44:03 +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.'
|
2018-11-19 17:37:04 +00:00
|
|
|
lane :e2e do
|
|
|
|
build_ios_e2e
|
|
|
|
end
|
|
|
|
|
2019-09-21 09:44:03 +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)'
|
2018-08-29 07:43:21 +00:00
|
|
|
lane :pr do
|
2020-06-24 15:54:28 +00:00
|
|
|
build_ios_adhoc(pr_build: true)
|
2018-08-29 07:43:21 +00:00
|
|
|
end
|
|
|
|
|
2019-09-21 09:44:03 +00:00
|
|
|
desc '`fastlane ios nightly` - makes a new nightly'
|
|
|
|
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
|
2020-06-24 15:54:28 +00:00
|
|
|
build_ios_adhoc()
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|
2018-08-13 11:40:24 +00:00
|
|
|
|
2019-09-21 09:44:03 +00:00
|
|
|
desc '`fastlane ios release` builds a release & uploads it to TestFlight'
|
2018-04-04 16:36:26 +00:00
|
|
|
lane :release do
|
2020-11-09 23:48:31 +00:00
|
|
|
kc = Keychain.new('fastlane')
|
|
|
|
|
|
|
|
match(
|
|
|
|
type: 'appstore',
|
|
|
|
readonly: true,
|
2021-02-04 12:00:56 +00:00
|
|
|
api_key: asc_api_key(),
|
2020-11-09 23:48:31 +00:00
|
|
|
app_identifier: 'im.status.ethereum',
|
|
|
|
keychain_name: kc.name,
|
|
|
|
keychain_password: kc.pass
|
|
|
|
)
|
|
|
|
|
|
|
|
build_ios_app(
|
|
|
|
scheme: 'StatusIm',
|
|
|
|
workspace: 'ios/StatusIm.xcworkspace',
|
|
|
|
configuration: 'Release',
|
|
|
|
clean: true,
|
|
|
|
export_method: 'app-store',
|
|
|
|
output_directory: 'status-ios',
|
2023-03-09 10:07:56 +00:00
|
|
|
buildlog_path: 'ios/logs',
|
2020-11-09 23:48:31 +00:00
|
|
|
include_symbols: false,
|
|
|
|
export_options: {
|
|
|
|
"combileBitcode": true,
|
|
|
|
"uploadBitcode": false,
|
|
|
|
"ITSAppUsesNonExemptEncryption": false
|
|
|
|
}
|
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
|
2018-04-04 16:36:26 +00:00
|
|
|
upload_to_testflight(
|
2020-07-08 14:08:51 +00:00
|
|
|
ipa: 'status-ios/StatusIm.ipa',
|
2020-01-20 20:35:29 +00:00
|
|
|
skip_waiting_for_build_processing: true
|
2018-08-14 09:31:11 +00:00
|
|
|
)
|
2018-04-04 16:36:26 +00:00
|
|
|
end
|
2018-08-13 11:40:24 +00:00
|
|
|
|
2019-09-21 09:44:03 +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: `result/app.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'
|
2018-11-19 17:37:04 +00:00
|
|
|
desc "will fails if file isn't there"
|
|
|
|
lane :saucelabs do
|
|
|
|
upload_to_saucelabs(
|
2020-07-08 14:08:51 +00:00
|
|
|
'status-ios/StatusIm.app.zip'
|
2018-11-19 17:37:04 +00:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2019-09-21 09:44:03 +00:00
|
|
|
desc 'This fastlane step cleans up XCode DerivedData folder'
|
2018-08-14 18:09:52 +00:00
|
|
|
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
|
2019-09-13 17:16:13 +00:00
|
|
|
APK_PATHS = ENV["APK_PATHS"]&.split(";") or ["result/app.apk"]
|
2019-02-11 21:24:36 +00:00
|
|
|
|
2019-09-21 09:44:03 +00:00
|
|
|
desc 'Deploy a new internal build to Google Play'
|
|
|
|
desc 'expects GOOGLE_PLAY_JSON_KEY environment variable'
|
2018-03-26 10:56:25 +00:00
|
|
|
lane :nightly do
|
|
|
|
upload_to_play_store(
|
2019-09-21 09:44:03 +00:00
|
|
|
track: 'internal',
|
2019-09-13 17:16:13 +00:00
|
|
|
apk_paths: APK_PATHS,
|
2019-09-21 09:44:03 +00:00
|
|
|
json_key_data: ENV['GOOGLE_PLAY_JSON_KEY']
|
2018-08-14 09:31:11 +00:00
|
|
|
)
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|
2018-09-21 09:21:36 +00:00
|
|
|
|
2019-09-21 09:44:03 +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(
|
2019-09-21 09:44:03 +00:00
|
|
|
track: 'alpha',
|
2019-09-13 17:16:13 +00:00
|
|
|
apk_paths: APK_PATHS,
|
2019-09-21 09:44:03 +00:00
|
|
|
json_key_data: ENV['GOOGLE_PLAY_JSON_KEY']
|
2018-08-14 09:31:11 +00:00
|
|
|
)
|
2018-04-04 16:36:26 +00:00
|
|
|
end
|
2018-08-14 08:42:57 +00:00
|
|
|
|
2021-08-06 08:19:47 +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,
|
|
|
|
skip_upload_changelogs: true,
|
|
|
|
json_key_data: ENV['GOOGLE_PLAY_JSON_KEY'],
|
|
|
|
# These don't matter much as we're not uploading any new builds
|
|
|
|
# and indeed, we're skipping changelogs. This is just so that
|
|
|
|
# the library can find what it thinks it needs and continue with
|
|
|
|
# the work we actually want it to do.
|
|
|
|
track: 'production',
|
|
|
|
version_code: '2020042307'
|
|
|
|
)
|
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|