tooot/fastlane/Fastfile

169 lines
5.0 KiB
Plaintext
Raw Normal View History

2021-03-14 21:48:28 +01:00
fastlane_version "2.178.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-02-04 00:48:53 +01:00
BUILD_NUMBER = ENV["GITHUB_RUN_NUMBER"]
2021-02-03 23:49:18 +01:00
GITHUB_REPO = "tooot-app/app"
case ENVIRONMENT
2021-03-14 22:22:26 +01:00
when "main"
2021-02-04 01:17:54 +01:00
GITHUB_RELEASE= ""
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}"
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",
value: {
"NSAllowsArbitraryLoads" => false
}
)
2021-03-14 21:48:28 +01:00
increment_build_number( xcodeproj: XCODEPROJ, build_number: BUILD_NUMBER, skip_info_plist: true )
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-03-14 21:48:28 +01:00
desc 'IOS: Install pods'
private_lane :install_pods_ios do
cocoapods(podfile: "./ios/", deployment: true)
end
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-02-09 01:16:12 +01:00
is_prerelease: options[:prerelease]
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-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"
install_pods_ios
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-02-17 21:39:38 +01:00
build_ios_app( export_method: "app-store", include_symbols: true, include_bitcode: true )
2021-02-03 23:49:18 +01:00
upload_to_testflight(
demo_account_required: true,
distribute_external: true,
2021-03-14 21:48:28 +01:00
groups: "测试用户",
2021-02-03 23:49:18 +01:00
changelog: "Ready for testing"
)
2021-03-14 21:48:28 +01:00
when "release"
install_pods_ios
2021-02-05 01:13:57 +01:00
prepare_appstore_ios
2021-03-14 00:47:55 +01:00
match( type: "appstore", readonly: true, include_bitcode: true )
2021-02-03 23:49:18 +01:00
build_ios_app( export_method: "app-store" )
2021-03-14 22:22:26 +01:00
else
if !is_ci
match( type: "development", readonly: true )
build_ios_app( export_method: "development", output_directory: BUILD_DIRECTORY )
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-03-14 21:48:28 +01:00
when "release"
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