Name | poetry-git-version-plugin JSON |
Version |
2.0.1
JSON |
| download |
home_page | None |
Summary | Poetry plugin to get package version from git |
upload_time | 2024-11-15 14:01:00 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | MIT |
keywords |
rocshers
poetry
git
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Poetry Git Version Plugin
Poetry plugin to set package version based on git tag.
[![PyPI](https://img.shields.io/pypi/v/poetry-git-version-plugin)](https://pypi.org/project/poetry-git-version-plugin/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poetry-git-version-plugin)](https://pypi.org/project/poetry-git-version-plugin/)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=rocshers_poetry-git-version-plugin&metric=coverage)](https://sonarcloud.io/summary/new_code?id=rocshers_poetry-git-version-plugin)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rocshers_poetry-git-version-plugin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rocshers_poetry-git-version-plugin)
[![Downloads](https://static.pepy.tech/badge/poetry-git-version-plugin)](https://clickpy.clickhouse.com/dashboard/poetry-git-version-plugin)
[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/poetry-git-version-plugin)](https://gitlab.com/rocshers/python/poetry-git-version-plugin)
[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/poetry-git-version-plugin)](https://gitlab.com/rocshers/python/poetry-git-version-plugin)
## Features
- **No needed installed Git**
- **Git tag** parsing
- Different **types of release**
- Setting found or generated version as package **poetry.version**
- Maintenance of **PEP 440**
- `Auto-increment` depending on release type
- [Command](#poetry-git-version) to output a new version
- [Command](#poetry-set-git-version) to update the pyproject version
## Quick start
```bash
poetry self add poetry-git-version-plugin
poetry git-version # Write package version based on git tag
poetry build # Build package with version based on git tag
```
## Configs
### release_type
Determines which release type to use.
- type: Enum
- tag
- alpha
- beta
- rc
- post
- dev
- Default = "dev"
**Value definition:**
```toml
# Environment
export PACKAGE_VERSION_RELEASE_TYPE=dev
# pyproject.toml
[tool.poetry-git-version-plugin]
release_type = "dev"
```
**Values:**
Given: current tag - **1.2.3**, distance - **4**.
Possible values and version result:
- **tag** -> 1.2.1
- **alpha** -> 1.2.1**a**4
- **beta** -> 1.2.1**b**4
- **rc** -> 1.2.1**rc**4
- **post** -> 1.2.3.**post**4
- **dev** -> 1.2.3.**dev**4
### local
Determines whether to add locale to the version
- type: bool
- Default = true
**Value definition:**
```toml
# Environment
export PACKAGE_VERSION_LOCAL=true
# pyproject.toml
[tool.poetry-git-version-plugin]
local = true
```
**Values:**
Given: current tag - **1.2.3**, distance - **4**, hash - **09dc5d2d7d8132c94c9c77ac27e1f594963a8ed4**.
Possible values and version result:
- **false** -> 1.2.1a4
- **true** -> 1.2.1a4+**09dc5d2**
## Commands
### poetry git-version
```bash
$ poetry git-version # Write package version based on git tag
1.2.3.dev4+09dc5d2
```
### poetry set-git-version
```bash
$ poetry git-version # Set new version in pyproject
The new version has been installed: 1.2.3.dev4+09dc5d2
$ cat pyproject.toml | grep version
version = "1.2.3.dev4+09dc5d2"
```
## Use cases
### Publishing python package to pypi via poetry with version equal to git tag
.gitlab-ci.yml:
```yaml
pypi:
stage: publishing
image: python:3.10
tags:
- docker
script:
- export PACKAGE_VERSION_RELEASE_TYPE=alpha
- poetry self add poetry-git-version-plugin
- poetry config repositories.pypi https://upload.pypi.org/legacy/
- poetry config pypi-token.pypi ${PYPI_TOKEN}
- poetry publish -r pypi --build
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
- When creating a git tag: new package with version == {TAG}
- When pushing to CI_DEFAULT_BRANCH: new package with version == {TAG}a{N}
### Publishing python package to private pypi via poetry with version equal to git tag and commit hash
.gitlab-ci.yml:
```yaml
pypi:
stage: publishing
image: python:3.10
tags:
- docker
script:
- export PACKAGE_VERSION_RELEASE_TYPE=alpha
- export PACKAGE_VERSION_local=true
- poetry self add poetry-git-version-plugin
- poetry config repositories.gitlab "https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/pypi"
- poetry config http-basic.gitlab gitlab-ci-token "$CI_JOB_TOKEN"
- poetry publish -r gitlab --build
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
```
- When creating a git tag: new package with version == {TAG}
- When pushing to CI_DEFAULT_BRANCH: new package with version == {TAG}a{N}+{COMMIT_HASH}
## Contribute
Issue Tracker: <https://gitlab.com/rocshers/python/poetry-git-version-plugin/-/issues>
Source Code: <https://gitlab.com/rocshers/python/poetry-git-version-plugin>
Before adding changes:
```bash
make install-dev
```
After changes:
```bash
make format test
```
Raw data
{
"_id": null,
"home_page": null,
"name": "poetry-git-version-plugin",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "rocshers, poetry, git",
"author": null,
"author_email": "Alekse Marusich <alekse.marusich@rocshers.com>",
"download_url": "https://files.pythonhosted.org/packages/4b/05/b7b73b03a6fbf6d206c2d8499de4d5d1536a575789a54eb84842cbe9de1a/poetry_git_version_plugin-2.0.1.tar.gz",
"platform": null,
"description": "# Poetry Git Version Plugin\n\nPoetry plugin to set package version based on git tag.\n\n[![PyPI](https://img.shields.io/pypi/v/poetry-git-version-plugin)](https://pypi.org/project/poetry-git-version-plugin/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/poetry-git-version-plugin)](https://pypi.org/project/poetry-git-version-plugin/)\n\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=rocshers_poetry-git-version-plugin&metric=coverage)](https://sonarcloud.io/summary/new_code?id=rocshers_poetry-git-version-plugin)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=rocshers_poetry-git-version-plugin&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=rocshers_poetry-git-version-plugin)\n\n[![Downloads](https://static.pepy.tech/badge/poetry-git-version-plugin)](https://clickpy.clickhouse.com/dashboard/poetry-git-version-plugin)\n[![GitLab stars](https://img.shields.io/gitlab/stars/rocshers/python/poetry-git-version-plugin)](https://gitlab.com/rocshers/python/poetry-git-version-plugin)\n[![GitLab last commit](https://img.shields.io/gitlab/last-commit/rocshers/python/poetry-git-version-plugin)](https://gitlab.com/rocshers/python/poetry-git-version-plugin)\n\n## Features\n\n- **No needed installed Git**\n- **Git tag** parsing\n- Different **types of release**\n- Setting found or generated version as package **poetry.version**\n- Maintenance of **PEP 440**\n- `Auto-increment` depending on release type\n- [Command](#poetry-git-version) to output a new version\n- [Command](#poetry-set-git-version) to update the pyproject version\n\n## Quick start\n\n```bash\npoetry self add poetry-git-version-plugin\npoetry git-version # Write package version based on git tag\npoetry build # Build package with version based on git tag\n```\n\n## Configs\n\n### release_type\n\nDetermines which release type to use.\n\n- type: Enum\n - tag\n - alpha\n - beta\n - rc\n - post\n - dev\n- Default = \"dev\"\n\n**Value definition:**\n\n```toml\n# Environment\nexport PACKAGE_VERSION_RELEASE_TYPE=dev\n# pyproject.toml\n[tool.poetry-git-version-plugin]\nrelease_type = \"dev\"\n```\n\n**Values:**\n\nGiven: current tag - **1.2.3**, distance - **4**.\n\nPossible values \u200b\u200band version result:\n\n- **tag** -> 1.2.1\n- **alpha** -> 1.2.1**a**4\n- **beta** -> 1.2.1**b**4\n- **rc** -> 1.2.1**rc**4\n- **post** -> 1.2.3.**post**4\n- **dev** -> 1.2.3.**dev**4\n\n### local\n\nDetermines whether to add locale to the version\n\n- type: bool\n- Default = true\n\n**Value definition:**\n\n```toml\n# Environment\nexport PACKAGE_VERSION_LOCAL=true\n# pyproject.toml\n[tool.poetry-git-version-plugin]\nlocal = true\n```\n\n**Values:**\n\nGiven: current tag - **1.2.3**, distance - **4**, hash - **09dc5d2d7d8132c94c9c77ac27e1f594963a8ed4**.\n\nPossible values \u200b\u200band version result:\n\n- **false** -> 1.2.1a4\n- **true** -> 1.2.1a4+**09dc5d2**\n\n## Commands\n\n### poetry git-version\n\n\n```bash\n$ poetry git-version # Write package version based on git tag\n1.2.3.dev4+09dc5d2\n```\n\n### poetry set-git-version\n\n\n```bash\n$ poetry git-version # Set new version in pyproject \nThe new version has been installed: 1.2.3.dev4+09dc5d2\n\n$ cat pyproject.toml | grep version\nversion = \"1.2.3.dev4+09dc5d2\"\n```\n\n## Use cases\n\n### Publishing python package to pypi via poetry with version equal to git tag\n\n.gitlab-ci.yml:\n\n```yaml\npypi:\n stage: publishing\n image: python:3.10\n tags:\n - docker\n script:\n - export PACKAGE_VERSION_RELEASE_TYPE=alpha\n - poetry self add poetry-git-version-plugin\n - poetry config repositories.pypi https://upload.pypi.org/legacy/\n - poetry config pypi-token.pypi ${PYPI_TOKEN}\n - poetry publish -r pypi --build\n rules:\n - if: $CI_COMMIT_TAG\n - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH\n```\n\n- When creating a git tag: new package with version == {TAG}\n- When pushing to CI_DEFAULT_BRANCH: new package with version == {TAG}a{N}\n\n### Publishing python package to private pypi via poetry with version equal to git tag and commit hash\n\n.gitlab-ci.yml:\n\n```yaml\npypi:\n stage: publishing\n image: python:3.10\n tags:\n - docker\n script:\n - export PACKAGE_VERSION_RELEASE_TYPE=alpha\n - export PACKAGE_VERSION_local=true\n - poetry self add poetry-git-version-plugin\n - poetry config repositories.gitlab \"https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/pypi\"\n - poetry config http-basic.gitlab gitlab-ci-token \"$CI_JOB_TOKEN\"\n - poetry publish -r gitlab --build\n rules:\n - if: $CI_COMMIT_TAG\n - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH\n```\n\n- When creating a git tag: new package with version == {TAG}\n- When pushing to CI_DEFAULT_BRANCH: new package with version == {TAG}a{N}+{COMMIT_HASH}\n\n## Contribute\n\nIssue Tracker: <https://gitlab.com/rocshers/python/poetry-git-version-plugin/-/issues> \nSource Code: <https://gitlab.com/rocshers/python/poetry-git-version-plugin>\n\nBefore adding changes:\n\n```bash\nmake install-dev\n```\n\nAfter changes:\n\n```bash\nmake format test\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Poetry plugin to get package version from git",
"version": "2.0.1",
"project_urls": {
"Homepage": "https://projects.rocshers.com/open-source/poetry-git-version-plugin",
"Repository": "https://gitlab.com/rocshers/python/poetry-git-version-plugin"
},
"split_keywords": [
"rocshers",
" poetry",
" git"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "7d980f57126fe987f87cb3daae6c2af802442c77882840c8cc674c8d128d6042",
"md5": "e9e9ba514ae0c9aecb075c8433cff0ff",
"sha256": "ba1cbac134297ac880c4e055b551923c6628b5d2ab37164a0dd0c9149f1aa854"
},
"downloads": -1,
"filename": "poetry_git_version_plugin-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e9e9ba514ae0c9aecb075c8433cff0ff",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 7617,
"upload_time": "2024-11-15T14:00:58",
"upload_time_iso_8601": "2024-11-15T14:00:58.612683Z",
"url": "https://files.pythonhosted.org/packages/7d/98/0f57126fe987f87cb3daae6c2af802442c77882840c8cc674c8d128d6042/poetry_git_version_plugin-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "4b05b7b73b03a6fbf6d206c2d8499de4d5d1536a575789a54eb84842cbe9de1a",
"md5": "f276aea1f7b0bab364beff44210d0f4c",
"sha256": "e6d743c598477c6f87287b3bb8b0d503aaeae2ca301b6dd476ca20df1d8186c4"
},
"downloads": -1,
"filename": "poetry_git_version_plugin-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "f276aea1f7b0bab364beff44210d0f4c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 7465,
"upload_time": "2024-11-15T14:01:00",
"upload_time_iso_8601": "2024-11-15T14:01:00.293720Z",
"url": "https://files.pythonhosted.org/packages/4b/05/b7b73b03a6fbf6d206c2d8499de4d5d1536a575789a54eb84842cbe9de1a/poetry_git_version_plugin-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-15 14:01:00",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "rocshers",
"gitlab_project": "python",
"lcname": "poetry-git-version-plugin"
}