common: Pick up version details from deployment.json in common/version.py

This commit is contained in:
Shreya Malviya 2021-09-10 16:36:26 +05:30
parent 2b9b755177
commit 2af3878e81
1 changed files with 11 additions and 3 deletions

View File

@ -1,11 +1,19 @@
# To get the version from shell, run `python ./version.py` (see `python ./version.py -h` for
# details).
import argparse
import json
from pathlib import Path
MAJOR = "1"
MINOR = "11"
PATCH = "0"
deployment_info_file_path = Path(__file__).parent.parent.joinpath(
"monkey_island", "cc", "deployment.json"
)
with open(deployment_info_file_path, "r") as deployment_info_file:
deployment_info = json.load(deployment_info_file)
MAJOR = deployment_info["version"]["major"]
MINOR = deployment_info["version"]["minor"]
PATCH = deployment_info["version"]["patch"]
build_file_path = Path(__file__).parent.joinpath("BUILD")
with open(build_file_path, "r") as build_file:
BUILD = build_file.read()