1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
zap/tools/announceybot/announceybot.py
2023-05-21 19:30:30 +02:00

33 lines
781 B
Python

import sys
import os
from discord_webhook import DiscordWebhook
from git import Repo
URL = os.getenv("WEBHOOK_URL")
TAG_NAME = os.getenv("TAG_NAME", sys.argv[1])
def send_to_discord(message):
webhook = DiscordWebhook(url=URL, rate_limit_retry=True, content=message)
if os.getenv("DEBUG", None) == None:
return webhook.execute()
else:
print("Sending ...")
print(message)
def get_tag_annotation(tagname):
repo = Repo('../..')
tag = repo.tags[tagname]
return tag.tag.message
if __name__ == '__main__':
annotation = get_tag_annotation(TAG_NAME)
message = f'''New release {TAG_NAME}!
Updates:
{annotation}
See the release page: https://github.com/zigzap/zap/releases for more information!'''
send_to_discord(message)