diff --git a/generate_release_files.py b/generate_release_files.py index 3a7ec11..74fde66 100755 --- a/generate_release_files.py +++ b/generate_release_files.py @@ -34,9 +34,15 @@ def extract_repo_from_gitea_url(url: str) -> Optional[Tuple[str, str, str]]: return (match.group(1), match.group(2), match.group(3)) return None -def get_latest_tag_github(owner: str, repo: str) -> Optional[str]: - """Fetch the latest release tag from GitHub API.""" - url = f"{GITHUB_API}/{owner}/{repo}/releases?per_page=1" +def get_latest_tag_github(owner: str, repo: str, stable_only: bool = False) -> Optional[str]: + """Fetch the latest release tag from GitHub API. + With stable_only=True, uses /releases/latest (skips pre-releases), matching + INI entries that download from that endpoint. + """ + if stable_only: + url = f"{GITHUB_API}/{owner}/{repo}/releases/latest" + else: + url = f"{GITHUB_API}/{owner}/{repo}/releases?per_page=1" try: req = urllib.request.Request(url) req.add_header('User-Agent', 'Release-Tag-Fetcher/1.0') @@ -44,6 +50,8 @@ def get_latest_tag_github(owner: str, repo: str) -> Optional[str]: req.add_header('Authorization', f'token {GITHUB_TOKEN}') with urllib.request.urlopen(req, timeout=10) as response: releases = json.loads(response.read().decode('utf-8')) + if isinstance(releases, dict): + releases = [releases] if releases and len(releases) > 0: return releases[0].get('tag_name', releases[0].get('name', '')) except urllib.error.HTTPError as e: @@ -80,7 +88,8 @@ def get_latest_tag(entry: Dict[str, Any]) -> Optional[str]: """Fetch the latest release tag from GitHub or Gitea depending on entry source.""" if entry.get('source') == 'gitea': return get_latest_tag_gitea(entry['api_base'], entry['owner'], entry['repo']) - return get_latest_tag_github(entry['owner'], entry['repo']) + stable_only = '/releases/latest' in entry.get('url', '') + return get_latest_tag_github(entry['owner'], entry['repo'], stable_only) def parse_ini_file(file_path: Path, strip_version_suffix: bool = True) -> List[Dict[str, Any]]: """Parse .ini file and extract entries with GitHub or Gitea API URLs. diff --git a/include/sysmodules/sysmodules.ini b/include/sysmodules/sysmodules.ini index 4e113b4..48e4ace 100644 --- a/include/sysmodules/sysmodules.ini +++ b/include/sysmodules/sysmodules.ini @@ -54,6 +54,15 @@ unzip /config/ultrahand/downloads/saltynx.zip / delete /config/ultrahand/downloads/saltynx-api.json delete /config/ultrahand/downloads/saltynx.zip +[Switch-Frame-Tap - 0.7.23] +try: +download https://api.github.com/repos/TomasUribe/switch-frame-tap/releases/latest /config/ultrahand/downloads/switch-frame-tap-api.json +json_file /config/ultrahand/downloads/switch-frame-tap-api.json +download {json_file(assets,6,browser_download_url)} /config/ultrahand/downloads/switch-frame-tap.zip +unzip /config/ultrahand/downloads/switch-frame-tap.zip / +delete /config/ultrahand/downloads/switch-frame-tap-api.json +delete /config/ultrahand/downloads/switch-frame-tap.zip + [sys-botbase - 2.5] try: download https://api.github.com/repos/olliz0r/sys-botbase/releases?per_page=1 /config/ultrahand/downloads/sys-botbase-api.json