From 74458ae140db323dcefc2a3788218ec4f39bf5c6 Mon Sep 17 00:00:00 2001 From: James Pace Date: Wed, 16 Sep 2026 19:55:26 -0400 Subject: [PATCH] Generate a version number file. --- run.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/run.py b/run.py index 12ef05a..3e00912 100755 --- a/run.py +++ b/run.py @@ -12,6 +12,7 @@ import argparse import os from pathlib import Path +from datetime import datetime, UTC import subprocess def main(): @@ -20,7 +21,27 @@ def main(): parser.add_argument("--install-path", type=str) args = parser.parse_args() + prep_install_directory(args.install_path) export_vcs(args.project_dir, args.install_path) + generate_version_number(args.install_path) + +def prep_install_directory(install_path): + # Make the install directory if it doesn't exist. + mkdir_command = "mkdir -p {}".format(install_path) + subprocess.run(mkdir_command, shell=True) + +def generate_version_number(install_path): + # Try to get the version info from the environment. + version_number = os.environ.get("J7S_VERSION_NUMBER") + # If we can't assign a date/time. + if not version_number: + now = datetime.now(UTC) + version_number = now.strftime("%Y.%m.%d.%H.%M") + + # Save in install space. + output_file = install_path + "/version_number" + with open(output_file, 'w') as output: + print(version_number, file=output) def export_vcs(project_directory, install_path): if not project_directory: @@ -32,10 +53,6 @@ def export_vcs(project_directory, install_path): # Find src directory from project directory. src_directory = project_directory / "src" - # Make the install directory if it doesn't exist. - mkdir_command = "mkdir -p {}".format(install_path) - subprocess.run(mkdir_command, shell=True) - # Where we're going to save the output. output_file = install_path + "/project_state.repos"