def dist_github():
    import requests
    import keyring
    import getpass
    version = get_version()
    version_tuple = version.split(".")
    changes_since_last_version = ["* __{}__: {}".format(key, "\n".join(changes)) for key, changes in get_changelog().items() if key.startswith("{}.{}".format(*version_tuple))]
    changes_since_last_version = "\n".join(sorted(changes_since_last_version, reverse=True))
    payload = {
        "tag_name": version,
        "target_commitish": "master",
        "name": version,
        "body": "Changes in Version {}.{}: \n\n{}".format(version_tuple[0], version_tuple[1], changes_since_last_version)
    }
    print("Preparing release {}...".format(version))
    username = keyring.get_password("github", "__default_user") or raw_input("Github username: ")
    password = keyring.get_password("github", username) or getpass.getpass()
    otp = raw_input("One Time Token: ")
    response = requests.post("https://api.github.com/repos/maebert/jrnl/releases", headers={"X-GitHub-OTP": otp}, json=payload, auth=(username, password))
    if response.status_code in (403, 404):
        print("Authentication error.")
    else:
        keyring.set_password("github", "__default_user", username)
        keyring.set_password("github", username, password)
        if response.status_code > 299:
            if  "message" in response.json():
                print("Error: {}".format(response.json()['message']))
                for error_dict in response.json().get('errors', []):
                    print("*", error_dict)
            else:
                print("Unkown error")
                print(response.text)
        else:
            print("Release created.")
    sys.exit()
Creates a release on the maebert/jrnl repository on github
dataset/ETHPy150Open maebert/jrnl/setup.py/dist_github