diff --git a/config/webVersion.ts b/config/webVersion.ts index 5ff97bd..ed760b5 100644 --- a/config/webVersion.ts +++ b/config/webVersion.ts @@ -5,5 +5,5 @@ 2: Patch oder Hotfix (Bugfixes oder kleine Änderungen). */ -const webVersion = "1.0.6.11"; +const webVersion = "1.6.12"; export default webVersion; diff --git a/incrementVersion.ts b/incrementVersion.ts index 54022c3..c770c8d 100644 --- a/incrementVersion.ts +++ b/incrementVersion.ts @@ -3,17 +3,45 @@ const fs = require("fs"); const path = require("path"); const versionFilePath = path.join(process.cwd(), "config/webVersion.ts"); + +// Falls die Datei nicht existiert, erstelle eine Standardversion +if (!fs.existsSync(versionFilePath)) { + fs.writeFileSync( + versionFilePath, + `export const WEB_VERSION = "1.0.0.0";\n`, + "utf8" + ); +} + const versionFile = fs.readFileSync(versionFilePath, "utf8"); -// Regex, um Versionsnummer zu finden -const versionRegex = /(\d+)\.(\d+)\.(\d+)\.(\d+)/; +// Regex, um Versionsnummer zu finden (vX.Y.Z oder vX.Y.Z.N) +const versionRegex = /(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?/; const match = versionFile.match(versionRegex); if (match) { - let [major, minor, patch, build] = match.slice(1).map(Number); - build++; // Erhöhe die Build-Nummer automatisch + let [major, minor, patch, build] = match + .slice(1) + .map((num) => (num !== undefined ? Number(num) : 0)); - const newVersion = `${major}.${minor}.${patch}.${build}`; + const isHotfix = process.env.HOTFIX_MODE === "true"; // Umgebungsvariable für Hotfixes + + if (isHotfix) { + build++; // Falls ein Hotfix gemacht wird, nur `N` erhöhen (vX.Y.Z.N) + console.log( + `🔧 Hotfix-Modus aktiv – Erhöhe Patch-Fix auf: ${major}.${minor}.${patch}.${build}` + ); + } else { + patch++; // Normale Builds erhöhen `Z` + build = 0; // Falls es kein Hotfix ist, beginnt `N` wieder bei 0 + console.log( + `📦 Normale Build-Erhöhung – Neue Version: ${major}.${minor}.${patch}` + ); + } + + const newVersion = isHotfix + ? `${major}.${minor}.${patch}.${build}` + : `${major}.${minor}.${patch}`; const updatedFile = versionFile.replace(versionRegex, newVersion); fs.writeFileSync(versionFilePath, updatedFile, "utf8");