Skip to content

Commit 23a53bd

Browse files
committed
feat: add bump helm chart version script
1 parent 80cde52 commit 23a53bd

File tree

5 files changed

+46
-64
lines changed

5 files changed

+46
-64
lines changed

helm-charts/catalogi/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: catalogi
33
description: A Helm chart for deploying the Catalogi open source software catalog.
44
type: application
5-
version: 0.1.0
5+
version: 0.1.1
66
appVersion: 1.50.2
77
dependencies:
88
- name: postgresql

lefthook.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ pre-commit:
77
glob: "{package.json,helm-charts/catalogi/Chart.yaml}"
88
run: yarn sync-helm-charts
99
stage_fixed: true
10+
11+
bump-chart-version:
12+
glob: "helm-charts/catalogi/**/*"
13+
# This exclude is critical to prevent an infinite loop.
14+
exclude: "helm-charts/catalogi/Chart.yaml"
15+
run: yarn bump-chart-version
16+
stage_fixed: true
17+
1018
lint:
1119
run: yarn turbo lint
1220

scripts/bump-helm-chart-version.js

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,45 @@ const fs = require("fs");
22
const path = require("path");
33
const yaml = require("js-yaml");
44

5-
export const bumpChartVersion = () => {
6-
const rootDir = path.join(__dirname, "..");
5+
const rootDir = path.join(__dirname, "..");
76

8-
const chartYamlPath = path.join(
9-
rootDir,
10-
"helm-charts",
11-
"catalogi",
12-
"Chart.yaml"
13-
);
7+
const chartYamlPath = path.join(
8+
rootDir,
9+
"helm-charts",
10+
"catalogi",
11+
"Chart.yaml"
12+
);
1413

15-
try {
16-
const chartYamlContent = fs.readFileSync(chartYamlPath, "utf8");
17-
const chartYaml = yaml.load(chartYamlContent);
18-
const currentVersion = chartYaml.version;
14+
try {
15+
const chartYamlContent = fs.readFileSync(chartYamlPath, "utf8");
16+
const chartYaml = yaml.load(chartYamlContent);
17+
const currentVersion = chartYaml.version;
1918

20-
// --- This is the new, dependency-free logic ---
21-
const parts = currentVersion.split(".");
22-
if (parts.length !== 3) {
23-
throw new Error(
24-
`Chart version "${currentVersion}" is not a valid x.y.z format.`
25-
);
26-
}
19+
// --- This is the new, dependency-free logic ---
20+
const parts = currentVersion.split(".");
21+
if (parts.length !== 3) {
22+
throw new Error(
23+
`Chart version "${currentVersion}" is not a valid x.y.z format.`
24+
);
25+
}
2726

28-
const patch = parseInt(parts[2], 10);
29-
if (isNaN(patch)) {
30-
throw new Error(`Patch version "${parts[2]}" is not a valid number.`);
31-
}
27+
const patch = parseInt(parts[2], 10);
28+
if (isNaN(patch)) {
29+
throw new Error(`Patch version "${parts[2]}" is not a valid number.`);
30+
}
3231

33-
parts[2] = patch + 1;
34-
const newVersion = parts.join(".");
35-
// --- End of new logic ---
32+
parts[2] = patch + 1;
33+
const newVersion = parts.join(".");
34+
// --- End of new logic ---
3635

37-
console.log(
38-
`Bumping Helm chart version from ${currentVersion} to ${newVersion}...`
39-
);
40-
chartYaml.version = newVersion;
41-
const newChartYamlContent = yaml.dump(chartYaml);
42-
fs.writeFileSync(chartYamlPath, newChartYamlContent, "utf8");
43-
console.log("✅ Helm chart version bumped.");
44-
} catch (error) {
45-
console.error("❌ Error bumping Helm chart version:", error.message);
46-
process.exit(1);
47-
}
48-
};
36+
console.log(
37+
`Bumping Helm chart version from ${currentVersion} to ${newVersion}...`
38+
);
39+
chartYaml.version = newVersion;
40+
const newChartYamlContent = yaml.dump(chartYaml);
41+
fs.writeFileSync(chartYamlPath, newChartYamlContent, "utf8");
42+
console.log("✅ Helm chart version bumped.");
43+
} catch (error) {
44+
console.error("❌ Error bumping Helm chart version:", error.message);
45+
process.exit(1);
46+
}

scripts/helm-version-utils.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

scripts/sync-helm-app-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ try {
3434

3535
console.log("Calling bump script...");
3636
execSync(
37-
`node ${path.join(__dirname, "bump-chart-version.js")}`,
37+
`node ${path.join(__dirname, "bump-helm-chart-version.js")}`,
3838
{ stdio: "inherit" }, // This ensures the output of the bump script is shown
3939
);
4040

0 commit comments

Comments
 (0)