Files
packages/anda/rust/rnote/chkupdate.py
T
windowsboy111 16e4f74ea9 Add others/
2022-12-04 10:26:59 +08:00

21 lines
611 B
Python

import os
import requests
import re
NAME = 'rnote'
REPO = "flxzt/rnote"
REGEX_VER = r'Version:\s*([\.\d]+)\n'
SPEC = f"{NAME}.spec"
LINK = f'https://api.github.com/repos/{REPO}/releases/latest'
ver = requests.get(LINK, headers={'Authorization': 'Bearer ' + os.getenv('GITHUB_TOKEN')}).json()['tag_name']
ver = ver[1:] # starts with v
with open(SPEC, 'r') as f:
matches = re.findall(REGEX_VER, f.read())
if not len(matches): exit(f"{NAME}: Failed to match regex!")
cur = matches[0]
if ver == cur: exit(f'{NAME}: Up to date!')
print(f'{NAME}: {cur} -> {ver}')
os.system(f'rpmdev-bumpspec -n {ver} {SPEC}')