Skip to main content

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

Release files for uv-version 0.1.9.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for uv-version 0.1.9.post1
File Size Uploaded
uv_version-0.1.9.post1.tar.gz 9.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for uv-version 0.1.9.post1
File Interpreter ABI Platform
uv_version-0.1.9.post1-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / uv_version-0.1.9.post1.tar.gz

Download URL uv_version-0.1.9.post1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b93afe3bd81a8fec8502c72b885b16cc9193359cc555b372c1e99a3d652a5722
BLAKE2b-256 checksum
How to use checksums
69839ff7930a525be19a9000e6de650220570871a9aa21d188657793934b6eb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.2

Release files / uv_version-0.1.9.post1-py3-none-any.whl

Download URL uv_version-0.1.9.post1-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
765b226941b23721ec88558092e4f333a7a27595a8207d2235a9aa57d18c9b8d
BLAKE2b-256 checksum
How to use checksums
7da2b235a057967b46831549c2ec929c3af1bbd11e31d0920850d5ad2d16dca3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.2

Release history Release notifications | RSS feed

This release

0.1.9.post1 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page