From 26ebc8126353a9b58a2e32c82c572aa622584624 Mon Sep 17 00:00:00 2001 From: Radu Suciu Date: Thu, 29 Feb 2024 18:10:10 +0000 Subject: [PATCH] make package version dynamic also adjusting test workflow so that we append the git hash to the current version before publishing to testpypi --- .github/workflows/test.yaml | 6 ++++++ pyproject.toml | 12 +++++++++--- pytest_docker_compose/__init__.py | 1 + 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 74ad6d2..5b1e463 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -44,4 +44,10 @@ jobs: if: matrix.python-version == '3.11' run: | source ${{ env.VIRTUAL_ENV }}/bin/activate + + # adding the git hash to the current version so that the package + # won't be rejected from the test repository due to version clash + TEMP_VERSION=$(git describe | sed s/\-/\./ | sed s/\-/\+/) + bumpver update --no-commit --no-tag-commit --set-version="${TEMP_VERSION}" + pdm publish --repository testpypi diff --git a/pyproject.toml b/pyproject.toml index a4a3d89..2e7cab3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "pytest-docker-compose-v2" -version = "0.1.1" +dynamic = ["version"] description = "Manages Docker containers during your integration tests" authors = [ {name = "Radu Suciu"}, @@ -56,6 +56,10 @@ dev = [ "pytest>=7.4.4", ] +[tool.pdm.version] +source = "file" +path = "pytest_docker_compose/__init__.py" + [tool.pytest.ini_options] addopts = "-m 'not (should_fail or multiple_compose_files)' '--docker-compose' './tests/pytest_docker_compose_tests/my_network' '--docker-compose-no-build'" markers = [ @@ -137,7 +141,7 @@ sort_commits = "oldest" [tool.bumpver] current_version = "0.1.1" -version_pattern = "MAJOR.MINOR.PATCH" +version_pattern = "MAJOR.MINOR.PATCH[GITHASH]" commit_message = "bump version {old_version} -> {new_version}" commit = true tag = true @@ -146,5 +150,7 @@ push = false [tool.bumpver.file_patterns] "pyproject.toml" = [ 'current_version = "{version}"', - 'version = "{version}"', +] +"pytest_docker_compose/__init__.py" = [ + '__version__ = "{version}"', ] diff --git a/pytest_docker_compose/__init__.py b/pytest_docker_compose/__init__.py index e69de29..485f44a 100644 --- a/pytest_docker_compose/__init__.py +++ b/pytest_docker_compose/__init__.py @@ -0,0 +1 @@ +__version__ = "0.1.1"