-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathbump-helm-chart.mjs
More file actions
31 lines (25 loc) · 1.16 KB
/
bump-helm-chart.mjs
File metadata and controls
31 lines (25 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { readFileSync, writeFileSync } from "node:fs";
const VERSION_SOURCE = "packages/cli-v3/package.json";
const CHART_PATH = "hosting/k8s/helm/Chart.yaml";
const { version } = JSON.parse(readFileSync(VERSION_SOURCE, "utf8"));
const desiredVersion = `version: ${version}`;
const desiredAppVersion = `appVersion: v${version}`;
const original = readFileSync(CHART_PATH, "utf8");
const versionMatch = original.match(/^version:.*$/m);
const appVersionMatch = original.match(/^appVersion:.*$/m);
if (!versionMatch || !appVersionMatch) {
const missing = [!versionMatch && "version:", !appVersionMatch && "appVersion:"]
.filter(Boolean)
.join(", ");
console.error(`${CHART_PATH} is missing required key(s): ${missing}`);
process.exit(1);
}
if (versionMatch[0] === desiredVersion && appVersionMatch[0] === desiredAppVersion) {
console.log(`${CHART_PATH} already at ${version} (from ${VERSION_SOURCE}), no changes`);
} else {
const updated = original
.replace(/^version:.*/m, desiredVersion)
.replace(/^appVersion:.*/m, desiredAppVersion);
writeFileSync(CHART_PATH, updated);
console.log(`${CHART_PATH} bumped to ${version} (from ${VERSION_SOURCE})`);
}