tooot/fastlane/Fastfile

155 lines
4.6 KiB
Plaintext
Raw Normal View History

2021-02-05 01:13:57 +01:00
fastlane_version "2.173.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(
env_vars: ["TOOOT_ENVIRONMENT"]
)
VERSIONS = read_json( json_path: "./package.json" )[:versions]
ENVIRONMENT = ENV["TOOOT_ENVIRONMENT"]
VERSION = "#{VERSIONS[:major]}.#{VERSIONS[:minor]}"
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-02-04 01:17:54 +01:00
when "development"
GITHUB_RELEASE= ""
2021-02-03 23:49:18 +01:00
when "staging"
2021-02-09 01:16:12 +01:00
GITHUB_RELEASE = "v#{VERSION}-rc#{VERSIONS[:patch]}"
2021-02-03 23:49:18 +01:00
when "production"
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 )
increment_build_number( xcodeproj: XCODEPROJ, build_number: BUILD_NUMBER )
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-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
when "development"
match( type: "development", readonly: true )
2021-02-09 01:16:12 +01:00
if !is_ci
build_ios_app( export_method: "development", output_directory: BUILD_DIRECTORY )
install_on_device( skip_wifi: true )
end
2021-02-03 23:49:18 +01:00
when "staging"
2021-02-05 01:13:57 +01:00
prepare_appstore_ios
2021-02-03 23:49:18 +01:00
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
upload_to_testflight(
demo_account_required: true,
distribute_external: true,
groups: "内测用户",
changelog: "Ready for testing"
)
when "production"
2021-02-05 01:13:57 +01:00
prepare_appstore_ios
2021-02-03 23:49:18 +01:00
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
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
when "development"
2021-02-09 01:16:12 +01:00
if !is_ci
build_android_app(
task: 'assemble',
2021-02-13 13:08:34 +01:00
build_type: 'release',
2021-02-09 01:16:12 +01:00
project_dir: "./android"
)
adb(
command: "install #{lane_context[SharedValues::GRADLE_APK_OUTPUT_PATH]}"
)
end
2021-02-05 01:13:57 +01:00
when "staging"
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
)
when "production"
end
end
2021-02-03 23:49:18 +01:00
lane :build do
releaseExists = get_github_release(url: GITHUB_REPO, version: GITHUB_RELEASE)
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
2021-02-05 01:13:57 +01:00
build_android
2021-02-03 23:49:18 +01:00
case ENVIRONMENT
when "staging"
2021-02-09 01:16:12 +01:00
github_release(prerelease: true)
2021-02-03 23:49:18 +01:00
when "production"
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