Skip to content

Commit

Permalink
Version checking will not check for a version override file (which th…
Browse files Browse the repository at this point in the history
…e CI will set).
  • Loading branch information
eriq-augustine committed Jun 27, 2024
1 parent 74a6dd2 commit b297339
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@ __pycache__/
/*.onefile-build
/shark-clipper*

/VERSION.txt

/ffmpeg
/ffprobe
9 changes: 8 additions & 1 deletion sharkclipper/util/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit b297339

Please sign in to comment.