Exemplo n.º 1
0
def build(args, output_dir, release, github_token, homebrew_dir):
    deb_file = args.deb_file
    chocolatey_file = args.chocolatey_file
    homebrew_file = args.homebrew_file

    if args.build_deb:
        user = get_current_user(github_token)
        releases = get_all_releases(args.repository, github_token)
        deb_file = build_deb(
            args.repository, release, user, releases, args.docker_linux_host, output_dir
        )
    if args.build_homebrew:
        homebrew_file = build_bottle(
            homebrew_dir,
            release,
            args.tap_repository,
            args.homebrew_target_macos_version,
            args.homebrew_target_macos_version_spec,
            output_dir,
        )
    if args.build_chocolatey:
        chocolatey_file = build_chocolatey(
            args.repository, release, args.docker_windows_host, output_dir
        )

    return deb_file, homebrew_file, chocolatey_file
Exemplo n.º 2
0
def build(args, output_dir, release, github_token, homebrew_dir):
    deb_file = args.deb_file
    chocolatey_file = args.chocolatey_file
    homebrew_file = args.homebrew_file

    if args.build_deb:
        user = get_current_user(github_token)
        releases = get_all_releases(args.repository, github_token)
        deb_file = build_deb(args.repository, release, user, releases,
                             args.docker_linux_host, output_dir)
    if args.build_homebrew:
        homebrew_file = build_bottle(
            homebrew_dir,
            release,
            args.repository,
            args.tap_repository,
            args.homebrew_target_macos_version,
            args.homebrew_target_macos_version_spec,
            output_dir,
        )
    if args.build_chocolatey:
        chocolatey_file = build_chocolatey(
            args.repository,
            release,
            args.docker_windows_host,
            args.docker_windows_memory,
            args.docker_windows_isolation,
            output_dir,
        )

    return deb_file, homebrew_file, chocolatey_file
Exemplo n.º 3
0
def push_tap(git_repository, tap_path, version, github_token):
    """
    Grab any working directory changes for the tap, clone a new tap repository,
    and push those changes upstream. The original tap path is in a clean state
    after this push. The clone is done with ssh, so ssh keys must be available

    Args:
        git_repository: The repo on github that needs to be cloned/pushed to
        tap_path: The directory that the tap (with changes) exists in
        version: The version to use in commit messages
    """
    logging.info("Gathering git diff from {}".format(tap_path))
    git_diff = run(["git", "diff"], tap_path, True).stdout
    user = get_current_user(github_token)
    git_url = "https://{}:{}@github.com/{}.git".format(user["login"],
                                                       github_token,
                                                       git_repository)

    with tempfile.TemporaryDirectory() as temp_dir:
        logging.info("Cloning {} into {}".format(git_url, temp_dir))
        run(["git", "clone", git_url, temp_dir])

        logging.info("Cloned into {}. Applying patch".format(temp_dir))
        run(["git", "apply", "-"], temp_dir, input=git_diff)

        logging.info("Committing...")
        with tempfile.NamedTemporaryFile() as fout:
            commit_message = (
                "Bump buck to version {}\n\nThis commit was generated by "
                "release automation\n").format(version)
            fout.write(commit_message.encode("utf-8"))
            fout.flush()
            run(["git", "commit", "-F", fout.name, "buck.rb"], temp_dir)

        logging.info("Pushing commit upstream")
        run(["git", "push", "origin"], temp_dir)
        logging.info("Pushed commit upstream!")

    logging.info(
        "Resetting state of {}, and updating it after push".format(tap_path))
    run(["git", "checkout", "buck.rb"], tap_path)
    run(["git", "checkout", "master"], tap_path)
    run(["git", "pull"], tap_path)
    logging.info(
        "Reset state of {}, and updating it after push".format(tap_path))