diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 994acf7..11b8516 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -31,7 +31,7 @@ jobs: echo "bin_version=${bin_version}" >> $GITHUB_OUTPUT echo "bin_basename=shark-clipper-${bin_version}" >> $GITHUB_OUTPUT - - name: Write Version File + - name: Write Version Override File shell: bash run: | echo "${{ steps.vars.outputs.full_version }}" > VERSION.txt diff --git a/.gitignore b/.gitignore index f746203..2be3f8a 100644 --- a/.gitignore +++ b/.gitignore @@ -24,5 +24,7 @@ __pycache__/ /*.onefile-build /shark-clipper* +/VERSION.txt + /ffmpeg /ffprobe diff --git a/sharkclipper/util/version.py b/sharkclipper/util/version.py index fc4763f..caece9a 100644 --- a/sharkclipper/util/version.py +++ b/sharkclipper/util/version.py @@ -8,10 +8,17 @@ import sharkclipper.util.log PACKAGE_CONFIG_PATH = os.path.join(sharkclipper.util.file.ROOT_DIR, 'pyproject.toml') +OVERRIDE_VERSION_PATH = os.path.join(sharkclipper.util.file.ROOT_DIR, 'VERSION.txt') UNKNOWN_VERSION = '?.?.?' VERSION_REGEX = r'^version\s*=\s*["\'](\d+\.\d+\.\d+)["\']$' def get_version(): + # First, check for the version override file. + if (os.path.isfile(OVERRIDE_VERSION_PATH)): + with open(OVERRIDE_VERSION_PATH, 'r') as file: + return file.read().strip() + + # Next, check for the base version in the project config. if (not os.path.isfile(PACKAGE_CONFIG_PATH)): logging.error("Could not find version file: '%s'." % (PACKAGE_CONFIG_PATH)) return UNKNOWN_VERSION @@ -37,7 +44,7 @@ def main(): return 0 def _get_parser(): - parser = argparse.ArgumentParser(description = "Get the sverer's version.") + parser = argparse.ArgumentParser(description = "Get the server's version.") sharkclipper.util.log.set_cli_args(parser) return parser