Skip to content

Commit d636aba

Browse files
authored
ci: update chart version index for a single chart (#1867)
1 parent 8a20b29 commit d636aba

File tree

1 file changed

+19
-13
lines changed

1 file changed

+19
-13
lines changed

ci/src/update-helm-chart-deps.mjs

+19-13
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,21 @@ import yaml from 'js-yaml'
77
import semver from 'semver'
88
import { $ } from 'zx'
99

10+
export function isVersionApplicable(currentVersion, version, allowedUpgradeType) {
11+
if (semver.lte(version, currentVersion)) {
12+
return false // Ignore versions that are <= current version
13+
}
14+
if (allowedUpgradeType === 'patch') {
15+
return semver.diff(currentVersion, version) === 'patch'
16+
}
17+
if (allowedUpgradeType === 'minor') {
18+
const isMinorOrPatch =
19+
semver.diff(currentVersion, version) === 'patch' || semver.diff(currentVersion, version) === 'minor'
20+
return isMinorOrPatch
21+
}
22+
return true // Default: Allow all upgrades
23+
}
24+
1025
async function main() {
1126
config()
1227
const env = envalid.cleanEnv(process.env, {
@@ -44,6 +59,7 @@ async function main() {
4459
}
4560

4661
for (const dependency of chart.dependencies) {
62+
const currentDependencyVersion = dependency.version
4763
if (dependencyNameFilter.length != 0 && !dependencyNameFilter.includes(dependency.name)) {
4864
console.log(
4965
`Skipping updates for dependency: ${dependency.name} due to dependencyNameFilter: ${dependencyNameFilter} `,
@@ -70,18 +86,7 @@ async function main() {
7086
// Filter versions for allowed upgrades (minor/patch)
7187
const currentVersion = dependency.version
7288
const filteredVersions = allVersions.filter((version) => {
73-
if (semver.lte(version, currentVersion)) {
74-
return false // Ignore versions that are <= current version
75-
}
76-
if (allowedUpgradeType === 'patch') {
77-
return semver.diff(currentVersion, version) === 'patch'
78-
}
79-
if (allowedUpgradeType === 'minor') {
80-
const isMinorOrPatch =
81-
semver.diff(currentVersion, version) === 'patch' || semver.diff(currentVersion, version) === 'minor'
82-
return isMinorOrPatch
83-
}
84-
return true // Default: Allow all upgrades
89+
return isVersionApplicable(currentVersion, version, allowedUpgradeType)
8590
})
8691

8792
if (!filteredVersions.length) {
@@ -143,8 +148,9 @@ async function main() {
143148
}
144149
} catch (error) {
145150
console.error('Error updating dependencies:', error)
146-
continue
147151
} finally {
152+
// restore this version so it does not populate to the next chart update
153+
dependency.version = currentDependencyVersion
148154
if (ciCreateFeatureBranch) {
149155
// Reset to the main branch for the next dependency
150156
await $`git checkout ${baseBranch}`

0 commit comments

Comments
 (0)