Ejemplo n.º 1
0
def create_github_release():
    configure_git()
    version = get_project_version()

    if not version:
        print("Unable to determine the current version")
        sys.exit(1)

    tag_exists = (check_exit_code([
        f'git show-ref --tags --quiet --verify -- "refs/tags/{version}"'
    ]) == 0)

    if not tag_exists:
        run_process(["git", "tag", version])
        run_process(["git", "push", "--tags"])

    _, changelog = get_release_info()

    gh_release_create(
        REPO_SLUG,
        version,
        publish=True,
        name=f"{PROJECT_NAME} {version}",
        body=changelog,
        asset_pattern="dist/*",
    )
Ejemplo n.º 2
0
def create_github_release():
    try:
        from github_release import gh_release_create
    except ModuleNotFoundError:
        print("Cannot create GitHub release due to missing dependency: github_release")
        sys.exit(1)

    configure_git()
    version = get_project_version()
    tag = f"{TAG_PREFIX}{version}"

    if not version:
        print("Unable to determine the current version")
        sys.exit(1)

    tag_exists = (
        check_exit_code([f'git show-ref --tags --quiet --verify -- "refs/tags/{tag}"'])
        == 0
    )

    if not tag_exists:
        run_process(["git", "tag", tag])
        run_process(["git", "push", "--tags"])

    _, changelog = get_release_info()

    gh_release_create(
        REPO_SLUG,
        tag,
        publish=True,
        name=f"{PROJECT_NAME} {version}",
        body=changelog,
        asset_pattern="dist/*",
    )
Ejemplo n.º 3
0
def prepare_release():
    configure_git()

    POETRY_DUMP_VERSION_OUTPUT = re.compile(
        r"Bumping version from \d+\.\d+\.\d+ to (?P<version>\d+\.\d+\.\d+)")

    type_, release_changelog = get_release_info()

    output = run_process(["poetry", "version", type_])
    version_match = POETRY_DUMP_VERSION_OUTPUT.match(output)

    if not version_match:
        print("Unable to bump the project version using Poetry")
        sys.exit(1)

    new_version = version_match.group("version")

    if VERSION_STRINGS:
        for version_file in VERSION_STRINGS:
            file_path = ROOT / version_file
            update_version_strings(file_path, new_version)

    current_date = datetime.utcnow().strftime("%Y-%m-%d")

    old_changelog_data = ""
    header = ""

    if not CHANGELOG_FILE.is_file():
        with open(CHANGELOG_FILE, "a+") as f:
            f.write(f"CHANGELOG\n{CHANGELOG_HEADER}\n\n")

    with open(CHANGELOG_FILE, "r") as f:
        lines = f.readlines()

    for index, line in enumerate(lines):
        if CHANGELOG_HEADER != line.strip():
            continue

        old_changelog_data = lines[index + 1:]
        header = lines[:index + 1]
        break

    with open(CHANGELOG_FILE, "w") as f:
        f.write("".join(header))

        new_version_header = f"{new_version} - {current_date}"

        f.write(f"\n{new_version_header}\n")
        f.write(f"{VERSION_HEADER * len(new_version_header)}\n\n")

        f.write(release_changelog)
        append_github_contributor(f)
        f.write("\n")

        f.write("".join(old_changelog_data))
Ejemplo n.º 4
0
import os
import re
import sys
from datetime import datetime

from base import CHANGELOG_FILE, get_release_info, run_process

sys.path.append(os.path.dirname(__file__))  # noqa

if __name__ == "__main__":
    POETRY_DUMP_VERSION_OUTPUT = re.compile(
        r"Bumping version from \d+\.\d+\.\d+ to (?P<version>\d+\.\d+\.\d+)")
    CHANGELOG_HEADER_SEPARATOR = "========="

    type_, release_changelog = get_release_info()

    output = run_process(["poetry", "version", type_])
    version_match = POETRY_DUMP_VERSION_OUTPUT.match(output)

    if not version_match:
        print("Unable to bump the project version using poetry")
        sys.exit(1)

    new_version = version_match.group("version")
    current_date = datetime.utcnow().strftime("%Y-%m-%d")

    old_changelog_data = []
    header = []

    with open(CHANGELOG_FILE, "r") as f:
        lines = f.readlines()
Ejemplo n.º 5
0
    if not version:
        print("Unable to get the current version")
        sys.exit(1)

    tag_exists = (
        check_exit_code(
            [f'git show-ref --tags --quiet --verify -- "refs/tags/{version}"']
        )
        == 0
    )

    if not tag_exists:
        run_process(["git", "tag", version])
        run_process(["git", "push", "--tags"])

    _, changelog = get_release_info()

    project_username = os.environ["CIRCLE_PROJECT_USERNAME"]
    project_reponame = os.environ["CIRCLE_PROJECT_REPONAME"]

    repo_url = f"{project_username}/{project_reponame}"

    gh_release_create(
        repo_url,
        version,
        publish=True,
        name=f"{PROJECT_NAME} {version}",
        body=changelog,
        asset_pattern="dist/*",
    )