tooot/fastlane/Fastfile

221 lines
7.0 KiB
Plaintext
Raw Normal View History

fastlane_version "2.179.0"
2021-02-03 23:49:18 +01:00
skip_docs
2021-01-31 03:09:35 +01:00
2021-02-02 22:50:38 +01:00
ensure_env_vars(
2021-03-14 21:48:28 +01:00
env_vars: ["ENVIRONMENT", "SENTRY_ORGANIZATION", "SENTRY_PROJECT", "SENTRY_AUTH_TOKEN"]
2021-02-02 22:50:38 +01:00
)
VERSIONS = read_json( json_path: "./package.json" )[:versions]
2021-03-14 21:48:28 +01:00
ENVIRONMENT = ENV["ENVIRONMENT"]
2021-02-02 22:50:38 +01:00
VERSION = "#{VERSIONS[:major]}.#{VERSIONS[:minor]}"
2021-03-15 22:30:29 +01:00
RELEASE_CHANNEL = "#{VERSIONS[:major]}-#{ENVIRONMENT}"
2021-03-18 09:50:14 +01:00
BUILD_NUMBER = "#{Time.now.strftime("%y%m%d")}#{ENV["GITHUB_RUN_NUMBER"]}"
2021-02-03 23:49:18 +01:00
GITHUB_REPO = "tooot-app/app"
case ENVIRONMENT
2021-03-14 21:48:28 +01:00
when "candidate"
2021-02-17 21:39:38 +01:00
GITHUB_RELEASE = "v#{VERSION}-#{VERSIONS[:patch]}"
2021-03-14 21:48:28 +01:00
when "release"
2021-02-03 23:49:18 +01:00
GITHUB_RELEASE = "v#{VERSION}"
2021-03-16 23:15:37 +01:00
else
GITHUB_RELEASE= ""
2021-02-03 23:49:18 +01:00
end
2021-01-31 03:09:35 +01:00
2021-02-03 23:49:18 +01:00
XCODEPROJ = "./ios/tooot.xcodeproj"
INFO_PLIST = "./ios/tooot/Info.plist"
EXPO_PLIST = "./ios/tooot/Supporting/Expo.plist"
2021-01-31 03:09:35 +01:00
2021-02-03 23:49:18 +01:00
desc "IOS: Prepare app store"
2021-02-04 01:01:35 +01:00
private_lane :prepare_appstore_ios do
2021-02-05 01:13:57 +01:00
set_info_plist_value( path: INFO_PLIST, key: "CFBundleShortVersionString", value: VERSION )
set_info_plist_value(
path: INFO_PLIST,
key: "NSAppTransportSecurity",
2021-03-16 00:36:32 +01:00
value: {}
)
2021-03-18 09:50:14 +01:00
increment_build_number( xcodeproj: XCODEPROJ, build_number: BUILD_NUMBER )
2021-02-05 01:13:57 +01:00
app_store_connect_api_key
2021-02-03 23:49:18 +01:00
end
2021-01-31 03:09:35 +01:00
2021-02-05 01:13:57 +01:00
desc 'IOS: Update expo information'
private_lane :update_expo_ios do
2021-02-03 23:49:18 +01:00
set_info_plist_value( path: EXPO_PLIST, key: "EXUpdatesSDKVersion", value: VERSIONS[:expo] )
set_info_plist_value( path: EXPO_PLIST, key: "EXUpdatesReleaseChannel", value: RELEASE_CHANNEL )
end
2021-01-31 03:09:35 +01:00
2021-02-05 01:13:57 +01:00
desc "ANDROID: Prepare play store"
private_lane :prepare_playstore_android do
android_set_version_name( version_name: VERSION, gradle_file: "./android/app/build.gradle" )
android_set_version_code( version_code: BUILD_NUMBER, gradle_file: "./android/app/build.gradle" )
end
2021-02-03 23:49:18 +01:00
desc "Create new GitHub release"
2021-02-09 01:16:12 +01:00
private_lane :github_release do |options|
2021-02-03 23:49:18 +01:00
set_github_release(
repository_name: GITHUB_REPO,
2021-02-04 01:01:35 +01:00
name: GITHUB_RELEASE,
2021-02-03 23:49:18 +01:00
tag_name: GITHUB_RELEASE,
2021-02-04 01:01:35 +01:00
description: "No changelog provided",
2021-02-03 23:49:18 +01:00
commitish: git_branch,
2021-03-25 01:31:30 +01:00
is_prerelease: options[:prerelease],
2021-04-03 11:52:13 +02:00
upload_assets: options[:prerelease] ? nil : ["#{File.expand_path('..', Dir.pwd)}/tooot-#{GITHUB_RELEASE}.apk"]
2021-02-03 23:49:18 +01:00
)
end
2021-02-02 22:50:38 +01:00
2021-02-03 23:49:18 +01:00
desc "Expo release"
private_lane :expo_release do
yarn( package_path: "./package.json", flags: "release", command: RELEASE_CHANNEL )
end
2021-02-02 22:50:38 +01:00
2021-02-04 01:01:35 +01:00
desc "Build and deploy iOS app"
2021-02-03 23:49:18 +01:00
private_lane :build_ios do
BUILD_DIRECTORY = "./ios/build"
2021-04-03 11:52:13 +02:00
IPA_FILE = "#{BUILD_DIRECTORY}/tooot.ipa"
DSYM_FILE = "#{BUILD_DIRECTORY}/tooot.app.dSYM.zip"
2021-02-02 22:50:38 +01:00
2021-02-05 01:13:57 +01:00
update_expo_ios
2021-02-03 23:49:18 +01:00
setup_ci
2021-01-31 03:09:35 +01:00
2021-02-03 23:49:18 +01:00
case ENVIRONMENT
2021-03-14 21:48:28 +01:00
when "candidate"
2021-02-05 01:13:57 +01:00
prepare_appstore_ios
2021-02-03 23:49:18 +01:00
match( type: "appstore", readonly: true )
2021-04-03 11:52:13 +02:00
build_ios_app(
export_method: "app-store",
include_symbols: true,
output_directory: BUILD_DIRECTORY,
silent: true
)
sentry_upload_dsym(
org_slug: ENV["SENTRY_ORGANIZATION"],
project_slug: ENV["SENTRY_PROJECT"],
dsym_path: DSYM_FILE
)
2021-02-03 23:49:18 +01:00
upload_to_testflight(
2021-04-03 11:52:13 +02:00
ipa: IPA_FILE,
2021-02-03 23:49:18 +01:00
demo_account_required: true,
distribute_external: true,
2021-03-14 21:48:28 +01:00
groups: "测试用户",
2021-04-03 11:52:13 +02:00
changelog: "感谢帮忙测试 tooot 🙏"
2021-02-03 23:49:18 +01:00
)
2021-03-14 21:48:28 +01:00
when "release"
2021-02-05 01:13:57 +01:00
prepare_appstore_ios
2021-03-16 23:15:37 +01:00
match( type: "appstore", readonly: true )
2021-04-03 11:52:13 +02:00
build_ios_app(
export_method: "app-store",
include_bitcode: true,
output_directory: BUILD_DIRECTORY,
silent: true
)
upload_to_app_store(
force: true,
ipa: IPA_FILE,
submit_for_review: true,
automatic_release: false
)
2021-03-14 22:22:26 +01:00
else
if !is_ci
match( type: "development", readonly: true )
2021-03-16 23:15:37 +01:00
build_ios_app( export_method: "development", output_directory: BUILD_DIRECTORY, silent: true )
2021-03-14 22:22:26 +01:00
install_on_device( skip_wifi: true )
end
2021-01-31 03:09:35 +01:00
end
end
2021-02-04 01:17:54 +01:00
desc "Build and deploy Android app"
private_lane :build_android do
2021-02-05 01:13:57 +01:00
sh("echo #{ENV["ANDROID_KEYSTORE"]} | base64 -d | tee #{File.expand_path('..', Dir.pwd)}/android/tooot.jks >/dev/null", log: false)
2021-02-04 01:17:54 +01:00
case ENVIRONMENT
2021-03-14 21:48:28 +01:00
when "candidate"
2021-02-05 01:13:57 +01:00
prepare_playstore_android
build_android_app(
task: 'clean bundle',
build_type: 'release',
2021-02-04 01:17:54 +01:00
project_dir: "./android",
2021-02-05 01:13:57 +01:00
print_command: false,
print_command_output: false,
2021-02-04 01:17:54 +01:00
properties: {
2021-02-05 01:13:57 +01:00
"expoSDK" => VERSIONS[:expo],
"releaseChannel" => RELEASE_CHANNEL,
"android.injected.signing.store.file" => "#{File.expand_path('..', Dir.pwd)}/android/tooot.jks",
"android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["ANDROID_KEYSTORE_ALIAS"],
"android.injected.signing.key.password" => ENV["ANDROID_KEYSTORE_KEY_PASSWORD"],
2021-02-04 01:17:54 +01:00
}
)
2021-02-05 01:13:57 +01:00
upload_to_play_store(
2021-02-09 01:16:12 +01:00
track: "beta",
2021-02-05 01:13:57 +01:00
skip_upload_metadata: true,
skip_upload_changelogs: true,
skip_upload_images: true,
skip_upload_screenshots: true
2021-02-04 01:17:54 +01:00
)
2021-04-03 11:52:13 +02:00
when "release"
prepare_playstore_android
build_android_app(
task: 'clean bundle',
build_type: 'release',
project_dir: "./android",
print_command: false,
print_command_output: false,
properties: {
"expoSDK" => VERSIONS[:expo],
"releaseChannel" => RELEASE_CHANNEL,
"android.injected.signing.store.file" => "#{File.expand_path('..', Dir.pwd)}/android/tooot.jks",
"android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["ANDROID_KEYSTORE_ALIAS"],
"android.injected.signing.key.password" => ENV["ANDROID_KEYSTORE_KEY_PASSWORD"],
}
)
upload_to_play_store(
track: "production",
skip_upload_changelogs: true
)
2021-03-25 00:52:15 +01:00
build_android_app(
task: 'assemble',
build_type: 'release',
project_dir: "./android",
print_command: false,
print_command_output: false,
properties: {
"expoSDK" => VERSIONS[:expo],
"releaseChannel" => RELEASE_CHANNEL,
"android.injected.signing.store.file" => "#{File.expand_path('..', Dir.pwd)}/android/tooot.jks",
"android.injected.signing.store.password" => ENV["ANDROID_KEYSTORE_PASSWORD"],
"android.injected.signing.key.alias" => ENV["ANDROID_KEYSTORE_ALIAS"],
"android.injected.signing.key.password" => ENV["ANDROID_KEYSTORE_KEY_PASSWORD"],
}
)
2021-03-25 01:20:30 +01:00
sh "mv #{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]} #{File.expand_path('..', Dir.pwd)}/tooot-#{GITHUB_RELEASE}.apk"
2021-03-14 22:22:26 +01:00
else
if !is_ci
build_android_app(
task: 'assemble',
build_type: 'release',
project_dir: "./android"
)
adb(
command: "install #{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}"
)
end
2021-02-04 01:17:54 +01:00
end
end
2021-02-03 23:49:18 +01:00
lane :build do
2021-03-04 14:11:08 +01:00
releaseExists = get_github_release(url: GITHUB_REPO, version: GITHUB_RELEASE, api_token: ENV['GH_PAT_GET_RELEASE'])
2021-02-03 23:49:18 +01:00
if releaseExists
puts("Release #{GITHUB_RELEASE} exists. Continue with building React Native only.")
else
puts("Release #{GITHUB_RELEASE} does not exist. Create new release as well as new native build.")
2021-02-04 01:17:54 +01:00
build_ios
build_android
2021-02-03 23:49:18 +01:00
case ENVIRONMENT
2021-03-14 21:48:28 +01:00
when "candidate"
2021-02-09 01:16:12 +01:00
github_release(prerelease: true)
2021-03-14 21:48:28 +01:00
when "release"
2021-02-09 01:16:12 +01:00
github_release(prerelease: false)
2021-02-03 23:49:18 +01:00
end
end
2021-02-05 01:13:57 +01:00
expo_release
2021-02-03 23:49:18 +01:00
rocket
2021-01-31 03:09:35 +01:00
end