From d6388ccc32709a83d8837b27468f878d9e5d2b1b Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Thu, 17 Feb 2022 21:59:35 +0100 Subject: [PATCH] add version check --- .github/workflows/build_check.yml | 11 ++++++++++ scripts/check_version.py | 35 +++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 scripts/check_version.py diff --git a/.github/workflows/build_check.yml b/.github/workflows/build_check.yml index 542fe65..21e8860 100644 --- a/.github/workflows/build_check.yml +++ b/.github/workflows/build_check.yml @@ -3,6 +3,17 @@ name: Integreation Tests on: [push, pull_request] jobs: + version_check: + name: Version Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + - name: Set up Python + uses: actions/setup-python@v2 + - name: check version + run: ./scripts/check_version.py + build: name: Compile Firmware runs-on: ubuntu-latest diff --git a/scripts/check_version.py b/scripts/check_version.py new file mode 100755 index 0000000..95e29c0 --- /dev/null +++ b/scripts/check_version.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 + +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"): + version = line.strip().split(" ")[2].replace('"', "") + +version_split = version.split(".") +version_year = int(version_split[0]) +version_week = int(version_split[1]) + +print(f"firmware version year: {version_year}") +print(f"firmware version week: {version_week}") + +print(f"current year: {current_year}") +print(f"current week: {current_week}") + +error = False +if version_year != current_year: + print("firmware version is not current year!") + error = True + +if version_week != current_week: + print("firmware version is not current week!") + error = True + +exit(error)