summaryrefslogtreecommitdiffstats
path: root/.github/workflows/version_check.py
blob: c9b3e547ca2cf123c266c4a32390ffe9c6a2960a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.


import datetime
import pathlib
import sys

pyproject = (
    pathlib.Path(__file__).parent.parent.parent
    / "packages"
    / "python"
    / "pyproject.toml"
)

content = pyproject.read_text(encoding="utf-8")

for line in content.splitlines():
    if line.startswith("version"):
        version = line.split("=")[1].strip().strip('"')
        year, minor, micro = version.split(".")
        today = datetime.date.today()
        if int(year) != today.year:
            print(f"Version {version} year should be {today.year}")
            sys.exit(1)

print("Version check passed")