Read some file content as current version#

For example, current repo state is:

commit 233f6d72 Dev branch commit (HEAD, dev)
|    commit 86269212 Release commit (v1.0.0, master)
|    |
|   commit e7bdbe51 Another commit
|    /
commit 273c47eb Long long ago

And there are no tags in the current branch (dev), all of them are placed in the master branch.

By default, when you try to get current version, you’ll receive some initial value (see starting_version option).

But if you want to get synchronized version numbers in both on the branches, you can create a text file (for example, VERSION or VERSION.txt) and save here current version number:


Then place it in both the branches and update your config file:


    # you can use os.path instead of pathlib
    from pathlib import Path
    root_path = Path(__file__).parent
    version_file = root_path / "VERSION"
            "enabled": True,
            "version_file": version_file,
  • pyproject.toml:

    enabled = true
    version_file = "VERSION"

When you’ll try to get current version in non-master branch, the content of this file (1.0.0) will be returned instead default version number.

Please take into account that version_file is ignored if any tag is present in the current branch.

See also#