(argv)
| 64 | |
| 65 | |
| 66 | def main(argv): |
| 67 | if len(argv) > 1: |
| 68 | tag_name = argv[1] |
| 69 | else: |
| 70 | tag_name = os.environ.get("GITHUB_REF") |
| 71 | if not tag_name: |
| 72 | print("tag_name not given and $GITHUB_REF not set", file=sys.stderr) |
| 73 | return 1 |
| 74 | if tag_name.startswith("refs/tags/"): |
| 75 | tag_name = tag_name[len("refs/tags/") :] |
| 76 | |
| 77 | token = os.environ.get("GH_RELEASE_NOTES_TOKEN") |
| 78 | if not token: |
| 79 | print("GH_RELEASE_NOTES_TOKEN not set", file=sys.stderr) |
| 80 | return 1 |
| 81 | |
| 82 | slug = os.environ.get("GITHUB_REPOSITORY") |
| 83 | if not slug: |
| 84 | print("GITHUB_REPOSITORY not set", file=sys.stderr) |
| 85 | return 1 |
| 86 | |
| 87 | rst_body = parse_changelog(tag_name) |
| 88 | md_body = convert_rst_to_md(rst_body) |
| 89 | if not publish_github_release(slug, token, tag_name, md_body): |
| 90 | print("Could not publish release notes:", file=sys.stderr) |
| 91 | print(md_body, file=sys.stderr) |
| 92 | return 5 |
| 93 | |
| 94 | print() |
| 95 | print(f"Release notes for {tag_name} published successfully:") |
| 96 | print(f"https://github.com/{slug}/releases/tag/{tag_name}") |
| 97 | print() |
| 98 | return 0 |
| 99 | |
| 100 | |
| 101 | if __name__ == "__main__": |
no test coverage detected