Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Your version manager

Project description

NewVersion - Your version manager

PyPI - newversion Docs

PyPI - Python Version Coverage

Features

Installation

python -m pip install newversion

Usage

CLI

newversion            # 0.0.0
newversion bump major # 1.0.0

# get package version from pyproject.toml, setup.cfg or setup.py
newversion package # 1.2.3
newversion package | newversion bump  # 1.2.4
newversion package | newversion get minor  # 2


# bump minor version and update package version
newversion package | newversion bump minor | newversion set_package

echo "1.2.3rc1" | newversion bump micro   # 1.2.3
echo "1.2.3rc1" | newversion bump minor   # 1.3.0
echo "1.2.3rc1" | newversion bump major   # 2.0.0
echo "1.2.3rc1" | newversion bump pre     # 1.2.3rc2
echo "1.2.3rc1" | newversion bump rc      # 1.2.3rc2
echo "1.2.3rc1" | newversion bump alpha   # 1.2.4a1

echo "1.2.3rc1" | newversion set micro 5  # 1.2.5rc1
echo "1.2.3rc1" | newversion set minor 5  # 1.5.3rc1
echo "1.2.3rc1" | newversion set major 5  # 5.2.3rc1
echo "1.2.3rc1" | newversion set pre 5    # 1.2.3rc5
echo "1.2.3rc1" | newversion set rc 5     # 1.2.3rc5
echo "1.2.3rc1" | newversion set alpha 5  # 1.2.3a5

echo "1.2.3rc1" | newversion get micro    # 1
echo "1.2.3rc1" | newversion get minor    # 2
echo "1.2.3rc1" | newversion get major    # 3
echo "1.2.3rc1" | newversion get pre      # rc1
echo "1.2.3rc1" | newversion get rc       # 1
echo "1.2.3rc1" | newversion get alpha    # 0

echo "1.2.3rc1" | newversion stable # 1.2.3

echo "1.2.3rc1" | newversion is_stable       # error!
echo "1.2.3" | newversion is_stable          # 1.2.3
echo "1.2.3" | newversion is_stable && echo "Stable!" # Stable!

echo "1.2.3rc1" | newversion gt "1.2.3"   # error!
echo "1.2.3rc1" | newversion lte "1.2.3"  # "1.2.3rc1"

Python library

from newversion import Version

version = Version("1.2.3")
next_version = version.bump_minor() # Version("1.3.0")

# bump version same way as SemVer
version.dumps() # "1.2.3"
version.bump_micro().dumps() # "1.2.4"
version.bump_minor().dumps() # "1.3.0"
version.bump_major().dumps() # "2.0.0"

# create and bump pre-releases
version.bump_prerelease().dumps() # "1.2.4rc1"
version.bump_prerelease(bump_release="minor").dumps() # "1.3.0rc1"
version.bump_prerelease("alpha").dumps() # "1.2.4a1"
Version("1.2.3b4").bump_prerelease().dumps() # "1.2.3b5"
version.bump_micro().replace(dev=1234).dumps() # "1.2.4.dev1234"

# and post-releases
version.bump_postrelease().dumps() # "1.2.3.post1"
Version("1.2.3.post3").bump_postrelease(2).dumps() # "1.2.3.post5"

# easily check if this is a pre- or dev release or a stable version
Version("1.2.3").is_stable # True
Version("1.2.3a6").is_stable # False
Version("1.2.3.post3").is_stable # True
Version("1.2.3.post3").get_stable().dumps() # "1.2.3"

Versioning

newversion version follows PEP 440.

Latest changes

Full changelog can be found in Releases.

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to PEP 440 -- Version Identification and Dependency Specification.

[Unreleased]

[1.8.0] - 2021-03-16

Added

  • [cli] package command to get Python package version
  • [cli] set_package command to set Python package version

[1.7.0] - 2021-03-15

[1.7.0rc1] - 2021-03-15

Added

  • [cli] echo "1.2.3" | newversion ne "1.2.4" comamnd to raise error if version is not equal to other

Changed

  • [api] reworked Executor for easier usage as API

Fixed

  • [packaging] console entrypoint newversion was not present in wheel package
  • [version] error on getting epoch
  • [packaging] typing_extensions are no longer needed on python > 3.8

[0.1.5] - 2021-02-25

Changed

  • Added compatibility with Python 3.6.10+

Project details


Download files

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

Files for newversion, version 1.8.0
Filename, size File type Python version Upload date Hashes
Filename, size newversion-1.8.0-py3-none-any.whl (16.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size newversion-1.8.0.tar.gz (15.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page