Mise en production : mise à jour des classeurs Cuisine/Restauration, scripts de mise à jour, versioning

This commit is contained in:
2025-11-17 15:55:30 +01:00
parent 37465a9ece
commit c1f25eb61d
8 changed files with 105 additions and 208 deletions

51
Scripts/maj_version.py Normal file
View File

@@ -0,0 +1,51 @@
import sys
from pathlib import Path
from datetime import date
def lire_version(path: Path):
if not path.exists():
return [1, 0, 0]
contenu = path.read_text(encoding="utf-8").strip().splitlines()
if not contenu:
return [1, 0, 0]
version_str = contenu[0].strip()
try:
parts = [int(x) for x in version_str.split(".")]
while len(parts) < 3:
parts.append(0)
return parts[:3]
except ValueError:
return [1, 0, 0]
def ecrire_version(path: Path, version):
version_str = ".".join(str(x) for x in version)
today = date.today().isoformat()
texte = f"{version_str}\n{today}\n"
path.write_text(texte, encoding="utf-8")
return version_str
def increment_patch(version):
version[2] += 1
return version
def main():
if len(sys.argv) < 2:
print("Usage : python maj_version.py chemin_du_VERSION.txt")
sys.exit(1)
version_file = Path(sys.argv[1])
version = lire_version(version_file)
version = increment_patch(version)
new_version_str = ecrire_version(version_file, version)
print(f"Nouvelle version : {new_version_str}")
if __name__ == "__main__":
main()