altlinux-autorepacked/autorepacked/common_providers/github_releases_provider.py
2024-01-17 15:36:11 +03:00

36 lines
896 B
Python

import re
from autorepacked import utils
from autorepacked.common_providers.base_provider import BaseProvider
class GithubReleasesProvider(BaseProvider):
_repo = ''
def _last_release_url(self):
return utils.eget([
'--get-real-url',
f'https://github.com/{self._repo}/releases/latest'
])
def _last_tag_name(self):
return self.get_version()
def _get_release_filename(self):
return ''
def get_version(self):
url = self._last_release_url()
pattern = r'\d+\.\d+\.\d+'
match = re.search(pattern, url)
if match:
return match.group()
else:
return "not found"
def get_download_url(self):
return (f"https://github.com/"
f"{self._repo}/releases/download/"
f"{self._last_tag_name()}/{self._get_release_filename()}")