poetry-git-version-plugin


Namepoetry-git-version-plugin JSON
Version 2.0.0 PyPI version JSON
download
home_pageNone
SummaryPoetry plugin to get package version from git
upload_time2024-11-14 17:40:20
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseMIT
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/61/40/2f2050723b7635561a3ce5fbe069cab7878796225bc4b5e80fad08a99f01/poetry_git_version_plugin-2.0.0.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.0",
    "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": "56a774b14513b746e7e5fef90a21636f1845f46a4cd0309a69e148b3c3578c35",
                "md5": "19b113c48b228323ed0e178cfc95219f",
                "sha256": "68254ccea5f2f6cd407e25dd2c58997096997167b21efdf1394d553b28a45f65"
            },
            "downloads": -1,
            "filename": "poetry_git_version_plugin-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "19b113c48b228323ed0e178cfc95219f",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 7263,
            "upload_time": "2024-11-14T17:40:18",
            "upload_time_iso_8601": "2024-11-14T17:40:18.512233Z",
            "url": "https://files.pythonhosted.org/packages/56/a7/74b14513b746e7e5fef90a21636f1845f46a4cd0309a69e148b3c3578c35/poetry_git_version_plugin-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "61402f2050723b7635561a3ce5fbe069cab7878796225bc4b5e80fad08a99f01",
                "md5": "544685fa38634efbb48f4c9534b081f6",
                "sha256": "2de8cc129e6eb03401408678cbc4a03904022e8e7f8ef29a042b34aebc442b1a"
            },
            "downloads": -1,
            "filename": "poetry_git_version_plugin-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "544685fa38634efbb48f4c9534b081f6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 7320,
            "upload_time": "2024-11-14T17:40:20",
            "upload_time_iso_8601": "2024-11-14T17:40:20.599968Z",
            "url": "https://files.pythonhosted.org/packages/61/40/2f2050723b7635561a3ce5fbe069cab7878796225bc4b5e80fad08a99f01/poetry_git_version_plugin-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-14 17:40:20",
    "github": false,
    "gitlab": true,
    "bitbucket": false,
    "codeberg": false,
    "gitlab_user": "rocshers",
    "gitlab_project": "python",
    "lcname": "poetry-git-version-plugin"
}
        
Elapsed time: 0.77257s