I have a static version in pyproject.toml
, I want the version to be dynamic, everytime when I deploy the latest version I want to update the version of the package automatically instead of changing it manually. Is there any way to do that?
I tried using setuptools-git-versioning
but I could'nt succeed in doing this.
my pyproject.toml
looks like this:
[build-system\]
requires = \["setuptools\>=61.0", "wheel", "setuptools-git-versioning\<2",\]
build-backend = "setuptools.build_meta"
[tool.setuptools-git-versioning\]
enabled = true
[project]
name = "my-package"
dynamic = ["version"]
and deploy job in .gitlab-ci.yml
looks like this:
deploy:
stage: deploy-package
image: <docker_image?
script:
- pip install build twine
- pip install setuptools-git-versioning==1.13.5
- python -m build
- TWINE_PASSWORD=${CI_JOB_TOKEN} TWINE_USERNAME=gitlab-ci-token python -m twine upload --repository-url ${PROJECT_URL}${CI_PROJECT_ID}/packages/pypi dist/*
I wanted to know am I missing anything or is there any better way to do this?