Skip to content

Commit

Permalink
Improve support for prerelease versions
Browse files Browse the repository at this point in the history
  • Loading branch information
m417z committed Dec 18, 2024
1 parent 28f831f commit a52cba2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
7 changes: 5 additions & 2 deletions .github/pr_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]}')
Expand Down
14 changes: 12 additions & 2 deletions deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand All @@ -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`);
Expand Down

0 comments on commit a52cba2

Please sign in to comment.