From a52cba2cccfdfb5b68245e3af5cc0ddcf3b3f8d1 Mon Sep 17 00:00:00 2001 From: Michael Maltsev <4129781+m417z@users.noreply.github.com> Date: Wed, 18 Dec 2024 19:23:26 +0200 Subject: [PATCH] Improve support for prerelease versions --- .github/pr_validation.py | 7 +++++-- deploy.ts | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/pr_validation.py b/.github/pr_validation.py index aa869b1a4..eca37fa2e 100644 --- a/.github/pr_validation.py +++ b/.github/pr_validation.py @@ -191,9 +191,12 @@ def validate_metadata(path: Path, expected_author: str): key = ('version', None) if key in properties: value, line_number = properties[key] - if not re.fullmatch(r'([0-9]+\.)*[0-9]+', value): + if not re.fullmatch(r'([0-9]+\.)*[0-9]+(-\w+)?', value): warnings += add_warning( - path, line_number, f'{key[0]} must contain only numbers and dots' + path, + line_number, + f'{key[0]} must contain only numbers and dots, and optionally a' + ' prerelease suffix (e.g. 1.2.3-beta)', ) else: warnings += add_warning(path, 1, f'Missing {key[0]}') diff --git a/deploy.ts b/deploy.ts index a4056b5c5..6d394a679 100644 --- a/deploy.ts +++ b/deploy.ts @@ -143,13 +143,16 @@ function getModChangelogTextForVersion(modId: string, modVersion: string, commit } function generateModData(modId: string, changelogPath: string, modDir: string) { - fs.mkdirSync(modDir); + if (!fs.existsSync(modDir)) { + fs.mkdirSync(modDir); + } let changelog = ''; const versions: { version: string; prerelease?: boolean; }[] = []; + let sawReleaseVersion = false; const modSourceUtils = new ModSourceUtils('mods'); @@ -173,9 +176,16 @@ function generateModData(modId: string, changelogPath: string, modDir: string) { throw new Error(`Mod ${modId} has no version in commit ${commit}`); } + const prerelease = metadata.version.includes('-'); + if (!prerelease) { + sawReleaseVersion = true; + } else if (sawReleaseVersion) { + continue; + } + versions.unshift({ version: metadata.version, - ...(metadata.version.includes('-') ? { prerelease: true } : {}), + ...(prerelease ? { prerelease: true } : {}), }); const modVersionFilePath = path.join(modDir, `${metadata.version}.wh.cpp`);