From 90574905415fa54696a80f1f73430193ea336601 Mon Sep 17 00:00:00 2001 From: ISA Date: Thu, 13 Feb 2025 14:14:47 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20Neue=20Versionierungsstrategie=20mit=20?= =?UTF-8?q?Build-=20und=20Hotfix-Postfix=20eingef=C3=BChrt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Versionierung auf das Muster `vX.Y.Z` für Builds und `vX.Y.Z.N` für Hotfixes umgestellt. - `Z` wird nun bei jedem Commit als Build-Nummer erhöht, um Änderungen nachzuvollziehen. - `N` wird als Patch-Postfix für Bugfixes in bestehenden Versionen genutzt (`vX.Y.Z.1`, `vX.Y.Z.2` usw.). - Erleichtert Wartung und gezielte Fehlerbehebung für Kunden mit älteren Versionen. - Verbesserte Struktur für langfristige Skalierbarkeit und Nachvollziehbarkeit. --- config/webVersion.ts | 2 +- incrementVersion.ts | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 6 deletions(-) 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");