コード例 #1
0
def determine_kokoro_job_name(ctx: TagContext) -> None:
    if ctx.upstream_repo in nodejs_handle_publish:
        ctx.kokoro_job_name = (
            f"cloud-devrel/client-libraries/nodejs/release/{ctx.upstream_repo}/publish"
        )
    else:
        ctx.kokoro_job_name = (
            f"cloud-devrel/client-libraries/nodejs/release/{ctx.upstream_repo}/docs"
        )
コード例 #2
0
ファイル: ruby.py プロジェクト: codyoss/releasetool
def tag(ctx: TagContext = None) -> TagContext:
    if not ctx:
        ctx = TagContext()

    if ctx.interactive:
        click.secho(
            f"o/ Hey, {getpass.getuser()}, let's tag a Ruby release!", fg="magenta"
        )

    if ctx.github is None:
        releasetool.commands.common.setup_github_context(ctx)

    if ctx.release_pr is None:
        determine_release_pr(ctx)

    determine_release_tag(ctx)
    determine_package_name_and_version(ctx)

    # If the release already exists, don't do anything
    if releasetool.commands.common.release_exists(ctx):
        click.secho(f"{ctx.release_tag} already exists.", fg="magenta")
        return ctx

    get_release_notes(ctx)

    create_release(ctx)

    if "google-cloud-ruby" in ctx.upstream_repo:
        job_name = ctx.package_name.split("google-cloud-")[-1]
        ctx.kokoro_job_name = (
            f"cloud-devrel/client-libraries/google-cloud-ruby/release/{job_name}"
        )
    elif "google-api-ruby-client" in ctx.upstream_repo:
        ctx.kokoro_job_name = f"cloud-devrel/client-libraries/google-api-ruby-client/release/{ctx.package_name}"
    else:
        ctx.kokoro_job_name = (
            f"cloud-devrel/client-libraries/{ctx.package_name}/release"
        )

    releasetool.commands.common.publish_via_kokoro(ctx)

    if ctx.interactive:
        click.secho("\\o/ All done!", fg="magenta")

    branch = ctx.release_pr["head"]["ref"]

    try:
        ctx.github.delete_branch(repository=ctx.upstream_repo, branch=branch)
        click.secho(f"Deleted branch {branch}")
    # If user has already deleted the branch, this will fail.
    except HTTPError as exc:
        if exc.response.status_code != 422:
            click.secho(f"{exc!r}")

    return ctx
コード例 #3
0
def tag(ctx: TagContext = None) -> TagContext:
    if not ctx:
        ctx = TagContext()

    if ctx.interactive:
        click.secho(f"o/ Hey, {getpass.getuser()}, let's tag a release!",
                    fg="magenta")

    if ctx.github is None:
        releasetool.commands.common.setup_github_context(ctx)

    if ctx.release_pr is None:
        python.determine_release_pr(ctx)

    python.determine_release_tag(ctx)
    python.determine_package_version(ctx)

    # If the release already exists, don't do anything
    if releasetool.commands.common.release_exists(ctx):
        click.secho(f"{ctx.release_tag} already exists.", fg="magenta")
        return ctx

    get_release_notes(ctx)

    create_release(ctx)

    ctx.kokoro_job_name = kokoro_job_name(ctx.upstream_repo, ctx.package_name)
    releasetool.commands.common.publish_via_kokoro(ctx)

    if ctx.interactive:
        click.secho("\\o/ All done!", fg="magenta")

    return ctx
コード例 #4
0
ファイル: java.py プロジェクト: portintegration/releasetool
def create_release(ctx: TagContext) -> None:
    click.secho("> Creating the release.")

    ctx.github_release = ctx.github.create_release(
        repository=ctx.upstream_repo,
        tag_name=ctx.release_tag,
        target_commitish=ctx.release_pr["merge_commit_sha"],
        name=ctx.release_tag,
        body=ctx.release_notes,
    )

    release_location_string = f"Release is at {ctx.github_release['html_url']}"
    click.secho(release_location_string)

    ctx.github.create_pull_request_comment(
        ctx.upstream_repo, ctx.release_pr["number"], release_location_string
    )

    repo_short_name = ctx.upstream_repo.split("/")[-1]
    ctx.kokoro_job_name = (
        f"cloud-devrel/client-libraries/java/{repo_short_name}/release/stage"
    )
    ctx.github.update_pull_labels(
        ctx.release_pr, add=["autorelease: tagged"], remove=["autorelease: pending"]
    )
    releasetool.commands.common.publish_via_kokoro(ctx)
コード例 #5
0
def tag(ctx: TagContext = None) -> TagContext:
    if not ctx:
        ctx = TagContext()

    if ctx.interactive:
        click.secho(f"o/ Hey, {getpass.getuser()}, let's tag a release!",
                    fg="magenta")

    if ctx.github is None:
        releasetool.commands.common.setup_github_context(ctx)

    if ctx.release_pr is None:
        determine_release_pr(ctx)

    determine_release_tag(ctx)
    determine_package_name_and_version(ctx)

    # If the release already exists, don't do anything
    if releasetool.commands.common.release_exists(ctx):
        click.secho(f"{ctx.release_tag} already exists.", fg="magenta")
        return ctx

    get_release_notes(ctx)

    create_release(ctx)

    ctx.kokoro_job_name = (
        f"cloud-devrel/client-libraries/google-cloud-python/release/{ctx.package_name}"
    )
    releasetool.commands.common.publish_via_kokoro(ctx)

    if ctx.interactive:
        click.secho(f"\\o/ All done!", fg="magenta")

    return ctx
コード例 #6
0
def create_releases(ctx: TagContext) -> None:
    click.secho("> Creating the release.")

    commitish = ctx.release_pr["merge_commit_sha"]
    title = ctx.release_pr["title"]
    body_lines = ctx.release_pr["body"].splitlines()
    all_lines = [title] + body_lines
    pr_comment = ""
    for line in all_lines:
        match = re.search(RELEASE_LINE_PATTERN, line)
        if match is not None:
            package = match.group(1)
            version = match.group(2)
            tag = package + "-" + version
            ctx.github.create_release(
                repository=ctx.upstream_repo,
                tag_name=tag,
                target_commitish=commitish,
                name=f"{package} version {version}",
                # TODO: either reformat the message as we do in TagReleases,
                # or make sure we create the PR with an "already-formatted"
                # body. (The latter is probably simpler, and will make the
                # PR easier to read anyway.)
                body=ctx.release_pr["body"],
                # Versions like "1.0.0-beta01" or "0.9.0" are prerelease
                prerelease="-" in version or version.startswith("0."),
            )
            click.secho(f"Created release for {tag}")
            pr_comment = pr_comment + f"- Created release for {tag}\n"

    if pr_comment == "":
        raise ValueError("No releases found within pull request")

    ctx.github.create_pull_request_comment(
        ctx.upstream_repo, ctx.release_pr["number"], pr_comment
    )

    # This isn't a tag, but that's okay - it just needs to be a commitish for
    # Kokoro to build against.
    ctx.release_tag = commitish

    repo_short_name = ctx.upstream_repo.split("/")[-1]
    ctx.kokoro_job_name = f"cloud-sharp/{repo_short_name}/gcp_windows/autorelease"
    ctx.github.update_pull_labels(
        ctx.release_pr, add=["autorelease: tagged"], remove=["autorelease: pending"]
    )
    releasetool.commands.common.publish_via_kokoro(ctx)
コード例 #7
0
def tag(ctx: TagContext = None) -> TagContext:
    if not ctx:
        ctx = TagContext()

    if ctx.interactive:
        click.secho(f"o/ Hey, {getpass.getuser()}, let's tag a release!", fg="magenta")

    if ctx.github is None:
        releasetool.commands.common.setup_github_context(ctx)

    # delegate releaase tagging to release-please
    default_branch = ctx.release_pr["base"]["ref"]
    repo = ctx.release_pr["base"]["repo"]["full_name"]

    with tempfile.NamedTemporaryFile("w+t", delete=False) as fp:
        fp.write(ctx.token)
        token_file = fp.name

    output = subprocess.check_output(
        [
            "npx",
            "release-please",
            "github-release",
            f"--token={token_file}",
            f"--default-branch={default_branch}",
            "--release-type=java-yoshi",
            "--bump-minor-pre-major=true",
            f"--repo-url={repo}",
            "--package-name=",
            "--debug",
        ]
    )

    ctx.release_tag = _parse_release_tag(output.decode("utf-8"))
    ctx.kokoro_job_name = kokoro_job_name(ctx.upstream_repo, ctx.package_name)

    if ctx.interactive:
        click.secho("\\o/ All done!", fg="magenta")

    return ctx
コード例 #8
0
def tag(ctx: TagContext = None) -> TagContext:
    if not ctx:
        ctx = TagContext()

    if ctx.interactive:
        click.secho(f"o/ Hey, {getpass.getuser()}, let's tag a release!", fg="magenta")

    if ctx.github is None:
        releasetool.commands.common.setup_github_context(ctx)

    if ctx.release_pr is None:
        determine_release_pr(ctx)

    determine_release_tag(ctx)
    determine_package_name_and_version(ctx)

    # If the release already exists, don't do anything
    if releasetool.commands.common.release_exists(ctx):
        click.secho(f"{ctx.release_tag} already exists.", fg="magenta")
        return ctx

    get_release_notes(ctx)
    create_release(ctx)

    # Only enable release job triggering on google-auth-library-java for now.
    if ctx.upstream_repo == "googleapis/google-auth-library-java":
        ctx.kokoro_job_name = (
            "cloud-devrel/client-libraries/java/google-auth-library-java/release/stage"
        )
        # TODO: Move to create_release once autorelease is enabled for all
        # java repositories
        ctx.github.update_pull_labels(
            ctx.release_pr, add=["autorelease: tagged"], remove=["autorelease: pending"]
        )
        releasetool.commands.common.publish_via_kokoro(ctx)

    if ctx.interactive:
        click.secho(f"\\o/ All done!", fg="magenta")

    return ctx
コード例 #9
0
ファイル: dotnet.py プロジェクト: steffnay/releasetool
def create_releases(ctx: TagContext) -> None:
    click.secho("> Creating the release.")

    commitish = ctx.release_pr["merge_commit_sha"]
    lines = ctx.release_pr["body"].splitlines()
    pr_comment = ""
    for line in lines:
        match = re.search(RELEASE_LINE_PATTERN, line)
        if match is not None:
            package = match.group(1)
            version = match.group(2)
            tag = package + "-" + version
            ctx.github.create_release(
                repository=ctx.upstream_repo,
                tag_name=tag,
                target_commitish=commitish,
                name=tag,
                body=f"Package {package} version {version}",
                # Versions like "1.0.0-beta01" or "0.9.0" are prerelease
                prerelease="-" in version or version.startswith("0."),
            )
            click.secho(f"Created release for {tag}")
            pr_comment = pr_comment + f"- Created release for {tag}\n"

    if pr_comment == "":
        raise ValueError("No releases found within pull request")

    ctx.github.create_pull_request_comment(ctx.upstream_repo,
                                           ctx.release_pr["number"],
                                           pr_comment)

    # This isn't a tag, but that's okay - it just needs to be a commitish for
    # Kokoro to build against.
    ctx.release_tag = commitish
    ctx.kokoro_job_name = f"cloud-sharp/google-cloud-dotnet/gcp_windows/autorelease"
    ctx.github.update_pull_labels(ctx.release_pr,
                                  add=["autorelease: tagged"],
                                  remove=["autorelease: pending"])
    releasetool.commands.common.publish_via_kokoro(ctx)
コード例 #10
0
ファイル: nodejs.py プロジェクト: igorbernstein2/releasetool
def tag(ctx: TagContext = None) -> TagContext:
    if not ctx:
        ctx = TagContext()

    if ctx.interactive:
        click.secho(f"o/ Hey, {getpass.getuser()}, let's tag a release!",
                    fg="magenta")

    if ctx.github is None:
        releasetool.commands.common.setup_github_context(ctx)

    if ctx.release_pr is None:
        determine_release_pr(ctx)

    # If using manifest release, the manifest releaser determines
    # release tag, version, and release notes:
    if ctx.upstream_repo not in manifest_release:
        determine_release_tag(ctx)
        determine_package_version(ctx)
        # If the release already exists, don't do anything
        if releasetool.commands.common.release_exists(ctx):
            click.secho(f"{ctx.release_tag} already exists.", fg="magenta")
            return ctx
        get_release_notes(ctx)
    else:
        # If using mono-release strategy, fallback to using sha from
        # time of merge:
        ctx.release_tag = ctx.release_pr["merge_commit_sha"]

    create_release(ctx)
    ctx.kokoro_job_name = kokoro_job_name(ctx.upstream_repo, ctx.package_name)
    releasetool.commands.common.publish_via_kokoro(ctx)

    if ctx.interactive:
        click.secho("\\o/ All done!", fg="magenta")

    return ctx