Skip to main content

CLI tool for managing package version

Project description

uv-version

CLI tool for managing package version

PyPI PyPI - Python Version uvxt

Coverage Quality Gate Status

Downloads GitLab stars GitLab last commit

Functionality

  • Parsing: git, pyproject.toml, env, stdin
  • Output to: pyproject.toml, stdout
  • Increment

Quick start

uvx uv-version increment

Configs

Commands

Arguments for using version

  • --to-pyproject: Set a new version in pyproject.toml. [Default]
  • --to-print: Print the new version to the console.

Arguments for getting version

  • --from-pyproject: Version is determined by the value in pyproject.toml project.version [Default]
  • --from-git: Version is determined based on the git status
  • --from-stdin: Version is expected as the last argument of the call or from stdin
  • --from-env: Version is expected in the environment variable $PACKAGE_VERSION.

You can use multiple attributes together.

When retrieving the version from different sources, keep in mind that the highest version will be used in the end.

uvx increment

Increases the version by 1

$ uvx uv-version --to-print
0.1.1
$ uvx uv-version --to-print increment prerelease
0.1.2a1
$ uvx uv-version --to-print increment micro
0.1.3
$ uvx uv-version --to-print increment minor
0.2.0
$ uvx uv-version --to-print increment major
1.0.0

Use cases

Publishing python package to pypi via uv with version equal to git tag

.gitlab-ci.yml:

pypi:
  stage: publishing
  image: ghcr.io/astral-sh/uv:python3.12-bookworm-slim
  tags:
    - docker
  script:
    - apt install git
    - uvx uv-version --from-git
    - uv build --no-sources
    - uv publish
  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 uv with version equal to git tag and commit hash

.gitlab-ci.yml:

pypi:
  stage: publishing
  image: ghcr.io/astral-sh/uv:python3.12-bookworm-slim
  tags:
    - docker
  script:
    - apt install git
    # set alpha version template
    - PACKAGE_VERSION_ALPHA_VERSION_FORMAT='{version}a{distance}+{commit_hash}'
    # Update package version
    - uvx uv-version --from-git
    # Publishing to gitlab
    - UV_PUBLISH_URL=https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/pypi
    - UV_PUBLISH_TOKEN=${PYPI_TOKEN}
    - uv build --no-sources
    - uv publish
  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}

Roadmap

  • logging
  • tests
  • version construct
  • Set to __init__, __version__,VERSION files

Contribute

Issue Tracker: https://gitlab.com/rocshers/python/uv-version/-/issues
Source Code: https://gitlab.com/rocshers/python/uv-version

Before adding changes:

make install-dev

After changes:

make format test

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uv_version-0.1.9.tar.gz (9.4 kB view details)

Uploaded Source

Built Distribution

uv_version-0.1.9-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file uv_version-0.1.9.tar.gz.

File metadata

  • Download URL: uv_version-0.1.9.tar.gz
  • Upload date:
  • Size: 9.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.2

File hashes

Hashes for uv_version-0.1.9.tar.gz
Algorithm Hash digest
SHA256 950ee75fa090af15203e30fa090af09bbac5d8f97e9c2e1be19d26250c53fde5
MD5 61fb1215d316917beb00c81c272ab4f2
BLAKE2b-256 55c57f07fe1c417d6295c2053961c065befc8624827d5984b81955d6a5f3389f

See more details on using hashes here.

File details

Details for the file uv_version-0.1.9-py3-none-any.whl.

File metadata

File hashes

Hashes for uv_version-0.1.9-py3-none-any.whl
Algorithm Hash digest
SHA256 217199bb91887046962cb5f1eadde09eabab553208d6f59fa986004a2c1b954d
MD5 fdfec0970c2f002d68f06851e0751b7a
BLAKE2b-256 5119bae04c2bb02214f30c7c57f4638a764c583acb15ab926886d7b9d2342078

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page