Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions scripts/flow/rc/check-images-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
import * as yaml from "jsr:@std/yaml@1.0.5";
import { parseArgs } from "jsr:@std/cli@1.0.6";
import { Octokit } from "https://esm.sh/octokit@4.0.2?dts";
import {
greaterOrEqual,
lessThanOrEqual,
parse as parseSemver,
} from "jsr:@std/semver@^1.0.4";

const platforms = [
"linux/amd64",
Expand Down Expand Up @@ -66,6 +71,34 @@ interface Results {

type GitRepoImageMap = Record<string, string[]>;

/**
* Normalize version string for semver parsing.
* Removes 'v' prefix and '-enterprise' suffix if present.
*/
function normalizeVersion(version: string): string {
return version.replace(/^v/, "").replace(/-enterprise$/, "");
}

/**
* Compare two version strings using semantic versioning.
* Returns true if version >= threshold.
*/
function versionGreaterOrEqual(version: string, threshold: string): boolean {
const v = parseSemver(normalizeVersion(version));
const t = parseSemver(normalizeVersion(threshold));
return greaterOrEqual(v, t);
}

/**
* Compare two version strings using semantic versioning.
* Returns true if version <= threshold.
*/
function versionLessThanOrEqual(version: string, threshold: string): boolean {
const v = parseSemver(normalizeVersion(version));
const t = parseSemver(normalizeVersion(threshold));
return lessThanOrEqual(v, t);
}

function validate(info: ImageInfo) {
info.ok = true;
// assert all git sha are same in oci files.
Expand Down Expand Up @@ -152,19 +185,19 @@ async function checkImages(
const results = {} as Record<string, ImageInfo>;
for (const [gitRepo, map] of Object.entries(mm)) {
// tidb-binlog is deprecated since v8.4.0, skip it.
if (version >= "v8.4.0" && gitRepo === "pingcap/tidb-binlog") {
if (versionGreaterOrEqual(version, "v8.4.0") && gitRepo === "pingcap/tidb-binlog") {
continue;
}
// ticdc is initilized since v8.5.4
if (version <= "v8.5.3" && gitRepo === "pingcap/ticdc") {
if (versionLessThanOrEqual(version, "v8.5.3") && gitRepo === "pingcap/ticdc") {
continue;
}

console.group(gitRepo);
const gitSha = await gatheringGithubGitSha(ghClient, gitRepo, branch);

for (const src of map) {
if (version >= "v8.5.4" && src === "pingcap/tiflow/images/cdc") {
if (versionGreaterOrEqual(version, "v8.5.4") && src === "pingcap/tiflow/images/cdc") {
continue;
}
const imageUrl = `${oci_registry}/${src}:${version}`;
Expand Down