美文网首页
Fastlane match管理证书, sigh重签ipa

Fastlane match管理证书, sigh重签ipa

作者: JohnSnow_b20c | 来源:发表于2020-05-31 09:17 被阅读0次

    使用fastlane match管理证书, 主电脑更新证书和描述文件, 其他电脑同步证书和描述文件
    .env文件配置

    # bundle id
    app_identifier      = "xxx"
    
    # 创建应用的时候用到
    # 应用名称
    app_name            = "xxx"
    # 应用版本号
    app_version         = "xxx"
    # 应用语言
    app_language        = "xxx"
    
    # 开发者账号
    apple_id            = "xxx"
    # team_id 开发者中心membership中可以查到
    team_id             = "xxx"
    # team_name 开发者中心membership中可以查到
    team_name           = "xxx"
    
    # match管理的证书的git仓库地址
    cer_git_url         = "xxx"
    # match管理的证书的git仓库分支, 如master
    cer_git_branch      = "xxx"
    
    
    # 开发者账号
    username           = ENV["apple_id"]
    # team_id 开发者中心membership中可以查到
    team_id            = ENV["team_id"]
    # team_name 开发者中心membership中可以查到
    team_name          = ENV["team_name"]
    # match管理的证书的git仓库地址
    git_url            = ENV["cer_git_url"]
    # match管理的证书的git仓库分支
    cer_git_branch     = ENV["cer_git_branch"]
    # 多个bundle id, 管理一个账号下多个应用的证书,描述文件
    app_identifiers    = ["xxx1", "xxx2", "xxx3"]
    # 默认ipa名字, 主要用于重签
    default_ipa_name   = "xxx.ipa"
    
      desc "更新证书描述文件"
      lane :createCerAndProvisionFile do
        register_devices(
          # 需要添加的设备
          devices: {
            "设备名称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 "同步证书和描述文件,只读权限, 不会动开发者中心中的证书和描述文件"
      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|
        # 先添加设备
        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}/证书相关/")
        FileUtils.cp_r("#{storage.working_directory}/certs", "#{fastlane_directory}/证书相关/")
        # 开始重签
        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如何取值, 在终端执行, 两个值取其一

    fastlane sigh resign xxx.ipa
    
    image.png

    相关文章

      网友评论

          本文标题:Fastlane match管理证书, sigh重签ipa

          本文链接:https://www.haomeiwen.com/subject/lhheoqtx.html