Esempio n. 1
0
def main() -> None:
    """
    Script entry point.
    """
    # Generate changelog for PRs merged yesterday
    merged_date = dt.date.today() - dt.timedelta(days=1)
    repo = Github(login_or_token=GITHUB_TOKEN).get_repo(GITHUB_REPO)
    merged_pulls = list(iter_pulls(repo, merged_date))
    print(f"Merged pull requests: {merged_pulls}")
    if not merged_pulls:
        print("Nothing was merged, existing.")
        return

    # Group pull requests by type of change
    grouped_pulls = group_pulls_by_change_type(merged_pulls)

    # Generate portion of markdown
    release_changes_summary = generate_md(grouped_pulls)
    print(f"Summary of changes: {release_changes_summary}")

    # Update CHANGELOG.md file
    release = f"{merged_date:%Y.%m.%d}"
    changelog_path = ROOT / "CHANGELOG.md"
    write_changelog(changelog_path, release, release_changes_summary)
    print(f"Wrote {changelog_path}")

    # Update version
    setup_py_path = ROOT / "setup.py"
    update_version(setup_py_path, release)
    print(f"Updated version in {setup_py_path}")

    # Commit changes, create tag and push
    update_git_repo([changelog_path, setup_py_path], release)

    # Create GitHub release
    github_release = repo.create_git_release(
        tag=release,
        name=release,
        message=release_changes_summary,
    )
    print(f"Created release on GitHub {github_release}")