Ejemplo n.º 1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--no-asciidoc',
                        action='store_true',
                        help="Don't generate docs")
    parser.add_argument('--asciidoc',
                        help="Full path to python and "
                        "asciidoc.py. If not given, it's searched in PATH.",
                        nargs=2,
                        required=False,
                        metavar=('PYTHON', 'ASCIIDOC'))
    parser.add_argument('--upload',
                        action='store_true',
                        required=False,
                        help="Toggle to upload the release to GitHub")
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-import
        read_github_token()

    if not misc_checks.check_git():
        utils.print_error("Refusing to do a release with a dirty git tree")
        sys.exit(1)

    if args.no_asciidoc:
        os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
    else:
        run_asciidoc2html(args)

    if os.name == 'nt':
        artifacts = build_windows()
    elif sys.platform == 'darwin':
        artifacts = build_mac()
    else:
        upgrade_sdist_dependencies()
        test_makefile()
        artifacts = build_sdist()
        upload_to_pypi = True

    if args.upload:
        version_tag = "v" + qutebrowser.__version__
        utils.print_title("Press enter to release {}...".format(version_tag))
        input()

        github_upload(artifacts, version_tag)
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)
Ejemplo n.º 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--skip-docs',
                        action='store_true',
                        help="Don't generate docs")
    parser.add_argument('--asciidoc',
                        help="Full path to asciidoc.py. "
                        "If not given, it's searched in PATH.",
                        nargs='?')
    parser.add_argument(
        '--asciidoc-python',
        help="Python to use for asciidoc."
        "If not given, the current Python interpreter is used.",
        nargs='?')
    parser.add_argument('--gh-token', help="GitHub token to use.", nargs='?')
    parser.add_argument('--upload',
                        action='store_true',
                        required=False,
                        help="Toggle to upload the release to GitHub.")
    parser.add_argument('--no-confirm',
                        action='store_true',
                        required=False,
                        help="Skip confirmation before uploading.")
    parser.add_argument('--skip-packaging',
                        action='store_true',
                        required=False,
                        help="Skip Windows installer/zip generation.")
    parser.add_argument('--32bit',
                        action='store_true',
                        required=False,
                        help="Skip Windows 64 bit build.",
                        dest='only_32bit')
    parser.add_argument('--64bit',
                        action='store_true',
                        required=False,
                        help="Skip Windows 32 bit build.",
                        dest='only_64bit')
    parser.add_argument('--debug',
                        action='store_true',
                        required=False,
                        help="Build a debug build.")
    args = parser.parse_args()
    utils.change_cwd()

    upload_to_pypi = False

    if args.upload:
        # Fail early when trying to upload without github3 installed
        # or without API token
        import github3  # pylint: disable=unused-import
        gh_token = read_github_token(args.gh_token)
    else:
        gh_token = read_github_token(args.gh_token, optional=True)

    if not misc_checks.check_git():
        utils.print_error("Refusing to do a release with a dirty git tree")
        sys.exit(1)

    if args.skip_docs:
        os.makedirs(os.path.join('qutebrowser', 'html', 'doc'), exist_ok=True)
    else:
        run_asciidoc2html(args)

    if os.name == 'nt':
        artifacts = build_windows(
            gh_token=gh_token,
            skip_packaging=args.skip_packaging,
            only_32bit=args.only_32bit,
            only_64bit=args.only_64bit,
            debug=args.debug,
        )
    elif sys.platform == 'darwin':
        artifacts = build_mac(gh_token=gh_token, debug=args.debug)
    else:
        test_makefile()
        artifacts = build_sdist()
        twine_check(artifacts)
        upload_to_pypi = True

    if args.upload:
        version_tag = "v" + qutebrowser.__version__

        if not args.no_confirm:
            utils.print_title(
                "Press enter to release {}...".format(version_tag))
            input()

        github_upload(artifacts, version_tag, gh_token=gh_token)
        if upload_to_pypi:
            pypi_upload(artifacts)
    else:
        print()
        utils.print_title("Artifacts")
        for artifact in artifacts:
            print(artifact)