You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.4 KiB
52 lines
1.4 KiB
from discord_webhook import DiscordWebhook, DiscordEmbed
|
|
import sys
|
|
|
|
version = sys.argv[1]
|
|
if not version:
|
|
print('Pass version as first argument')
|
|
exit(1)
|
|
|
|
webhook_url = sys.argv[2]
|
|
if not webhook_url:
|
|
print('Pass webhook URL as second argument')
|
|
exit(1)
|
|
|
|
changelog = sys.argv[3]
|
|
if not changelog:
|
|
print('Pass path to changelog file as third argument')
|
|
exit(1)
|
|
|
|
with open(changelog, 'r') as f:
|
|
changelog_text = f.read()
|
|
|
|
mkdown_desc = f'''
|
|
**Release Notes**
|
|
```
|
|
{changelog_text}
|
|
```
|
|
'''
|
|
|
|
embed = DiscordEmbed(
|
|
title=f'New Release {version}',
|
|
description=mkdown_desc,
|
|
url=f'https://github.com/recyclarr/recyclarr/releases/tag/{version}'
|
|
)
|
|
|
|
embed.set_author(
|
|
name='Recyclarr',
|
|
url='https://github.com/recyclarr/recyclarr',
|
|
icon_url='https://github.com/recyclarr/recyclarr/blob/master/ci/notify/trash-icon.png?raw=true')
|
|
|
|
def add_links(os_name, archs, os):
|
|
url_base = f'https://github.com/recyclarr/recyclarr/releases/download/{version}'
|
|
download_links = ', '.join(f'[{arch}]({url_base}/recyclarr-{os}-{arch}.zip)' for arch in archs)
|
|
embed.add_embed_field(name=os_name, value=f'[{download_links}]')
|
|
|
|
add_links('Linux', ('x64', 'arm', 'arm64'), 'linux')
|
|
add_links('Windows', ('x64', 'arm64'), 'win')
|
|
add_links('MacOS', ('x64', 'arm64'), 'osx')
|
|
|
|
webhook = DiscordWebhook(webhook_url)
|
|
webhook.add_embed(embed)
|
|
print(webhook.execute())
|