def METHOD_NAME(
    repo_org: str,
    repo_name: str,
    tag_name: str,
    github_token: str,
    target_commit: str,
    previous_tag: str = None,
):
    """
    Generate release notes using the GitHub API.
    """
    request = {"tag_name": tag_name, "target_commitish": target_commit}
    if previous_tag:
        request["previous_tag_name"] = previous_tag
    response = httpx.post(
        f"https://api.github.com/repos/{repo_org}/{repo_name}/releases/generate-notes",
        headers={
            "Accept": "application/vnd.github+json",
            "Authorization": f"Bearer {github_token}",
        },
        json=request,
    )
    if not response.status_code == 200:
        print(
            "Received status code {response.status_code} from GitHub API:",
            file=sys.stderr,
        )
        print(response.json(), file=sys.stderr)
        exit(1)
    release_notes = response.json()["body"]
    # Drop the generated by section
    release_notes = "\n".join(release_notes.splitlines()[2:])
    # Add newlines before all categories
    release_notes = release_notes.replace("\n###", "\n\n###")
    # Update what's new to release name
    release_notes = release_notes.replace("## What's Changed", f"## Release {tag_name}")
    # Parse all entries
    entries = ENTRY_REGEX.findall(release_notes)
    # Generate a contributors section
    contributors = ""
    for contributor in sorted(set(user for _, user, _ in entries)):
        contributors += f"\n- @{contributor}"
    # Replace the heading of the existing contributors section; append contributors
    release_notes = release_notes.replace(
        "\n**Full Changelog**:",
        "### Contributors" + contributors + "\n\n**All changes**:",
    )
    # Strip contributors from individual entries
    release_notes = ENTRY_REGEX.sub(
        lambda match: f"- {match.group(1)} — {match.group(3)}",
        release_notes,
    )
    print(release_notes)