ci: use version number from Git tag

This commit is contained in:
Stefan Reimer 2022-02-08 16:01:41 +01:00
parent e3cb29c454
commit 886f421edd
4 changed files with 11 additions and 16 deletions

View File

@ -27,8 +27,6 @@ clean:
rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist rm -rf .cache build .coverage .eggs cloudbender.egg-info .pytest_cache dist
pybuild: pybuild:
# Set version in Python
sed -i cloudbender/__init__.py -e 's/__version__.*/__version__ = "$(TAG)"/'
python setup.py bdist_wheel --universal python setup.py bdist_wheel --universal
test_upload: $(PACKAGE_FILE) test_upload: $(PACKAGE_FILE)

View File

@ -1,8 +1,13 @@
import logging import logging
import pkg_resources
__author__ = "Stefan Reimer" __author__ = "Stefan Reimer"
__email__ = "stefan@zero-downtimet.net" __email__ = "stefan@zero-downtimet.net"
__version__ = "v0.10.3"
try:
__version__ = pkg_resources.get_distribution("CloudBender").version
except pkg_resources.DistributionNotFound:
__version__ = "devel"
# Set up logging to ``/dev/null`` like a library is supposed to. # Set up logging to ``/dev/null`` like a library is supposed to.

View File

@ -1,5 +1,5 @@
[metadata] [metadata]
description-file = README.md description_file = README.md
[bdist_wheel] [bdist_wheel]
universal=1 universal=1

View File

@ -6,17 +6,6 @@ from setuptools import setup
from setuptools import find_packages from setuptools import find_packages
from setuptools.command.test import test as TestCommand from setuptools.command.test import test as TestCommand
def find_version(filename):
"""Uses re to pull out the assigned value to __version__ in filename."""
with io.open(filename, "r", encoding="utf-8") as version_file:
version_match = re.search(r'^__version__ = [\'"]([^\'"]*)[\'"]',
version_file.read(), re.M)
if version_match:
return version_match.group(1)
return "0.0-version-unknown"
class PyTest(TestCommand): class PyTest(TestCommand):
"""TestCommand subclass to use pytest with setup.py test.""" """TestCommand subclass to use pytest with setup.py test."""
@ -45,7 +34,10 @@ else:
setup( setup(
name='cloudbender', name='cloudbender',
version=find_version("cloudbender/__init__.py"), setuptools_git_versioning={
"enabled": True,
},
setup_requires=["setuptools-git-versioning"],
description='Toolset to render and manage AWS Cloudformation', description='Toolset to render and manage AWS Cloudformation',
python_requires='>=3.7', python_requires='>=3.7',
long_description=long_description, long_description=long_description,