Easy release management: file versioning, git commit, git tagging, and optionally git remote and PyPI.
Project description
tag2ver
Easy release management: file versioning, git commit, git tagging, and optionally Black, git remote, and PyPI.
The name tag2ver is meant to convey that the utility does everything from
git-tagging to file-versioning and all in between and either side. In particular
tag2ver:
-
If
Black(https://black.readthedocs.io/en/stable/index.html) is installed will format all files with:black .. -
Updates
pyandpyifile's__version__attribute with given incremented semantic-version (https://semver.org). -
Updates
versionattribute ofsetup.pyas above (ifsetupexists). -
Git commits all modified files with given description.
-
Git tags git repository with given version.
-
Pushes to remote git (if remote exists).
-
Uploads to
PyPIorTest PyPIwith-toption (ifsetup.pyexists).
tag2ver is careful to check everything before making changes, i.e. it is heavily
biased to finding and reporting an error before attempting any actions.
The whole program is in the single file, tag2ver.py, (without any dependencies outside
Python itself) and therefore tag2ver.py alone can be copied to install the utility.
Alternatively::
pip install --upgrade tag2ver
Before use with a remote git repository, e.g. GitHub, you must cache your credentials
because you are not prompted.
See
https://stackoverflow.com/questions/5343068/is-there-a-way-to-cache-https-credentials-for-pushing-commits
for how to cache credentials,
EG https://github.com/hickford/git-credential-oauth.
If you forget to cache credentials you will get a 128 error from the git push command.
Help Text
Usage from folder with git repository to tag and source files to version:
python -m tag2ver [options] [<Major>.<Minor>.<Patch> "Release/commit Description."].
Options (order of options not important):
-
-hor--help, print short help message (rest of command line ignored). -
--versionprint version number oftag2ver(rest of command line ignored). -
-for--force, force the given git (not PyPI) version even if it is not a single increment. -
-tor--test_pypi, useTest PyPIinstead ofPyPI(ifsetup.pyexists). Passes--repository testpypionto twine (https://twine.readthedocs.io/en/latest/). -
-u <Username>or--username <Username>, forPyPI/Test PyPI(ifsetup.pyexists). Passed onto twine (https://twine.readthedocs.io/en/latest/). Commonly required with PyPI. -
-p <Password>or--password <Password>, forPyPI/Test PyPI(ifsetup.pyexists). Passed onto twine (https://twine.readthedocs.io/en/latest/).
Version in form <Major>.<Minor>.<Patch> (must be the 1st non-option):
-
Must be a semantic version (https://semver.org) with format
<Major>.<Minor>.<Patch>, whereMajor,Minor, andPatchare positive integers or zero. -
Must be a single increment from previous git tag version, unless
-foption given. -
If PyPI used must be at least one increment from PyPI version (
-fnot considered for PyPI version comparison). -
Use:
<tag2ver dir>.tag2ver.py -f 0.0.0 "Add initial tag and version."(or similar), for 1st tagging in the repository (note 1) -
Leading zeros are allowed but ignored, e.g.
00.00.00is the same as0.0.0. -
Leading plus not allowed, e.g.
+0.0.0is an error.
Note 1:
-
Both
pyandpyifiles still need version attr (though it can be an empty string), e.g.__version__ = ''. -
Similarly
setup, e.g.version='0.0.0'(must have a valid version though). -
Since
setupmust contain a valid version the smallest version that can be in PyPI is0.0.1(since version insetupmust be increased). In practice this isn't a problem since much development happens before ready for PyPI and therefore version already>0.0.0.
Description usually in quotes (must be the 2nd non-option):
- Description of the version: a single, short, ideally < 50 characters, sentence with an imperative mood (in double quotes to allow spaces).
Actions tag2ver takes in order:
-
Reformat all files with
BlackifBlackinstalled. -
Checks git repository exists, if not exit.
-
Checks version number is a single increment from last git tag (except
-foption) and of form<Major>.<Minor>.<Patch>and description exists, if not exit. -
Checks if PyPI deployed (
setup.pymust exist) (see note 2) -
Updates the
__version__attribute of all thepy, exceptsetup.py(see above), andpyifile's in the current directory and subdirectories with given version (__version__attributes must already exist in all files). -
Commits all modified files, including
pyandpyifilestag2verhas modified, with given description. -
Tags the repository with given version and given description.
-
If
remoterepository exists, pushesorigintoHEAD(typicallymain). Remote git repositories require authentication typically using a credential helper, EG https://github.com/hickford/git-credential-oauth. -
If
setup.pyexists, uploads toPyPI(orTest PyPIwith-toption) with given version. Username,-uor--username, and password,-por--password, may optionally be specified. To use an API token on PyPI or Test PyPI the username is__token__and the password is the relevant API token. (Upload uses twine (https://twine.readthedocs.io/en/latest/); see link for other options for specifying username and password, EGkeyringor~/.pypirc. An example of a typicalsetup.pyistag2ver'ssetup.pyhttps://github.com/hlovatt/tag2ver/blob/main/setup.py.)
Note 2:
-
Checks version number is at least one increment from last PyPI deployment (regardless of
-foption - PyPI versioning cannot be overridden). -
Updates
setup.py'sversionattribute with given version (versionkwarg must already exist). -
Checks that
tag2veris not running inside a virtual environment; see next point,pipis used with option--Userthat is not supported inside virtual environments. -
From PyPI updates
pip,setuptools,wheel,twine, andpackaging, using option--Userso that the global versions for other users are not affected.
EG:
-
python -m tag2ver -hprints help. -
python -m tag2ver -f 0.0.0 "Add initial tag and version."for 1st release (note-fand note0.0.0cannot be pushed to PyPI). -
python -m tag2ver 0.0.1 "Fix bugs, tag, and version.". -
python -m tag2ver 0.1.0 "Add features, tag, and version.". -
python -m tag2ver 1.0.0 "Make incompatible changes, tag, and version.". -
python -m tag2ver -u <PyPI user name> 1.0.1 "Push to PyPI.". Might need password as well, depending on Twine (https://twine.readthedocs.io/en/latest/) setup, and requiressetup.py.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tag2ver-1.3.1.tar.gz.
File metadata
- Download URL: tag2ver-1.3.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c184353548f122a7188477f742d824326d19bfc15037bd1ddd70caec4e91684b
|
|
| MD5 |
2bc60cc7be218f4352ba34c16c86fffc
|
|
| BLAKE2b-256 |
f6f83dba216ffc5ab22a6f784015172cf665a18997f23201e771f265ebacae3f
|
File details
Details for the file tag2ver-1.3.1-py3-none-any.whl.
File metadata
- Download URL: tag2ver-1.3.1-py3-none-any.whl
- Upload date:
- Size: 8.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f0d85c0ae8e4d1db4858cd71d519c05ba11262673b2b24bb6816ac7b8a6b40b
|
|
| MD5 |
c745980105bb934578b14a4a8ba1e4d0
|
|
| BLAKE2b-256 |
702d883aee0a266b9b21417c2fb7c91603ed81b53abc5a53c589e9a04b2087a0
|