Generate a version number file.
This commit is contained in:
parent
df5fea15f1
commit
74458ae140
25
run.py
25
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"
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue