From 70e1653b1a8b7c095e80e7668a06dfd39ffeaced Mon Sep 17 00:00:00 2001 From: TerminalFi Date: Thu, 22 Jun 2023 23:04:42 -0500 Subject: [PATCH 1/2] log prereleases gracefully --- scripts/compare_tags.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/compare_tags.py b/scripts/compare_tags.py index 3ee04dc..8c2175d 100644 --- a/scripts/compare_tags.py +++ b/scripts/compare_tags.py @@ -1,7 +1,7 @@ import re import json import os -from typing import Literal +from typing import Literal, Tuple import urllib.request from urllib.error import URLError @@ -21,7 +21,7 @@ def get_tags(self) -> list: print(f"Error while fetching tags from GitHub API: {e}") exit(1) - def get_latest_version(self, tags: list) -> str: + def get_latest_version(self, tags: list) -> Tuple[str, bool]: for tag in tags: if tag["name"].startswith("gopls/v"): unparsed_version = tag["name"].split("v")[1] @@ -32,10 +32,10 @@ def get_latest_version(self, tags: list) -> str: if version.group(2) is not None: print(f'[get_latest_version] Version is {version.group(1)}-{version.group(2)}') - return f'{version.group(1)}-{version.group(2)}' + return f'{version.group(1)}-{version.group(2)}', True print(f'[get_latest_version] Version is {version.group(1)}') - return version.group(1) + return version.group(1), False print("[get_latest_version] Could not find latest version from tags.") exit(1) @@ -66,8 +66,13 @@ def compare_semantic_versions(self, v1: str, v2: str) -> Literal[0, 1]: def check_for_update(self): tags = self.get_tags() - latest_version = self.get_latest_version(tags) + latest_version, prelease = self.get_latest_version(tags) local_version = self.get_version_locally() + if prelease: + with open(os.environ["GITHUB_OUTPUT"], "a") as fh: + print(f"REQUIRES_UPDATE=0", file=fh) + print(f"LATEST_VERSION={latest_version}", file=fh) + return # Check if update is required requires_update = self.compare_semantic_versions(local_version, latest_version) From c9f647d0107eff3207cd77587d7137664fdf7577 Mon Sep 17 00:00:00 2001 From: TerminalFi Date: Thu, 22 Jun 2023 23:09:02 -0500 Subject: [PATCH 2/2] switch to releases --- scripts/compare_tags.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/compare_tags.py b/scripts/compare_tags.py index 8c2175d..4229a69 100644 --- a/scripts/compare_tags.py +++ b/scripts/compare_tags.py @@ -23,7 +23,7 @@ def get_tags(self) -> list: def get_latest_version(self, tags: list) -> Tuple[str, bool]: for tag in tags: - if tag["name"].startswith("gopls/v"): + if tag["tag_name"].startswith("gopls/v"): unparsed_version = tag["name"].split("v")[1] version = re.search(r"(\d+\.\d+\.\d+)-?(\w+\.\d+)?", unparsed_version) if not version: @@ -84,5 +84,5 @@ def check_for_update(self): print(f"BRANCH_NAME={branch_name}", file=fh) -url = "https://api.github.com/repos/golang/tools/tags" +url = "https://api.github.com/repos/golang/tools/releases" VersionChecker(url=url).check_for_update()