Last active
August 28, 2020 03:49
-
-
Save isnine/d4aacf8fcc7ecae50c3c8390651b893f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
default_platform(:ios) | |
platform :ios do | |
# 记得提前在CI中设置 https://travis-ci.com/{user}/{app}/settings | |
# - GH_Token //Github的token | |
# - Cert_PassWord //证书密码 | |
# - FASTLANE_PASSWORD // Apple 账号密码 | |
# - FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD //PassWord apple专用密码 | |
# - Apple_Session //appleSession,通过fastlane spaceauth -u user@example.com获得 | |
lane :ci do | |
branch = git_branch | |
puts("*************| 当前branch #{branch} |*************") | |
# 配置环境 | |
keychain_name = "build" | |
keychain_password = "travis" | |
# 设置session 规避两步验证码 | |
# ENV["FASTLANE_SESSION"] = File.read("session.txt") | |
# 创建临时钥匙串 | |
create_keychain( | |
name: keychain_name, | |
password: keychain_password, | |
default_keychain: true, | |
unlock: true, | |
timeout: 3600, | |
add_to_search_list: true | |
) | |
# 导入私钥 | |
import_certificate( | |
certificate_path: "./fastlane/certs/dist.p12", | |
certificate_password: ENV["Cert_PassWord"], | |
keychain_name: keychain_name, | |
keychain_password: keychain_password | |
) | |
import_certificate( | |
certificate_path: "./fastlane/certs/dev.p12", | |
certificate_password: ENV["Cert_PassWord"], | |
keychain_name: keychain_name, | |
keychain_password: keychain_password | |
) | |
# 拉取证书 | |
system "sh ./load_provision.sh" | |
# sigh(app_identifier: "bundleID", | |
# username: "user@example.com") | |
if branch.start_with? "master" | |
beta | |
elsif branch.start_with? "release" | |
release | |
end | |
end | |
lane :release do | |
# 编译app | |
buildApp | |
# 上传app | |
upload_to_app_store( | |
skip_screenshots: true, | |
skip_metadata: false, | |
reject_if_possible: true, | |
# skip_binary_upload: true, | |
force: true, | |
app_review_information: { | |
first_name: 'W', | |
last_name: 'XZ', | |
phone_number: '+86 17600000', | |
email_address: 'user@example.com', | |
demo_user: '', | |
demo_password: '', | |
notes: '' | |
}, | |
submit_for_review: true, | |
submission_information: { | |
add_id_info_limits_tracking: true, | |
add_id_info_serves_ads: false, | |
add_id_info_tracks_action: true, | |
add_id_info_tracks_install: true, | |
add_id_info_uses_idfa: true, | |
content_rights_has_rights: true, | |
content_rights_contains_third_party_content: true, | |
export_compliance_platform: 'ios', | |
export_compliance_compliance_required: false, | |
export_compliance_encryption_updated: false, | |
export_compliance_app_type: nil, | |
export_compliance_uses_encryption: false, | |
export_compliance_is_exempt: false, | |
export_compliance_contains_third_party_cryptography: false, | |
export_compliance_contains_proprietary_cryptography: false, | |
export_compliance_available_on_french_store: false | |
}, | |
release_notes: {'default' => File.read("Changelog.txt"), | |
'zh-Hans' => File.read("Changelog.txt"), | |
'en-US' => File.read("Changelog.txt")} | |
) | |
# 更新版本tag | |
add_git_tag | |
if is_ci? | |
system "git push https://isnine:${GH_Token}@github.com/isnine/easy.git --tags" | |
else | |
push_to_git_remote | |
end | |
# 上传dysm | |
crashlytics(api_token: "xxxx", | |
build_secret: "xxxx") | |
end | |
desc "Push a new beta build to TestFlight" | |
lane :beta do | |
# 编译app | |
buildApp | |
# 上传 | |
upload_to_testflight( | |
beta_app_feedback_email: "user@example", | |
beta_app_description: "", | |
notify_external_testers: false, | |
distribute_external: true, | |
changelog: File.read("Changelog.txt"), | |
groups: ["testflight.top","Price Tag","其他渠道"], | |
) | |
# 更新版本tag | |
add_git_tag | |
if is_ci? | |
system "git push https://isnine:${GH_Token}@github.com/isnine/easy.git --tags" | |
else | |
push_to_git_remote | |
end | |
# 上传dysm | |
crashlytics(api_token: "xxx", | |
build_secret: "xx") | |
end | |
end | |
# 编译当前app | |
def buildApp | |
# 更改build号 | |
updateProjectBuildNumber | |
# 编译 | |
build_app(workspace: "easy.xcworkspace", scheme: "easy") | |
end | |
# 更新版本号 | |
def updateProjectBuildNumber | |
currentTime = Time.new.strftime("%y%m%d") | |
build = latest_testflight_build_number(version: get_version_number) | |
puts("*************| Tag: #{build} |*************") | |
buildStr = build.to_s | |
if buildStr.include?"#{currentTime}" | |
# => 为当天版本 计算迭代版本号 | |
lastStr = buildStr[buildStr.length-2..buildStr.length-1] | |
lastNum = lastStr.to_i | |
lastNum = lastNum + 1 | |
lastStr = lastNum.to_s | |
if lastNum < 10 | |
lastStr = lastStr.insert(0,"0") | |
end | |
build = "#{currentTime}#{lastStr}" | |
else | |
# => 非当天版本 build 号重置 | |
build = "#{currentTime}01" | |
end | |
puts("*************| 更新build #{build} |*************") | |
# => 更改项目 build 号 | |
increment_build_number( | |
build_number: "#{build}" | |
) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment