tooot/fastlane/Fastfile

104 lines
2.9 KiB
Plaintext
Raw Normal View History

2021-02-02 22:50:38 +01:00
fastlane_version "2.172.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-03 23:49:18 +01:00
BUILD_NUMBER = number_of_commits
GITHUB_REPO = "tooot-app/app"
case ENVIRONMENT
when "staging"
GITHUB_RELEASE = "v#{VERSION} (#{BUILD_NUMBER})"
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"
private_lane :prepare_appstore do
case ENVIRONMENT
when "staging", "production"
increment_build_number( xcodeproj: XCODEPROJ, build_number: BUILD_NUMBER )
app_store_connect_api_key
2021-01-31 03:09:35 +01:00
end
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
desc 'IOS: Update version information'
private_lane :update_versions do
set_info_plist_value( path: INFO_PLIST, key: "CFBundleShortVersionString", value: VERSION )
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-03 23:49:18 +01:00
desc "Create new GitHub release"
private_lane :github_release do
set_github_release(
repository_name: GITHUB_REPO,
api_bearer: ENV["GITHUB_TOKEN"],
name: GITHUB_RELEASE,
tag_name: GITHUB_RELEASE,
commitish: git_branch,
is_prerelease: ENVIRONMENT == "staging"
)
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-03 23:49:18 +01:00
desc "Build and deploy"
private_lane :build_ios do
BUILD_DIRECTORY = "./ios/build"
2021-02-02 22:50:38 +01:00
2021-02-03 23:49:18 +01:00
update_versions
prepare_appstore
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 )
match_certificates( type: "development" )
build_ios_app( export_method: "development", output_directory: BUILD_DIRECTORY, output_name: "#{VERSION}-#{BUILD_NUMBER}" )
install_on_device( skip_wifi: true )
when "staging"
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"
match( type: "appstore", readonly: true )
build_ios_app( export_method: "app-store" )
2021-01-31 03:09:35 +01:00
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.")
build_ios
# build_android
case ENVIRONMENT
when "staging"
github_release
when "production"
github_release
end
end
expo_release
rocket
2021-01-31 03:09:35 +01:00
end