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-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
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
username = ENV["SAUCE_USERNAME"]
|
|
|
|
key = ENV["SAUCE_ACCESS_KEY"]
|
|
|
|
unique_name = ENV["SAUCE_LABS_APK"]
|
|
|
|
|
|
|
|
url = "https://saucelabs.com/rest/v1/storage/" + username + '/' + unique_name + "?overwrite=true"
|
|
|
|
|
|
|
|
upload_result = sh(
|
|
|
|
"curl",
|
|
|
|
"-u", username + ':' + key,
|
2018-08-17 09:14:11 +00:00
|
|
|
"-X", "POST",
|
2018-08-14 16:24:48 +00:00
|
|
|
"-H", "Content-Type: application/octet-stream",
|
|
|
|
url,
|
|
|
|
# this command has `status-react/fastlane` as cwd
|
|
|
|
# so we need to jump outside this folder to get a file
|
|
|
|
"--data-binary", "@" + "../" + file
|
|
|
|
)
|
|
|
|
|
|
|
|
# fail the lane if upload fails
|
|
|
|
UI.user_error!(
|
|
|
|
"failed to upload file to saucelabs: " + upload_result
|
|
|
|
) 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
|
|
|
|
def build_ios_adhoc
|
|
|
|
match(
|
|
|
|
type: "adhoc",
|
|
|
|
force_for_new_devices: true,
|
|
|
|
readonly: true,
|
|
|
|
keychain_name: "login.keychain"
|
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
|
|
|
|
workaround_realm_core_sync_issues
|
|
|
|
|
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",
|
|
|
|
output_directory: "status-adhoc"
|
|
|
|
)
|
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
|
|
|
|
|
2018-08-14 08:42:57 +00:00
|
|
|
def notify_about_new_build(source, url)
|
2018-08-15 06:15:45 +00:00
|
|
|
branch_name = ENV["BRANCH_NAME"]
|
|
|
|
branch_name = "develop" if branch_name.nil?
|
2018-08-14 08:42:57 +00:00
|
|
|
|
2018-08-15 06:15:45 +00:00
|
|
|
msg = "Branch: " + branch_name + ", "
|
2018-08-14 08:42:57 +00:00
|
|
|
|
|
|
|
if source.end_with? ".ipa"
|
|
|
|
msg = msg + "iOS build uploaded to diawi: " + url
|
|
|
|
else
|
|
|
|
msg = msg + "Android build uploaded to diawi: " + url
|
|
|
|
end
|
|
|
|
|
|
|
|
slack(
|
|
|
|
message: msg,
|
2018-08-17 09:14:11 +00:00
|
|
|
slack_url: ENV["SLACK_URL"],
|
|
|
|
default_payloads: []
|
2018-08-14 08:42:57 +00:00
|
|
|
)
|
|
|
|
|
2018-08-15 06:15:45 +00:00
|
|
|
change_id = ENV["CHANGE_ID"]
|
|
|
|
|
|
|
|
unless change_id.nil?
|
|
|
|
|
|
|
|
github_api(
|
|
|
|
server_url: "https://api.github.com",
|
|
|
|
api_token: ENV["GITHUB_TOKEN"],
|
|
|
|
http_method: "POST",
|
|
|
|
path: "/repos/status-im/status-react/issues/" + change_id + "/comments",
|
|
|
|
body: {
|
|
|
|
"body": msg
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
end
|
2018-08-14 08:42:57 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def upload_to_diawi_and_notify(source)
|
|
|
|
diawi(
|
|
|
|
token: ENV["DIAWI_TOKEN"],
|
|
|
|
file: source
|
|
|
|
)
|
|
|
|
|
2018-08-15 06:15:45 +00:00
|
|
|
File.write("diawi.out", lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI])
|
|
|
|
|
2018-08-14 08:42:57 +00:00
|
|
|
notify_about_new_build(
|
|
|
|
source,
|
|
|
|
lane_context[SharedValues::UPLOADED_FILE_LINK_TO_DIAWI]
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
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."
|
|
|
|
desc "This lane is used 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"
|
|
|
|
lane :adhoc do
|
|
|
|
unlock_keychain_if_needed
|
|
|
|
build_ios_adhoc
|
|
|
|
end
|
|
|
|
|
|
|
|
desc "`fastlane ios nightly` - makes a new nightly in TestFlight"
|
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-08-13 11:40:24 +00:00
|
|
|
unlock_keychain_if_needed
|
|
|
|
|
|
|
|
match(
|
|
|
|
type: "appstore",
|
|
|
|
force_for_new_devices: true,
|
|
|
|
readonly: true,
|
|
|
|
keychain_name: "login.keychain"
|
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
|
|
|
|
workaround_realm_core_sync_issues
|
|
|
|
|
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"
|
|
|
|
)
|
2018-08-14 09:31:11 +00:00
|
|
|
|
|
|
|
slack(
|
|
|
|
message: "New nightly build uploaded to TestFlight",
|
2018-08-17 09:14:11 +00:00
|
|
|
slack_url: ENV["SLACK_URL"],
|
|
|
|
default_payloads: []
|
2018-03-26 10:56:25 +00:00
|
|
|
)
|
2018-08-13 11:40:24 +00:00
|
|
|
|
|
|
|
# additional .ipa is for diawi
|
|
|
|
# we have to re-build it because it uses different config
|
|
|
|
build_ios_adhoc
|
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",
|
|
|
|
force_for_new_devices: true,
|
|
|
|
readonly: true,
|
|
|
|
keychain_name: "login.keychain"
|
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
|
|
|
|
workaround_realm_core_sync_issues
|
|
|
|
|
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",
|
|
|
|
export_options: {
|
|
|
|
"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"
|
|
|
|
)
|
|
|
|
slack(
|
|
|
|
message: "New release build uploaded to TestFlight",
|
2018-08-17 09:14:11 +00:00
|
|
|
slack_url: ENV["SLACK_URL"],
|
|
|
|
default_payloads: []
|
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
|
|
|
|
clean_testflight_testers
|
|
|
|
end
|
2018-08-14 08:42:57 +00:00
|
|
|
|
|
|
|
desc "`fastlane ios upload-diawi` - upload .ipa to diawi"
|
|
|
|
desc "also notifies in a GitHub comments and in Slack #jenkins channel"
|
|
|
|
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 "expects to have a slack webhook URL as SLACK_URL 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
|
|
|
|
upload_to_diawi_and_notify(
|
|
|
|
"status-adhoc/StatusIm.ipa"
|
|
|
|
)
|
|
|
|
end
|
2018-08-15 06:15:45 +00:00
|
|
|
|
|
|
|
desc "This fastlane step is a workaround!"
|
|
|
|
desc "every now and then Realm fails on iOS on the 'Download Core` step"
|
2018-08-15 14:13:27 +00:00
|
|
|
desc "the issue is because multiple downloads use the same temp dir"
|
|
|
|
desc "now we are replacing the original download script with another"
|
|
|
|
desc "that generates a random folder for each run"
|
2018-08-15 06:15:45 +00:00
|
|
|
lane :workaround_realm_core_sync_issues do
|
2018-08-15 14:13:27 +00:00
|
|
|
FileUtils.cp_r(
|
|
|
|
'../ci/download-realm.js',
|
|
|
|
'../node_modules/realm/scripts',
|
|
|
|
remove_destination: true
|
2018-08-17 09:14:11 +00:00
|
|
|
)
|
2018-08-15 06:15:45 +00:00
|
|
|
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
|
|
|
|
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",
|
2018-08-14 09:31:11 +00:00
|
|
|
apk: "android/app/build/outputs/apk/release/app-release.apk",
|
|
|
|
json_key_data: ENV["GOOGLE_PLAY_JSON_KEY"]
|
|
|
|
)
|
|
|
|
|
|
|
|
slack(
|
|
|
|
message: "New nightly build uploaded to Google Play",
|
2018-08-17 09:14:11 +00:00
|
|
|
slack_url: ENV["SLACK_URL"],
|
|
|
|
default_payloads: []
|
2018-03-26 10:56:25 +00:00
|
|
|
)
|
|
|
|
end
|
2018-04-04 16:36:26 +00:00
|
|
|
lane :release do
|
2018-08-14 09:31:11 +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
|
|
|
upload_to_play_store(
|
|
|
|
track: "alpha",
|
2018-08-14 09:31:11 +00:00
|
|
|
apk: "android/app/build/outputs/apk/release/app-release.apk",
|
|
|
|
json_key_data: ENV["GOOGLE_PLAY_JSON_KEY"]
|
|
|
|
)
|
|
|
|
slack(
|
|
|
|
message: "New release build uploaded to Google Play",
|
2018-08-17 09:14:11 +00:00
|
|
|
slack_url: ENV["SLACK_URL"],
|
|
|
|
default_payloads: []
|
2018-04-04 16:36:26 +00:00
|
|
|
)
|
|
|
|
end
|
2018-08-14 08:42:57 +00:00
|
|
|
|
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 "also notifies in a GitHub comments and in Slack #jenkins channel"
|
|
|
|
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 "expects to have a slack webhook URL as SLACK_URL 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
|
|
|
|
upload_to_diawi_and_notify(
|
|
|
|
"android/app/build/outputs/apk/release/app-release.apk"
|
|
|
|
)
|
|
|
|
end
|
2018-08-14 16:24:48 +00:00
|
|
|
|
|
|
|
desc "`fastlane android saucelabs` - upload .apk to sauce labs"
|
|
|
|
desc "also notifies in a GitHub comments and in Slack #jenkins channel"
|
|
|
|
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_APK env variable"
|
|
|
|
desc "will fails if file isn't there"
|
|
|
|
lane :saucelabs do
|
|
|
|
upload_to_saucelabs(
|
|
|
|
"android/app/build/outputs/apk/release/app-release.apk"
|
|
|
|
)
|
|
|
|
end
|
2018-03-26 10:56:25 +00:00
|
|
|
end
|