mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-12-23 08:47:50 +00:00
* build: rename filename of vscode workflow * build: archive * dev: permissions * fix: cache name * fix: ci file name * edit * edit2 * fix: release crates rule * fix: announce permission * fix: publish permission * fix: errors * fix: ??? * fix: cargo test * chore: rename * feat: upgrade ubuntu version * feat: upgrade cargo-dist * feat: upgrade cargo-dist * feat: pr run with tag be `''` * feat: upload * feat: upgrade cargo-dist?? * feat: fix workflow * fix: announce deps * fix: permission * fix: dir to download * fix: unpack * fix: unpack 2 * fix: list command * fix: executable name * fix: executable name 2 * fix: executable name 3 * fix: executable name 4 * fix: remove the macos e2e test challenge * fix: prebuilt location * fix: compile arguments
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import fs from "fs";
|
|
|
|
const ciFile = fs.readFileSync(".github/workflows/ci.yml", "utf-8");
|
|
|
|
const toolchainRe = (forWhat) =>
|
|
new RegExp(/dtolnay\/rust-toolchain@(\d+\.\d+\.\d+)/.source + `\\s*#\\s*${forWhat}`);
|
|
|
|
const ciCheckedVersion = ciFile.match(toolchainRe("check-min-version"))?.[1];
|
|
if (!ciCheckedVersion) {
|
|
console.error("Check minimum version not found");
|
|
process.exit(1);
|
|
}
|
|
|
|
const cargoToml = fs.readFileSync("Cargo.toml", "utf-8");
|
|
const cargoSpecifiedVersion = cargoToml.match(/rust-version = "(\d+\.\d+)"/)[1];
|
|
|
|
function parseVersion(version) {
|
|
const versions = version.split(".").map(Number);
|
|
if (versions.length === 2) {
|
|
versions.push(0);
|
|
}
|
|
if (versions.length !== 3) {
|
|
throw new Error(`Invalid version: ${version}`);
|
|
}
|
|
return versions;
|
|
}
|
|
|
|
function versionLess(a, b) {
|
|
if (a.length !== 3 || b.length !== 3) {
|
|
throw new Error("Invalid version to compare");
|
|
}
|
|
|
|
return (
|
|
a[0] < b[0] || (a[0] === b[0] && a[1] < b[1]) || (a[0] === b[0] && a[1] === b[1] && a[2] < b[2])
|
|
);
|
|
}
|
|
|
|
const specified = parseVersion(cargoSpecifiedVersion);
|
|
const checked = parseVersion(ciCheckedVersion);
|
|
|
|
if (versionLess(specified, checked)) {
|
|
console.error(
|
|
`Specified version ${cargoSpecifiedVersion} is less than checked version ${ciCheckedVersion}`,
|
|
);
|
|
process.exit(1);
|
|
}
|