mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-12-05 17:02:32 -05:00
Fix invalid version error with _get_version()-provided version (#5670)
* Make sure that the repository we check is in the location we expect * Merge `redbot._version` into `redbot` * Generate VersionInfo in _get_version() This way, if VersionInfo.from_str() generates exception due to invalid version, we catch it.
This commit is contained in:
13
.github/workflows/scripts/bump_version.py
vendored
13
.github/workflows/scripts/bump_version.py
vendored
@@ -4,11 +4,10 @@ import sys
|
||||
from typing import Match
|
||||
|
||||
import redbot
|
||||
from redbot._version import __version__
|
||||
|
||||
|
||||
if int(os.environ.get("JUST_RETURN_VERSION", 0)):
|
||||
print(f"::set-output name=version::{__version__}")
|
||||
print(f"::set-output name=version::{redbot._VERSION}")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
@@ -31,12 +30,12 @@ def repl(match: Match[str]) -> str:
|
||||
version_info.micro += 1
|
||||
version_info.dev_release = 1
|
||||
|
||||
return f'__version__ = "{version_info}"'
|
||||
return f'_VERSION = "{version_info}"'
|
||||
|
||||
|
||||
with open("redbot/_version.py", encoding="utf-8") as fp:
|
||||
with open("redbot/__init__.py", encoding="utf-8") as fp:
|
||||
new_contents, found = re.subn(
|
||||
pattern=r'^__version__ = "(?P<version>[^"]*)"$',
|
||||
pattern=r'^_VERSION = "(?P<version>[^"]*)"$',
|
||||
repl=repl,
|
||||
string=fp.read(),
|
||||
count=1,
|
||||
@@ -44,10 +43,10 @@ with open("redbot/_version.py", encoding="utf-8") as fp:
|
||||
)
|
||||
|
||||
if not found:
|
||||
print("Couldn't find `__version__` line!")
|
||||
print("Couldn't find `_VERSION` line!")
|
||||
sys.exit(1)
|
||||
|
||||
with open("redbot/_version.py", "w", encoding="utf-8", newline="\n") as fp:
|
||||
with open("redbot/__init__.py", "w", encoding="utf-8", newline="\n") as fp:
|
||||
fp.write(new_contents)
|
||||
|
||||
print(f"::set-output name=new_version::{version_info}")
|
||||
|
||||
Reference in New Issue
Block a user