Skip to content

Commit

Permalink
Merge pull request #52 from angulo-solido/fix-#49
Browse files Browse the repository at this point in the history
Fix versioning of APP
  • Loading branch information
MiguelNdeCarvalho authored May 13, 2022
2 parents 25cffa5 + c8d1bcc commit c6e12e3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 3 deletions.
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

0 comments on commit c6e12e3

Please sign in to comment.