Fastlane match管理證書, sigh重簽ipa

使用fastlane match管理證書, 主電腦更新證書和描述文件, 其他電腦同步證書和描述文件
.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)用語言
app_language        = "xxx"

# 開發(fā)者賬號(hào)
apple_id            = "xxx"
# team_id 開發(fā)者中心membership中可以查到
team_id             = "xxx"
# team_name 開發(fā)者中心membership中可以查到
team_name           = "xxx"

# match管理的證書的git倉庫地址
cer_git_url         = "xxx"
# match管理的證書的git倉庫分支, 如master
cer_git_branch      = "xxx"

# 開發(fā)者賬號(hào)
username           = ENV["apple_id"]
# team_id 開發(fā)者中心membership中可以查到
team_id            = ENV["team_id"]
# team_name 開發(fā)者中心membership中可以查到
team_name          = ENV["team_name"]
# match管理的證書的git倉庫地址
git_url            = ENV["cer_git_url"]
# match管理的證書的git倉庫分支
cer_git_branch     = ENV["cer_git_branch"]
# 多個(gè)bundle id, 管理一個(gè)賬號(hào)下多個(gè)應(yīng)用的證書,描述文件
app_identifiers    = ["xxx1", "xxx2", "xxx3"]
# 默認(rèn)ipa名字, 主要用于重簽
default_ipa_name   = "xxx.ipa"
  desc "更新證書描述文件"
  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 "同步證書和描述文件,只讀權(quán)限, 不會(huì)動(dòng)開發(fā)者中心中的證書和描述文件"
  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從倉庫地址拉取最新的證書
    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}"
    # 證書描述文件備份
    FileUtils.cp_r("#{storage.working_directory}/profiles", "#{fastlane_directory}/證書相關(guān)/")
    FileUtils.cp_r("#{storage.working_directory}/certs", "#{fastlane_directory}/證書相關(guān)/")
    # 開始重簽
    resign(
      ipa: app_patch, # can omit if using the `ipa` action
      #   證書的名稱或者證書的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
image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容