Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix versioning of APP #52

Merged
merged 5 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ jobs:
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Set version based on tag
run: |
sed -i 's/dev/${{ steps.tag.outputs.tag }}/g' terrabutler/__init__.py
- name: Build Python Module
run: |
pip install -r requirements.txt pyinstaller
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ python-dateutil==2.8.2
PyYAML==6.0
s3transfer==0.5.2
schema==0.7.5
semantic-version==2.9.0
six==1.16.0
urllib3==1.26.9
2 changes: 1 addition & 1 deletion terrabutler/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__name__ = "terrabutler"
__version__ = '0.1.0-alpha.1'
__version__ = "dev"
10 changes: 8 additions & 2 deletions terrabutler/click.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,18 @@
inception_init,
inception_init_needed
)
from terrabutler.utils import is_semantic_version


VERSION = (f"v{__version__}" if is_semantic_version(__version__)
else __version__
)


@click.group(context_settings=dict(help_option_names=['-h', '-help',
'--help']))
@click.version_option(version=__version__, prog_name=__name__.capitalize(),
message='%(prog)s v%(version)s')
@click.version_option(version=VERSION, prog_name=__name__.capitalize(),
message='%(prog)s: %(version)s')
def main():
validate_settings()

Expand Down
16 changes: 16 additions & 0 deletions terrabutler/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from terrabutler.requirements import check_requirements
from sys import exit
from semantic_version import Version
from os import getenv

check_requirements()
Expand All @@ -13,3 +15,17 @@
"templates": ROOT_PATH + "/configs/templates",
"variables": ROOT_PATH + "/configs/variables"
}


def is_semantic_version(version):
"""
Check if the version corresponds to the semantic versioning.
"""
try:
Version(version)
except ValueError:
return False
except Exception as e:
print(f"There was an error while parsing version: {e}")
exit(1)
return True