File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -45,21 +45,25 @@ def _get_latest_version():
45
45
req = urllib .request .Request (url , headers = headers )
46
46
try :
47
47
resp = urllib .request .urlopen (req , context = SSL_CONTEXT , timeout = 30 )
48
+ raw = resp .read ().decode ("utf-8" )
49
+ data = json .loads (raw )
50
+ if not data :
51
+ LOGGER .debug ("Releases (raw): %s" , raw )
52
+ raise RuntimeError ("List of releases is empty" )
53
+ for item in data :
54
+ if item ["prerelease" ]:
55
+ continue
56
+ if item .get ("draft" ):
57
+ continue
58
+ return item ["tag_name" ].replace ("v" , "" ).strip ()
59
+ raise RuntimeError (f"Could not find tag name in releases: { data } " )
48
60
except Exception as e :
49
61
LOGGER .warning (
50
62
"Error fetching the latest version, falling back to using git tags"
51
63
)
52
64
LOGGER .warning (str (e ))
53
65
return _get_latest_version_git ()
54
66
55
- data = json .loads (resp .read ().decode ("utf-8" ))
56
- for item in data :
57
- if item ["prerelease" ]:
58
- continue
59
- if item .get ("draft" ):
60
- continue
61
- return item ["tag_name" ].replace ("v" , "" ).strip ()
62
-
63
67
64
68
def _get_latest_version_git ():
65
69
with tempfile .TemporaryDirectory () as td :
You can’t perform that action at this time.
0 commit comments