mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
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
This commit is contained in:
45
.github/workflows/scripts/bump_version.py
vendored
Normal file
45
.github/workflows/scripts/bump_version.py
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
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}")
|
||||
25
.github/workflows/scripts/close_and_reopen_pr.js
vendored
Normal file
25
.github/workflows/scripts/close_and_reopen_pr.js
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = (async function ({github, context}) {
|
||||
const pr_number = process.env.PR_NUMBER;
|
||||
const pr_operation = process.env.PR_OPERATION;
|
||||
let sleep_time = 0;
|
||||
|
||||
if (!['created', 'updated'].includes(pr_operation)) {
|
||||
console.log('PR was not created as there were no changes.')
|
||||
return;
|
||||
}
|
||||
|
||||
for (const new_state of ['closed', 'open']) {
|
||||
// some sleep time needed to make sure API handles open after close
|
||||
if (sleep_time)
|
||||
await new Promise(r => setTimeout(r, sleep_time));
|
||||
|
||||
github.issues.update({
|
||||
issue_number: pr_number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
state: new_state
|
||||
});
|
||||
|
||||
sleep_time = 2000;
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user