jack1142 c5fbf5fb94
Change things up with Crowdin and release-related workflows (#4833)
* Alternative way of doing Crowdin...

* Limit the upload translations workflow to V3/develop

* Make the workflow close and reopen the PR automatically while I'm at it

* Add a workflow for preparing PRs for release

* Make the crowdin env vars local to the step requiring them

* Move dev bump to Publish Release workflow
2021-02-18 14:43:21 +01:00

46 lines
1.1 KiB
Python

import os
import re
import sys
from typing import Match
import redbot
version_info = None
def repl(match: Match[str]) -> str:
global version_info
new_stable_version = os.environ.get("NEW_STABLE_VERSION", "auto")
if new_stable_version == "auto":
version_info = redbot.VersionInfo.from_str(match.group("version"))
version_info.dev_release = None
else:
version_info = redbot.VersionInfo.from_str(new_stable_version)
if int(os.environ.get("DEV_BUMP", 0)):
version_info.micro += 1
version_info.dev_release = 1
return f'__version__ = "{version_info}"'
with open("redbot/__init__.py", encoding="utf-8") as fp:
new_contents, found = re.subn(
pattern=r'^__version__ = "(?P<version>[^"]*)"$',
repl=repl,
string=fp.read(),
count=1,
flags=re.MULTILINE,
)
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:
fp.write(new_contents)
print(f"::set-output name=new_version::{version_info}")