Tools for GitHub releases

get_repo_name[source]

get_repo_name(git_url)

Get repo name out of git_url

assert get_repo_name("https://github.com/PabloRMira/easyrelease") == "PabloRMira/easyrelease"
assert get_repo_name("https://github.com/PabloRMira/easyrelease/tree/main") == "PabloRMira/easyrelease"
assert get_repo_name("https://github.enterprise.com/PabloRMira/easyrelease/tree/main") == "PabloRMira/easyrelease"

get_base_repo_url[source]

get_base_repo_url(git_url)

Get base repo URL from git_url

assert get_base_repo_url("https://github.com/PabloRMira/easyrelease") == "https://github.com/PabloRMira/easyrelease"
assert (
    get_base_repo_url(
        "https://github.com/PabloRMira/easyrelease/tree/main"
    ) == "https://github.com/PabloRMira/easyrelease"
)

write_gh_template[source]

write_gh_template()

Write GitHub template for assigning commit messages to categories

get_last_tag[source]

get_last_tag()

Get last git tag. If there is no tag, then it outputs the first commit hash

get_commit_msgs[source]

get_commit_msgs(from_tag=None, to='HEAD')

Get commits from_tag to to. If from_tag is None then it will get the commits from latest tag

add_pull_request_link(msg)

Add pull request link to commit message s if reference is found, e.g. #100

if not check_git_dir():
    os.chdir("..")  # we need this if we test locally in the notebook itself
msg = "* [FIX] Some bug (#100)"
msg_link = add_pull_request_link(msg)
expected_msg_link = "* [FIX] Some bug ([#100](https://github.com/PabloRMira/easyrelease/pull/100))"
assert msg_link == expected_msg_link

release_report[source]

release_report(gh_config, commit_msgs, report_title='')

Get release report using report_title, commit messages commit_msgs and GitHub config gh_config

if not check_git_dir:
    os.chdir("..")  # we need this if we test locally in the notebook itself
commit_msgs = [
    "[FIX] Some bug",
    "[FEA] My new feature"
]
gh_config = {"gh_categories": 
             [{"title": "Bugfixes:", "keyword": "[FIX]"},
              {"title": "New features:", "keyword": "[FEA]"}]}
report = release_report(gh_config, commit_msgs, "Nice title!")
expected_report = "Nice title!\n\nBugfixes:\n* [FIX] Some bug\n\nNew features:\n* [FEA] New features"

get_gh_credentials[source]

get_gh_credentials()

Get GitHub credentials from file .gh-credentials

get_tags[source]

get_tags()

Get git tags as list. If multiple tags in one commit, then it puts them into a tuple

get_gh_config[source]

get_gh_config()

Get GitHub config

make_gh_release[source]

make_gh_release(draft=False, prerelease=False)

Make a GitHub release. Indicate if there is a draft or a prerelease with default False both

make_changelog[source]

make_changelog()

Generate CHANGELOG.md file with release notes