Replies: 2 comments 1 reply
-
It depends on which build backend you are using. For pdm-backend: https://backend.pdm-project.org/metadata/#read-from-scm-tag-supporting-git-and-hg |
Beta Was this translation helpful? Give feedback.
-
Thanks @frostming I solved the problem and found a solution, I'll write here so maybe can help someone else: If you need to have automatic versioning on git using tags for your python package in general you can:
[tool.pdm.version]
source = "scm"
# source = "file"
# path = "[version.py](http://version.py/)"
# write_to = "version.txt"
# write_template = "**version** = '{}'"
- mkdir pypackages && pdm install --prod --no-lock --no-editable
- export PDM_BUILD_SCM_VERSION=${CI_COMMIT_TAG}
- pdm build
- pdm publish --repository "[https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi](https://gitlab.com/api/v4/projects/${CI_PROJECT_ID}/packages/pypi)" --username ${REGISTRY_TOKEN_NAME} --password ${REGISTRY_TOKEN_KEY} It’s really important to specify the environment variable used by PDM: I think we can create a tutorial in the documentation page to summarise also this example, what do you think? |
Beta Was this translation helpful? Give feedback.
-
Hi all!
I am trying to make a python package with my CI/CD and publish it on Gitlab (same thing as on Github).
Is there any way to dynamically and automatically assign the git tag to the version of my python package? Without having to edit by hand every time the pyproject.toml with version = ""?
Have you ever tried this or do you have any examples?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions