Include tag distance and commit hash in dev versions when possible (#5664)

* Include tag distance and commit hash in dev versions when possible

* Fix test
This commit is contained in:
jack1142
2022-04-03 03:51:34 +02:00
committed by GitHub
parent febca8ccbb
commit 35f1681dc1
6 changed files with 80 additions and 11 deletions

View File

@@ -4,10 +4,11 @@ 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::{redbot.__version__}")
print(f"::set-output name=version::{__version__}")
sys.exit(0)
@@ -33,7 +34,7 @@ def repl(match: Match[str]) -> str:
return f'__version__ = "{version_info}"'
with open("redbot/__init__.py", encoding="utf-8") as fp:
with open("redbot/_version.py", encoding="utf-8") as fp:
new_contents, found = re.subn(
pattern=r'^__version__ = "(?P<version>[^"]*)"$',
repl=repl,
@@ -46,7 +47,7 @@ if not found:
print("Couldn't find `__version__` line!")
sys.exit(1)
with open("redbot/__init__.py", "w", encoding="utf-8", newline="\n") as fp:
with open("redbot/_version.py", "w", encoding="utf-8", newline="\n") as fp:
fp.write(new_contents)
print(f"::set-output name=new_version::{version_info}")