LoRa_APRS_iGate/scripts/check_version.py

50 wiersze
1.4 KiB
Python

2022-02-17 20:59:35 +00:00
#!/usr/bin/env python3
2022-03-27 00:14:22 +00:00
import git
2022-02-17 20:59:35 +00:00
from datetime import date
today = date.today()
current_year = int(str(today.isocalendar()[0])[2:])
current_week = int(today.isocalendar()[1])
version = None
with open("src/LoRa_APRS_iGate.cpp") as f:
for line in f:
if line.startswith("#define VERSION"):
2022-03-20 00:16:47 +00:00
version = line.strip().split(" ")[-1].replace('"', "")
2022-02-17 20:59:35 +00:00
version_split = version.split(".")
version_year = int(version_split[0])
version_week = int(version_split[1])
2022-03-27 00:14:22 +00:00
version_vers = int(version_split[2])
2022-02-17 20:59:35 +00:00
2022-03-27 00:14:22 +00:00
print(f"[INFO] firmware version year: {version_year}")
print(f"[INFO] firmware version week: {version_week}")
print(f"[INFO] firmware version version: {version_vers}")
print(f"[INFO] -> {version}")
2022-02-17 20:59:35 +00:00
2022-03-27 00:14:22 +00:00
print(f"[INFO] current year: {current_year}")
print(f"[INFO] current week: {current_week}")
print(f"[INFO] -> {current_year}.{current_week}.x")
2022-02-17 20:59:35 +00:00
error = False
if version_year != current_year:
2022-03-27 00:14:22 +00:00
print("[ERROR] firmware version is not current year!")
2022-02-17 20:59:35 +00:00
error = True
if version_week != current_week:
2022-03-27 00:14:22 +00:00
print("[ERROR] firmware version is not current week!")
2022-02-17 20:59:35 +00:00
error = True
2022-03-27 00:14:22 +00:00
repo = git.Repo('.')
2022-03-27 00:20:04 +00:00
print(f"[INFO] found {len(repo.tags)} tags in repo")
2022-03-27 00:14:22 +00:00
if f"v{version}" in repo.tags:
print("[ERROR] tag with this version is already existing")
error = True
if error:
print("[ERROR] check/update VERSION define in src/LoRa_APRS_iGate.cpp to fix this issue")
2022-02-17 20:59:35 +00:00
exit(error)