Beispiel #1
0
def get_cert(bundle_id, api_token):
    print_split.print_log('发起获取上传凭证请求')
    data = {'type': 'ios', 'bundle_id': bundle_id, 'api_token': api_token}
    print(data)
    req = requests.post(url='http://api.bq04.com/apps', data=data)
    cert_resp = req.content
    print_split.print_log('获取到 fir 响应')
    print(str(cert_resp))
    return cert_resp
Beispiel #2
0
def updateCode(repositoryName, branchName):
    print_split.print_log("updateCode")
    gitResetCommand = 'git reset --hard'
    gitCheckoutCommand = 'git checkout %s' % branchName
    gitBranchCommand = ''
    gitPullCommand = 'git pull'
    gitLogCommand = 'git log -1'
    os.system('%s' % settings.cmd_cd(repositoryName) + ';' + gitResetCommand +
              ';' + gitPullCommand + ';' + gitCheckoutCommand + ';' +
              gitPullCommand + ';' + gitLogCommand)
Beispiel #3
0
def upload_icon(icon, path):
    # 拿到相应的token
    cert_key = icon['key']
    cert_token = icon['token']
    cert_upload_url = icon['upload_url']

    print_split.print_log('上传 icon')
    file = {'file': open(path, 'rb')}
    param = {"key": cert_key, "token": cert_token}
    requests.packages.urllib3.disable_warnings()
    req = requests.post(cert_upload_url, files=file, data=param, verify=False)
    print(req.content)
    return req.content
Beispiel #4
0
def git_clone_repository(repositoryGit):
    print_split.print_log("gitCloneRepository")
    respositoryDir = None
    try:
        (filepath, tempfilename) = os.path.split(repositoryGit)
        (filename, extension) = os.path.splitext(tempfilename)
        respositoryDir = settings.kAutoArchiveRepositoryRootPath + filename
    except:
        print_split.print_war("未配置git仓库地址")
        return

    if (not os.path.exists(respositoryDir)):
        print_split.print_war('git clone ' + repositoryGit + ' ' +
                              respositoryDir)
        os.system('%s' % 'git clone ' + repositoryGit + ' ' + respositoryDir)
    else:
        print_split.print_war("检查到本地git仓库已经存在")
Beispiel #5
0
def upload_fir(binary, path, version, build, changelog):
    # 拿到相应的token
    cert_key = binary['key']
    cert_token = binary['token']
    cert_upload_url = binary['upload_url']

    print_split.print_log('上传 iPA')
    file = {'file': open(path, 'rb')}
    param = {
        "key": cert_key,
        "token": cert_token,
        "x:version": version,
        "x:build": build,
        "x:changelog": changelog
    }
    requests.packages.urllib3.disable_warnings()
    req = requests.post(cert_upload_url, files=file, data=param, verify=False)
    print(req.content)
    return req.content
Beispiel #6
0
def begin_tip(rinputs):
    print_split.print_log('即将开始打包')
    print_split.print_war('当前项目名:' + config.kTargetName())
    print_split.print_war('当前分支:' + config.kBranchName())
Beispiel #7
0
def main_archive(selectType, cmdType):
    # config values
    config_ExportOnly = config.ExportOnly

    config_kRepositoryGit = config.kRepositoryGit()
    config_kRepositoryName = config.kRepositoryName()
    config_kBranchName = config.kBranchName()
    config_kWorkspaceName = config.kWorkspaceName()
    config_kTargetName = config.kTargetName()
    config_kExportOptionName = config.kExportOptionName()
    config_kAppIconName = config.kAppIconName()

    config_kPodFilePath = config.kPodFilePath()
    config_kPodfileForDebugmode = config.kPodfileForDebugmode()
    config_kPodfileForReleasemode = config.kPodfileForReleasemode()

    config_kConfigFilePath = config.kConfigFilePath()
    config_kNetStatusForRCCode = config.kNetStatusForRCCode()
    config_kNetStatusForDisCode = config.kNetStatusForDisCode()
    config_kNetStatusForDevCode = config.kNetStatusForDevCode()

    config_copy_ipa_to_smb = config.copy_ipa_to_smb()
    config_services_path_prefix = config.services_path_prefix()
    config_configvalid_path = config.valid_path()
    config_copy_ipa_to_itc = config.copy_ipa_to_itc()
    config_itc_username = config.itc_username()
    config_itc_password = config.itc_password()
    config_copy_ipa_to_fir = config.copy_ipa_to_fir()
    config_fir_token = config.fir_token()
    config_send_email = config.send_email()
    config_email_SMTP = config.email_SMTP()
    config_email_SMTP_port = config.email_SMTP_port()
    config_email_user = config.email_user()
    config_email_password = config.email_password()
    config_email_sender_name = config.email_sender_name()
    config_email_to_list = config.email_to_list()
    config_email_to_list_itc = config.email_to_list_itc()
    config_email_cc_list = config.email_cc_list()

    # cmdType: -a:自动上传fir
    # 解析配置类型
    print_split.print_log('1.解析配置类型')
    packageType, netType = terminal_input.parser_select_type(selectType)

    # 非调试模式时
    if config.ExportOnly == False:
        # 恢复变化
        pod_tool.discardAllChange(config.kRepositoryName())
        # 下载代码
        pod_tool.git_clone_repository(config.kRepositoryGit())
        # 更新代码
        pod_tool.updateCode(config.kRepositoryName(), config.kBranchName())
        # 校验podfile的debugmode
        code_update.safe_change_podfile_debugmark(
            selectType, config_kPodFilePath, config_kPodfileForDebugmode,
            config_kPodfileForReleasemode)
        # 下载Podfile中的代码
        pod_tool.installPods(config.kRepositoryName())
        # 清理缓存
        pod_tool.cleanProject(config.kRepositoryName(), config.kTargetName())

    # 切换网络环境
    print_split.print_log('2.切换网络环境')
    code_update.safe_change_code_config_network(netType,
                                                config_kConfigFilePath,
                                                config_kNetStatusForDevCode,
                                                config_kNetStatusForDisCode,
                                                config_kNetStatusForRCCode)
    # 解析打包的输出路径
    print_split.print_log('3.解析打包的输出路径')
    xcarchivePath = terminal_input.parser_xcarchive_path(
        config_kRepositoryName, packageType, netType)
    # 打包归档
    if config.ExportOnly == False:
        print_split.print_log('4.打包归档')
        archiveSuccess = xc_tool.archive(config_kRepositoryName,
                                         config_kWorkspaceName, xcarchivePath,
                                         config_kTargetName)
        # 如果打包失败,终止之后的操作
        if not archiveSuccess:
            print_split.print_war('打包失败')
            return
    # 读入info配置
    version, build, bundleid, iconpath = xc_tool.readipainfo(
        xcarchivePath, config_kTargetName, config_kAppIconName)
    # 导出ipa文件,返回ipa文件名(不带扩展名)
    print_split.print_log('5.导出ipa文件')
    exprotFileName, folderPath = xc_tool.exportipa(config_kRepositoryName,
                                                   xcarchivePath,
                                                   config_kTargetName,
                                                   config_kExportOptionName,
                                                   packageType, netType, build)
    # 导出dSYM文件
    print_split.print_log('6.导出dSYM文件')
    xc_tool.exportdSYMFile(exprotFileName, folderPath, config_kTargetName)
    # 备份
    localpath = folderPath + exprotFileName + '.ipa'
    status = print_split.get_log('打包成功')
    status = status + '\n' + '本地地址:\n  ' + localpath

    showServicesPath = ''
    if config_copy_ipa_to_smb:
        print_split.print_log('7.备份到SMB')
        showServicesPath, serviceFileName, alertTitle = auto_smb.uploadipa(
            config_services_path_prefix, config_valid_path, packageType,
            netType, exprotFileName, folderPath, build)
        status = status + '\n' + alertTitle
    # 自动上传/派包
    if cmdType == 'a':
        # 上传到ITC
        if selectType == 4:
            if config_copy_ipa_to_itc:
                print_split.print_log('8.上传到ITC(appstore类型专属)')
                auto_itc.uploaditc(localpath, config_itc_username,
                                   config_itc_password)
                status = status + '\n' + print_split.get_log('已经上传至ITC')
                status = status + '\n' + '是否上传成功,请以苹果邮件和具体情况为准,成功后可进行testflight测试'
        # 上传到FIR
        else:
            if config_copy_ipa_to_fir:
                print_split.print_log('9.上传到FIR')
                downloadurl, operalurl = auto_fir.upload_ipa(
                    config_fir_token, localpath, folderPath + iconpath,
                    bundleid, netType, version, build)
                status = status + '\n' + print_split.get_log('上传FIR成功')
                status = status + '\n' + '请扫码下载:'
                status = status + '\n' + '操作地址:\n  ' + operalurl
                status = status + '\n' + '下载地址:\n  ' + downloadurl
    # 结果
    if config_send_email:
        email_to_list = config_email_to_list if selectType != 3 else config_email_to_list_itc
        # 发邮件
        print_split.print_log('10.发邮件')
        # 打包成功并拷贝到服务器后发送邮件
        se = auto_email.email_create(config_email_SMTP, config_email_SMTP_port,
                                     config_email_user, config_email_password)
        email_subject = '【打包成功】' + 'iOS ' + config_kTargetName + ' ' + build + ' ' + terminal_input.parser_net_name(
            selectType)
        email_content = status
        auto_email.send(se, config_email_sender_name, email_to_list,
                        config_email_cc_list, email_subject, email_content)
    else:
        # 结果弹窗
        print_split.print_log('11.结束')
        alert.show_detail_alert('自动打包结束', folderPath, showServicesPath, True)
Beispiel #8
0
def cleanProject(repositoryName, targetName):
    print_split.print_log("cleanProject")
    cleanCommand = "xcodebuild -target '%s' clean" % targetName
    os.system('%s' % settings.cmd_cd(repositoryName) + ';' + cleanCommand)
Beispiel #9
0
def discardAllChange(repositoryName):
    print_split.print_log("discardAllChange")
    os.system('%s' % settings.cmd_cd(repositoryName) + ';' + 'git checkout .')
Beispiel #10
0
def installPods(repositoryName):
    print_split.print_log("installPods")
    # pod install --verbose --no-repo-update
    os.system('%s' % settings.cmd_cd(repositoryName) + ';' +
              arch_cmd('pod install', isarm64()))