使用fastlane match管理證書(shū), 主電腦更新證書(shū)和描述文件, 其他電腦同步證書(shū)和描述文件
.env文件配置
# bundle id
app_identifier = "xxx"
# 創(chuàng)建應(yīng)用的時(shí)候用到
# 應(yīng)用名稱
app_name = "xxx"
# 應(yīng)用版本號(hào)
app_version = "xxx"
# 應(yīng)用語(yǔ)言
app_language = "xxx"
# 開(kāi)發(fā)者賬號(hào)
apple_id = "xxx"
# team_id 開(kāi)發(fā)者中心membership中可以查到
team_id = "xxx"
# team_name 開(kāi)發(fā)者中心membership中可以查到
team_name = "xxx"
# match管理的證書(shū)的git倉(cāng)庫(kù)地址
cer_git_url = "xxx"
# match管理的證書(shū)的git倉(cāng)庫(kù)分支, 如master
cer_git_branch = "xxx"
# 開(kāi)發(fā)者賬號(hào)
username = ENV["apple_id"]
# team_id 開(kāi)發(fā)者中心membership中可以查到
team_id = ENV["team_id"]
# team_name 開(kāi)發(fā)者中心membership中可以查到
team_name = ENV["team_name"]
# match管理的證書(shū)的git倉(cāng)庫(kù)地址
git_url = ENV["cer_git_url"]
# match管理的證書(shū)的git倉(cāng)庫(kù)分支
cer_git_branch = ENV["cer_git_branch"]
# 多個(gè)bundle id, 管理一個(gè)賬號(hào)下多個(gè)應(yīng)用的證書(shū),描述文件
app_identifiers = ["xxx1", "xxx2", "xxx3"]
# 默認(rèn)ipa名字, 主要用于重簽
default_ipa_name = "xxx.ipa"
desc "更新證書(shū)描述文件"
lane :createCerAndProvisionFile do
register_devices(
# 需要添加的設(shè)備
devices: {
"設(shè)備名稱1" => "xxx"
}
) # Simply provide a list of devices as a Hash
app_identifiers.each { |bundle_id|
match(git_url: git_url,
type: "development",
git_branch: cer_git_branch,
shallow_clone: true,
clone_branch_directly: true,
generate_apple_certs: true,
username: username,
team_id: team_id,
team_name: team_name,
app_identifier: bundle_id,
force_for_new_devices: true)
match(git_url: git_url,
type: "adhoc",
git_branch: cer_git_branch,
generate_apple_certs: true,
shallow_clone: true,
clone_branch_directly: true,
username: username,
team_id: team_id,
team_name: team_name,
app_identifier: bundle_id,
force_for_new_devices: true)
match(git_url: git_url,
type: "appstore",
git_branch: cer_git_branch,
generate_apple_certs: true,
shallow_clone: true,
clone_branch_directly: true,
username: username,
team_id: team_id,
team_name: team_name,
app_identifier: bundle_id)
}
end
desc "同步證書(shū)和描述文件,只讀權(quán)限, 不會(huì)動(dòng)開(kāi)發(fā)者中心中的證書(shū)和描述文件"
lane :syncCodeSigning do
app_identifiers.each { |bundle_id|
match(git_url: git_url,
type: "development",
git_branch: cer_git_branch,
username: username,
team_id: team_id,
team_name: team_name,
app_identifier: bundle_id,
readonly: true,
force_for_new_devices: true)
match(git_url: git_url,
type: "adhoc",
git_branch: cer_git_branch,
username: username,
team_id: team_id,
team_name: team_name,
app_identifier: bundle_id,
readonly: true,
force_for_new_devices: true)
match(git_url: git_url,
type: "appstore",
git_branch: cer_git_branch,
username: username,
team_id: team_id,
team_name: team_name,
app_identifier: bundle_id,
readonly: true)
}
end
使用fastlane sigh 重簽ipa包
# ipa重簽
lane :resignAdhocIpa do |lane|
# 先添加設(shè)備
createCerAndProvisionFile
# 使用match從倉(cāng)庫(kù)地址拉取最新的證書(shū)
config = FastlaneCore::Configuration.create(Match::Options.available_options, {}).load_configuration_file('Matchfile').options
config[:clone_branch_directly] = true
config[:skip_docs] = true
config[:shallow_clone] = true
config[:git_branch] = 'master'
# clone repo to get path
storage = Match::Storage.for_mode('git', config)
storage.download
encryption = Match::Encryption.for_storage_mode('git', {
git_url: config[:git_url],
working_directory: storage.working_directory
})
encryption.decrypt_files if encryption
UI.success("Repo is at: '#{storage.working_directory}'")
fastlane_directory = Dir.pwd
app_patch = "#{fastlane_directory}/../ipa/AdHoc/#{default_ipa_name}"
# 證書(shū)描述文件備份
FileUtils.cp_r("#{storage.working_directory}/profiles", "#{fastlane_directory}/證書(shū)相關(guān)/")
FileUtils.cp_r("#{storage.working_directory}/certs", "#{fastlane_directory}/證書(shū)相關(guān)/")
# 開(kāi)始重簽
resign(
ipa: app_patch, # can omit if using the `ipa` action
# 證書(shū)的名稱或者證書(shū)的SHA-1
signing_identity: "xxx",
provisioning_profile: "#{storage.working_directory}/profiles/adhoc/AdHoc_xxx.mobileprovision", # can omit if using the _sigh_ action
)
end
signing_identity如何取值, 在終端執(zhí)行, 兩個(gè)值取其一
fastlane sigh resign xxx.ipa