2021-12-08 17:27:33 +01:00
|
|
|
const yaml = require("js-yaml")
|
|
|
|
const fs = require("fs")
|
|
|
|
const path = require("path")
|
|
|
|
|
|
|
|
const UpgradeTypes = {
|
|
|
|
MAJOR: "major",
|
|
|
|
MINOR: "minor",
|
|
|
|
PATCH: "patch"
|
|
|
|
}
|
|
|
|
|
2021-12-09 12:05:43 +01:00
|
|
|
const CHART_PATH = path.join(__dirname, "../", "charts", "budibase", "Chart.yaml")
|
2021-12-08 17:27:33 +01:00
|
|
|
const UPGRADE_VERSION = process.env.BUDIBASE_RELEASE_VERSION
|
|
|
|
const UPGRADE_TYPE = process.env.HELM_CHART_UPGRADE_TYPE || UpgradeTypes.PATCH
|
|
|
|
|
|
|
|
if (!UPGRADE_VERSION) {
|
|
|
|
throw new Error("BUDIBASE_RELEASE_VERSION env var must be set.")
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
const chartFile = fs.readFileSync(CHART_PATH, "utf-8")
|
|
|
|
const chart = yaml.load(chartFile)
|
|
|
|
|
|
|
|
// Upgrade app version in chart to match budibase release version
|
|
|
|
chart.appVersion = UPGRADE_VERSION
|
|
|
|
|
|
|
|
// semantically version the chart
|
|
|
|
const [major, minor, patch] = chart.version.split(".")
|
|
|
|
const newPatch = parseInt(patch) + 1
|
|
|
|
chart.version = [major, minor, newPatch].join(".")
|
|
|
|
const updatedChartYaml = yaml.dump(chart)
|
|
|
|
fs.writeFileSync(CHART_PATH, updatedChartYaml)
|
|
|
|
} catch (err) {
|
|
|
|
console.error("Error releasing helm chart")
|
|
|
|
throw err
|
|
|
|
}
|