bumpver/README.md

991 lines
35 KiB
Markdown
Raw Normal View History

2020-08-30 10:29:19 +00:00
<div align="center">
<p align="center">
2020-10-18 21:11:17 +00:00
<img alt="logo" src="https://gitlab.com/mbarkhau/pycalver/-/raw/master/pycalver1k2_128.png">
2020-08-30 10:29:19 +00:00
</p>
</div>
2020-10-18 20:47:35 +00:00
# [BumpVer: Automatic Versioning][url_repo]
2020-10-18 20:47:35 +00:00
With the CLI command `bumpver`, you can search for and update version strings in your project files. It has a flexible pattern syntax to support many version schemes ([SemVer][url_semver_org], [CalVer][url_calver_org] or otherwise). BumpVer features:
2020-10-09 22:11:55 +00:00
- Configurable version patterns
2020-10-18 20:47:35 +00:00
- Optional Git or Mercurial integration
- Works with plaintext, so you can use it with any project.
2020-10-18 20:47:35 +00:00
[url_repo]: https://gitlab.com/mbarkhau/bumpver
[url_semver_org]: https://semver.org/
2020-10-18 20:47:35 +00:00
[url_calver_org]: https://calver.org/
2018-11-05 00:18:49 +01:00
2018-12-05 09:37:34 +01:00
Project/Repo:
[![MIT License][img_license]][url_license]
[![Supported Python Versions][img_pyversions]][url_pyversions]
2020-10-18 21:17:33 +00:00
[![CalVer 2020.1103-beta][img_version]][url_version]
[![PyPI Releases][img_pypi]][url_pypi]
[![PyPI Downloads][img_downloads]][url_downloads]
2018-12-05 09:37:34 +01:00
Code Quality/CI:
[![GitHub Build Status][img_github_build]][url_github_build]
[![GitLab Build Status][img_gitlab_build]][url_gitlab_build]
[![Type Checked with mypy][img_mypy]][url_mypy]
[![Code Coverage][img_codecov]][url_codecov]
[![Code Style: sjfmt][img_style]][url_style]
2018-11-05 00:18:49 +01:00
2018-12-09 16:50:09 +01:00
| Name | role | since | until |
|-------------------------------------|-------------------|---------|-------|
| Manuel Barkhau (mbarkhau@gmail.com) | author/maintainer | 2018-09 | - |
2018-11-05 00:18:49 +01:00
2020-10-18 21:10:09 +00:00
[img_github_build]: https://github.com/mbarkhau/pycalver/workflows/CI/badge.svg
[url_github_build]: https://github.com/mbarkhau/pycalver/actions?query=workflow%3ACI
2020-10-18 21:10:09 +00:00
[img_gitlab_build]: https://gitlab.com/mbarkhau/pycalver/badges/master/pipeline.svg
[url_gitlab_build]: https://gitlab.com/mbarkhau/pycalver/pipelines
2020-10-18 21:10:09 +00:00
[img_codecov]: https://gitlab.com/mbarkhau/pycalver/badges/master/coverage.svg
[url_codecov]: https://mbarkhau.gitlab.io/pycalver/cov
[img_license]: https://img.shields.io/badge/License-MIT-blue.svg
2020-10-18 21:10:09 +00:00
[url_license]: https://gitlab.com/mbarkhau/pycalver/blob/master/LICENSE
[img_mypy]: https://img.shields.io/badge/mypy-checked-green.svg
2020-10-18 21:10:09 +00:00
[url_mypy]: https://mbarkhau.gitlab.io/pycalver/mypycov
[img_style]: https://img.shields.io/badge/code%20style-%20sjfmt-f71.svg
[url_style]: https://gitlab.com/mbarkhau/straitjacket/
2020-10-18 20:47:35 +00:00
[img_downloads]: https://pepy.tech/badge/bumpver/month
[url_downloads]: https://pepy.tech/project/bumpver
2020-10-18 21:17:33 +00:00
[img_version]: https://img.shields.io/static/v1.svg?label=CalVer&message=2020.1103-beta&color=blue
2020-10-18 20:47:35 +00:00
[url_version]: https://pypi.org/project/bumpver/
[img_pypi]: https://img.shields.io/badge/PyPI-wheels-green.svg
2020-10-18 20:47:35 +00:00
[url_pypi]: https://pypi.org/project/bumpver/#files
[img_pyversions]: https://img.shields.io/pypi/pyversions/bumpver.svg
[url_pyversions]: https://pypi.python.org/pypi/bumpver
<!--
$ pip install -U md-toc
$ md_toc --in-place --skip-lines 10 github README.md
-->
<!--TOC-->
- [Overview](#overview)
- [Search and Replace](#search-and-replace)
2020-10-18 21:17:22 +00:00
- [Name Change PyCalVer -> BumpVer](#name-change-pycalver---bumpver)
2020-10-18 20:47:35 +00:00
- [Related Projects/Alternatives](#related-projectsalternatives)
- [Example Usage](#example-usage)
2020-10-18 21:17:22 +00:00
- [Testing a `version_pattern`](#testing-a-version_pattern)
- [Using `MAJOR`/`MINOR`/`PATCH` (SemVer Parts)](#using-majorminorpatch-semver-parts)
2020-10-18 20:47:35 +00:00
- [Auto Increment Parts: `BUILD`/`INC0`/`INC1`](#auto-increment-parts-buildinc0inc1)
- [Persistent Parts: `BUILD`/`TAG`/`PYTAG`](#persistent-parts-buildtagpytag)
- [Searching for Patterns with `grep`](#searching-for-patterns-with-grep)
- [Reference](#reference)
- [Command Line](#command-line)
- [Part Overview](#part-overview)
- [Normalization Caveats](#normalization-caveats)
- [Pattern Examples](#pattern-examples)
- [Week Numbering](#week-numbering)
- [Configuration](#configuration)
- [Configuration Setup](#configuration-setup)
- [Debugging Configuration](#debugging-configuration)
- [Bump It Up](#bump-it-up)
- [Version State](#version-state)
- [The Current Version](#the-current-version)
- [Dry Mode](#dry-mode)
- [VCS Parameters (git/mercurial)](#vcs-parameters-gitmercurial)
<!--TOC-->
2018-11-05 00:18:49 +01:00
2018-11-11 15:07:21 +01:00
2020-10-09 22:11:55 +00:00
## Overview
2018-11-05 00:18:49 +01:00
2020-10-04 20:46:20 +00:00
### Search and Replace
2020-10-18 20:47:35 +00:00
With `bumpver`, you configure a single `version_pattern` which is then used to
2020-10-09 22:11:55 +00:00
1. Search for version strings in your project files
2020-10-18 20:47:35 +00:00
2. Replace these with an updated/bumped version number.
2020-10-09 22:11:55 +00:00
Your configuration might look something like this:
2020-10-04 20:46:20 +00:00
```
2020-10-18 20:47:35 +00:00
[bumpver]
current_version = "1.5.2"
version_pattern = "MAJOR.MINOR.PATCH"
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
[bumpver:file_patterns]
setup.py
version="{version}",
2020-10-09 22:11:55 +00:00
src/mymodule/__init__.py
__version__ = "{version}"
2020-10-04 20:46:20 +00:00
```
2020-10-18 20:47:35 +00:00
Using this configuration, the output of `bumpver update --dry` might look something like this:
2020-10-09 22:11:55 +00:00
```diff
2020-10-18 20:47:35 +00:00
$ bumpver update --patch --dry
INFO - Old Version: 1.5.2
INFO - New Version: 1.5.3
2020-10-09 22:11:55 +00:00
--- setup.py
+++ setup.py
@@ -63,7 +63,7 @@
name="mymodule",
2020-10-18 20:47:35 +00:00
- version="1.5.2",
+ version="1.5.3",
2020-10-09 22:11:55 +00:00
description=description,
--- src/mymodule/__init__.py
+++ src/mymodule/__init__.py
@@ -3,3 +3,3 @@
2020-10-18 20:47:35 +00:00
-__version__ = "1.5.2"
+__version__ = "1.5.3"
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
### Name Change PyCalVer -> BumpVer
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
This project was originally developed under the name PyCalVer, with the intent to support various CalVer schemes. The package and CLI command have since been renamed from PyCalVer/`pycalver` to BumpVer/`bumpver`.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
This name change is due to confusion that this project is either Python specific, or only suitible for CalVer versioning schemes, neither of which is the case.
2020-10-09 22:11:55 +00:00
### Related Projects/Alternatives
2020-10-18 21:17:22 +00:00
If you are looking for an alternative, BumpVer was heavily influenced by [bumpversion/bump2version][url_bump2version]. You may also wish to take a look at their list of related projects: [bump2version/RELATED.md][url_bump2version_related]
2020-10-09 22:11:55 +00:00
2020-10-18 21:17:22 +00:00
[url_bump2version]: https://github.com/c4urself/bump2version/
[url_bump2version_related]: https://github.com/c4urself/bump2version/blob/master/RELATED.md
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
## Example Usage
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
You can override the date used by `bumpver` with the `--date=<isodate>` option. Adding this every time would be distracting, so the examples assume the following date:
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ date --iso
2020-10-15
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
### Testing a `version_pattern`
To test a `version_pattern` and how to increment it, you can use `bumpver test`:
```shell
$ bumpver test 'v2020.37' 'vYYYY.WW'
New Version: v2020.41
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
A `version_pattern` consists of three kinds of characters:
- Literal text, such as `v`, `.`, and `-`, typically used as delimiters.
- A [valid part](#parts-overview) such as `YYYY`/`WW` in the previous example.
- Square brackets `[]` to mark an optional segment.
The following example uses all three: `vYYYY.WW[-TAG]`
```
vYYYY.WW[-TAG]
literal text ^ ^ ^
```
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test 'v2020.37-beta' 'vYYYY.WW[-TAG]'
New Version: v2020.41-beta
PEP440 : 2020.41b0
2020-10-04 20:46:20 +00:00
```
2020-10-18 20:47:35 +00:00
Here we see the week number changed from 37 to 41. The test command also shows the normalized version pattern according to [PEP440][pep_440_ref]. This removes the `"v"` prefix and shortens the release tag from `-beta` to `b0`.
[pep_440_ref]: https://www.python.org/dev/peps/pep-0440/
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
To remove the release tag, use the option `--tag=final`.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver test 'v2020.37-beta' 'vYYYY.WW[-TAG]' --tag=final
New Version: v2020.41
PEP440 : 2020.41
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
### Using `MAJOR`/`MINOR`/`PATCH` (SemVer Parts)
A CalVer `version_pattern` may not require any flags to determine which part should be incremented, so long as the date has changed.
With SemVer you must always specify one of `--major/--minor/--patch`.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test '1.2.3' 'MAJOR.MINOR.PATCH[PYTAGNUM]' --major
New Version: 2.0.0
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
$ bumpver test '1.2.3' 'MAJOR.MINOR.PATCH[PYTAGNUM]' --minor
2020-10-09 22:11:55 +00:00
New Version: 1.3.0
2020-10-18 20:47:35 +00:00
$ bumpver test '1.2.3' 'MAJOR.MINOR.PATCH[PYTAGNUM]' --patch
New Version: 1.2.4
$ bumpver test '1.2.3' 'MAJOR.MINOR.PATCH[PYTAGNUM]' --patch --tag=beta
New Version: 1.2.4b0
$ bumpver test '1.2.4b0' 'MAJOR.MINOR.PATCH[PYTAGNUM]' --tag-num
New Version: 1.2.4b1
2020-10-09 22:11:55 +00:00
```
2020-10-04 20:46:20 +00:00
2020-10-18 20:47:35 +00:00
These non date based parts also make sense for a CalVer `version_pattern`, so that you can create multiple releases in the same month. It is common to include e.g. a `PATCH` part.
```shell
$ bumpver test '2020.10.0' 'YYYY.MM.PATCH' --patch
New Version: 2020.10.1
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
Without this flag, we would get an error if the date is still in October.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ date --iso
2020-10-15
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
$ bumpver test '2020.10.0' 'YYYY.MM.PATCH'
ERROR - Invalid arguments or pattern, version did not change.
ERROR - Version did not change: '2020.10.0'. Invalid version and/or pattern 'YYYY.MM.PATCH'.
INFO - Perhaps try: bumpver test --patch
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
Once the date is in November, the `PATCH` part will roll over back to zero. This happens whenever parts to the left change (in this case the year and month), just as it does if `MAJOR` or `MINOR` were incremented in SemVer.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test '2020.10.1' 'YYYY.MM.PATCH' --date 2020-11-01
New Version: 2020.11.0
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
The rollover to zero will happen even if you use the `--patch` argument, so that your first release in a month will always have a `PATCH` set to 0 instead of 1. You can make the `PATCH` part optional with `[.PATCH]` and always supply the `--patch` flag in your build script. This will cause the part to be omitted when 0 and added when > 0.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test '2020.9.1' 'YYYY.MM[.PATCH]' --patch
New Version: 2020.10
$ bumpver test '2020.10' 'YYYY.MM[.PATCH]' --patch
New Version: 2020.10.1
$ bumpver test '2020.10.1' 'YYYY.MM[.PATCH]' --patch
New Version: 2020.10.2
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
With CalVer, the version is based on a calendar date, so you only have to specify such flags if you've already published a release for the current date. Without such a flag, BumpVer will show the error, that the "version did not change".
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver test 'v2020.41-beta0' 'vYYYY.WW[-TAGNUM]'
ERROR - Invalid arguments or pattern, version did not change.
ERROR - Invalid version 'v2020.41-beta0' and/or pattern 'vYYYY.WW[-TAGNUM]'.
```
In this case you have to change one of the parts that are not based on a calendar date.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test 'v2020.41-beta0' 'vYYYY.WW[-TAGNUM]' --tag-num
New Version: v2020.41-beta1
PEP440 : 2020.41b1
$ bumpver test 'v2020.41-beta0' 'vYYYY.WW[-TAGNUM]' --tag=final
New Version: v2020.41
PEP440 : 2020.41
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
If a pattern is not applicable to a version string, then you will get an error message.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver test '2020.37' 'YYYY.MM' # expected to fail because 37 is not valid for part MM
ERROR - Incomplete match '2020.3' for version string '2020.37' with pattern 'YYYY.MM'/'(?P<year_y>[1-9][0-9]{3})\.(?P<month>1[0-2]|[1-9])'
ERROR - Invalid version '2020.37' and/or pattern 'YYYY.MM'.
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
This illustrates that each pattern is internally translated to a regular expression which must match the version string. The `--verbose` flag will show a verbose form of the regular expression, which may help to debug the discrepancy between the pattern and the version.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test 'v2020.37' 'YYYY.WW' --verbose # missing "v" prefix
INFO - Using pattern YYYY.WW
INFO - regex = re.compile(r"""
(?P<year_y>[1-9][0-9]{3})
\.
(?P<week_w>5[0-2]|[1-4][0-9]|[0-9])
""", flags=re.VERBOSE)
ERROR - Invalid version string 'v2020.37' for pattern ...
```
To fix the above, you can either remove the "v" prefix from the version or add it to the pattern.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver test 'v2020.37' 'vYYYY.WW' # added "v" prefix
New Version: v2020.41
PEP440 : 2020.41
2020-10-09 22:11:55 +00:00
```
2020-10-15 19:54:26 +00:00
2020-10-18 20:47:35 +00:00
### Auto Increment Parts: `BUILD`/`INC0`/`INC1`
These parts are incremented automatically, and do not use/require a CLI flag: `BUILD`/`INC0`/`INC1`.
```shell
$ bumpver test '2020.10.1' 'YYYY.MM.INC0'
New Version: 2020.10.2
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
$ bumpver test '2020.10.2' 'YYYY.MM.INC0' --date 2020-11-01
New Version: 2020.11.0
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
You can make the part optional using the `[PART]` syntax and it will be added/removed as needed.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test '2020.10' 'YYYY.MM[.INC0]'
New Version: 2020.10.1
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
$ bumpver test '2020.10.1' 'YYYY.MM[.INC0]' --date 2020-11-01
New Version: 2020.11
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
### Persistent Parts: `BUILD`/`TAG`/`PYTAG`
The `BUILD` and `TAG` parts will not rollover/reset. Instead they are carried forward from one version to the next.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver test 'v2020.1051-beta' 'vYYYY.BUILD[-TAG]'
New Version: v2020.1052-beta
PEP440 : 2020.1052b0
$ bumpver test 'v2020.1051-beta' 'vYYYY.BUILD[-TAG]' --date 2021-01-01
New Version: v2021.1052-beta
PEP440 : 2021.1052b0
$ bumpver test 'v2020.1051-beta' 'vYYYY.BUILD[-TAG]' --tag=rc
New Version: v2020.1052-rc
PEP440 : 2020.1052rc0
2020-10-04 20:46:20 +00:00
```
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
To remove a release tag, mark it as final with `--tag=final`.
2020-10-15 19:54:26 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver test 'v2020.1051-beta' 'vYYYY.BUILD[-TAG]' --tag=final
New Version: v2020.1052
PEP440 : 2020.1052
```
2020-10-09 22:11:55 +00:00
2020-10-27 14:26:51 +00:00
### Explicit `--set-version`
If the various automatic version incrementing methods don't work for you, you can explicitly do `--set-version=<version>`.
```diff
$ bumpver update --dry --set-version="v2020.1060"
INFO - Old Version: v2020.1051-beta
INFO - New Version: v2020.1060
--- setup.py
+++ setup.py
@@ -63,7 +63,7 @@
name="mymodule",
- version="2020.1051b0",
+ version="2020.1060",
description=description,
--- src/mymodule/__init__.py
+++ src/mymodule/__init__.py
@@ -3,3 +3,3 @@
-__version__ = "v2020.1051-beta"
+__version__ = "v2020.1060"
```
2020-10-15 19:54:26 +00:00
2020-10-18 20:47:35 +00:00
### Searching for Patterns with `grep`
2020-10-15 19:54:26 +00:00
2020-10-18 20:47:35 +00:00
You can use `bumpver grep` to test and debug entries for your configuration.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver grep \
'__version__ = "YYYY.MM[-TAGNUM]"' \
src/module/__init__.py
2020-10-09 22:11:55 +00:00
3:
4: __version__ = "2020.9-beta1"
5:
2020-10-04 20:46:20 +00:00
```
2020-10-18 20:47:35 +00:00
When searching your project files for version strings, there are some limitations to keep in mind:
1. A version string cannot span multiple lines.
2. Brackets `[]` can be escaped with backslash: `\[\]`.
3. There is no way to escape a valid part (so you cannot match the literal text `YYYY`).
2020-10-09 22:11:55 +00:00
Note that everything in the pattern is treated as literal text, except for a valid part (in all caps).
2020-10-18 20:47:35 +00:00
```
__version__ = "YYYY.MM[-TAGNUM]"
literal text ^^^^^^^^^^^^^^^ ^ ^ ^
```
2020-10-09 22:11:55 +00:00
When you write your configuration, you can avoid repeating your version pattern in every search pattern, by using these placeholders
2020-10-04 20:46:20 +00:00
2020-10-09 22:11:55 +00:00
- `{version}`
- `{pep440_version}`
2020-10-18 20:47:35 +00:00
Applied to the above example, you can instead write this:
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver grep \
--version-pattern "YYYY.MM[-TAGNUM]" \
'__version__ = "{version}"' \
src/module/__init__.py
2020-10-09 22:11:55 +00:00
3:
4: __version__ = "2020.9-beta1"
5:
2020-10-04 20:46:20 +00:00
```
2020-10-09 22:11:55 +00:00
The corresponding configuration would look like this.
```ini
2020-10-18 20:47:35 +00:00
[bumpver]
2020-10-09 22:11:55 +00:00
current_version = "2020.9-beta1"
2020-10-18 20:47:35 +00:00
version_pattern = "YYYY.MM[-TAGNUM]"
2020-10-09 22:11:55 +00:00
...
2020-10-18 20:47:35 +00:00
[bumpver:file_patterns]
2020-10-09 22:11:55 +00:00
src/module/__init__.py
__version__ = "{version}"
...
```
2020-10-18 20:47:35 +00:00
If you use a version pattern that is not in the PEP440 normalized form (such as the one above), you can nonetheless match version strings in your project files which *are* in the [PEP440 normalized form][url_pep_440]. To do this, you can use the placeholder `{pep440_version}` instead of the `{version}` placeholder.
2020-10-09 22:11:55 +00:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver grep --version-pattern "YYYY.MM[-TAGNUM]" 'version="{pep440_version}"' setup.py
2020-10-09 22:11:55 +00:00
setup.py
65: url="https://github.com/org/project",
66: version="2020.9b1",
67: description=description,
2020-10-04 20:46:20 +00:00
```
2020-10-18 20:47:35 +00:00
The placeholder `{version}` matches `2020.9-beta1`, while the placeholder `{pep440_version}` matches `2020.9b1` (excluding the "v" prefix, the "-" separator and with a short form release tag "b1" instead of "beta1"). These two placeholders make it possible to mostly use your preferred format for version strings, but use a PEP440 compliant/normalized version string where appropriate.
2020-10-09 22:11:55 +00:00
[url_pep_440]: https://www.python.org/dev/peps/pep-0440/
2020-10-18 20:47:35 +00:00
As a ~~neat trick~~ further illustration of how the search and replace works, you might wish to keep the year of your copyright headers up to date.
2020-10-04 20:46:20 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver grep 'Copyright (c) 2018-YYYY' src/mymodule/*.py | head
2020-10-09 22:11:55 +00:00
src/mymodule/__init__.py
3:
4: # Copyright (c) 2018-2020 Vandelay Industries - All rights reserved.
5:
src/mymodule/config.py
3:
4: # Copyright (c) 2018-2020 Vandelay Industries - All rights reserved.
5:
```
The corresponding configuration for this pattern would look like this.
```ini
2020-10-18 20:47:35 +00:00
[bumpver:file_patterns]
2020-10-09 22:11:55 +00:00
...
src/mymodule/*.py
Copyright (c) 2018-YYYY Vandelay Industries - All rights reserved.
2020-10-04 20:46:20 +00:00
```
2020-10-18 20:47:35 +00:00
Note that there must be a match for every entry in `file_patterns`. If there is no match, `bumpver` will show an error. This ensures that a pattern is not skipped when your project changes. In this case the side effect is to make sure that every file has a copyright header.
```shell
$ bumpver update --dry
ERROR - No match for pattern 'Copyright (c) 2018-YYYY Vandelay Industries - All rights reserved.'
ERROR -
# https://regex101.com/?flavor=python&flags=gmx&regex=Copyright%5B%20%5D%5C%28c%5C%29%0A%5B%20%5D2018%5C-%0A%28%3FP%3Cyear_y%3E%5B1-9%5D%5B0-9%5D%7B3%7D%29%0A%5B%20%5DVandelay%5B%20%5DIndustries%5B%20%5D%5C-%5B%20%5DAll%5B%20%5Drights%5B%20%5Dreserved%5C.
regex = re.compile(r"""
Copyright[ ]\(c\)
[ ]2018\-
(?P<year_y>[1-9][0-9]{3})
[ ]Vandelay[ ]Industries[ ]\-[ ]All[ ]rights[ ]reserved\.
""", flags=re.VERBOSE)
ERROR - No patterns matched for file 'src/mymodule/utils.py'
```
2020-10-04 20:46:20 +00:00
2020-10-09 22:11:55 +00:00
## Reference
### Command Line
2020-10-04 20:46:20 +00:00
2020-10-18 20:47:35 +00:00
<!-- BEGIN bumpver --help -->
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
$ bumpver --help
Usage: bumpver [OPTIONS] COMMAND [ARGS]...
2020-10-04 20:46:20 +00:00
2020-10-18 20:47:35 +00:00
Automatically update CalVer version strings in plaintext files.
2020-10-09 22:11:55 +00:00
Options:
--version Show the version and exit.
--help Show this message and exit.
-v, --verbose Control log level. -vv for debug level.
Commands:
2020-10-18 20:47:35 +00:00
grep Search file(s) for a version pattern.
init Initialize [bumpver] configuration.
show Show current version of your project.
test Increment a version number for demo purposes.
2020-10-20 22:35:24 +00:00
update Update project files with the incremented version string.
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
<!-- END bumpver --help -->
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
<!-- BEGIN bumpver update --help -->
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
$ bumpver update --help
Usage: bumpver update [OPTIONS]
2020-10-09 22:11:55 +00:00
2020-10-20 22:35:24 +00:00
Update project files with the incremented version string.
2020-10-09 22:11:55 +00:00
Options:
-d, --dry Display diff of changes, don't rewrite files.
2020-10-20 22:35:24 +00:00
-f, --fetch / -n, --no-fetch Sync tags from remote origin.
-v, --verbose Control log level. -vv for debug level.
2020-10-09 22:11:55 +00:00
--allow-dirty Commit even when working directory is has
uncomitted changes. (WARNING: The commit will
still be aborted if there are uncomitted to
files with version strings.
2020-10-20 22:35:24 +00:00
--set-version <VERSION> Set version explicitly.
--date <ISODATE> Set explicit date in format YYYY-0M-0D (e.g.
2020-10-20).
2020-10-18 20:47:35 +00:00
2020-10-20 22:35:24 +00:00
--pin-date Leave date components unchanged.
2020-10-18 20:47:35 +00:00
--tag-num Increment release tag number (rc1, rc2,
rc3..).
2020-10-20 22:35:24 +00:00
-t, --tag <NAME> Override release tag of current_version. Valid
options are: alpha, beta, rc, post, final.
2020-10-09 22:11:55 +00:00
2020-10-20 22:35:24 +00:00
-p, --patch Increment patch component.
-m, --minor Increment minor component.
--major Increment major component.
2020-10-09 22:11:55 +00:00
--help Show this message and exit.
```
2020-10-18 20:47:35 +00:00
<!-- END bumpver update --help -->
2020-10-09 22:11:55 +00:00
### Part Overview
2020-10-18 20:47:35 +00:00
> Where possible, these patterns match the conventions from [CalVer.org][url_calver_org_scheme].
2020-10-04 20:46:20 +00:00
[url_calver_org_scheme]: https://calver.org/#scheme
2020-10-18 20:47:35 +00:00
| part | range / example(s) | info |
2020-10-15 19:54:26 +00:00
|---------|---------------------------|--------------------------------------------|
2020-10-18 20:47:35 +00:00
| `MAJOR` | 0..9, 10..99, 100.. | `bumpver update --major` |
| `MINOR` | 0..9, 10..99, 100.. | `bumpver update --minor` |
| `PATCH` | 0..9, 10..99, 100.. | `bumpver update --patch` |
| `TAG` | alpha, beta, rc, post | `--tag=<tag>` |
| `PYTAG` | a, b, rc, post | `--tag=<tag>` |
| `NUM` | 0, 1, 2... | `-r/--tag-num` |
2020-10-15 19:54:26 +00:00
| `YYYY` | 2019, 2020... | Full year, based on `strftime('%Y')` |
| `YY` | 18, 19..99, 0, 1 | Short year, based on `int(strftime('%y'))` |
| `MM` | 9, 10, 11, 12 | Month, based on `int(strftime('%m'))` |
| `DD` | 1, 2, 3..31 | Day, based on `int(strftime('%d'))` |
| `BUILD` | 1001, 1002 .. 1999, 22000 | build number (maintains lexical order) |
| `INC0` | 0, 1, 2... | 0-based auto incrementing number |
| `INC1` | 1, 2... | 1-based auto incrementing number |
2020-10-04 20:46:20 +00:00
2020-10-09 22:11:55 +00:00
The following are also available, but you should review the [Normalization Caveats](#normalization-caveats) before you decide to use them.
2020-10-04 20:46:20 +00:00
2020-10-09 22:11:55 +00:00
| part | range / example(s) | comment |
| ------ | ------------------- | -------------------------------------------- |
2020-10-04 20:46:20 +00:00
| `Q` | 1, 2, 3, 4 | Quarter |
2020-10-09 22:11:55 +00:00
| `0Y` | 18, 19..99, 00, 01 | Short Year `strftime('%y')`(zero-padded) |
2020-10-04 20:46:20 +00:00
| `0M` | 09, 10, 11, 12 | Month `strftime('%m')` (zero-padded) |
| `0D` | 01, 02, 03..31 | Day `strftime('%d')` (zero-padded) |
| `JJJ` | 1,2,3..366 | Day of year `int(strftime('%j'))` |
| `00J` | 001, 002..366 | Day of year `strftime('%j')` (zero-padded) |
| `WW` | 0, 1, 2..52 | Week number¹ `int(strftime('%W'))` |
| `0W` | 00, 01, 02..52 | Week number¹ `strftime('%W')` (zero-padded) |
| `UU` | 0, 1, 2..52 | Week number² `int(strftime('%U'))` |
| `0U` | 00, 01, 02..52 | Week number² `strftime('%U')` (zero-padded) |
| `VV` | 1, 2..53 | Week number¹³ `int(strftime('%V'))` |
| `0V` | 01, 02..53 | Week number¹³ `strftime('%V')` (zero-padded) |
| `GGGG` | 2019, 2020... | `strftime("%G")` ISO 8601 week-based year |
| `GG` | 19, 20...99, 0, 1 | Short ISO 8601 week-based year |
| `0G` | 19, 20...99, 00, 01 | Zero-padded ISO 8601 week-based year |
- ¹ Monday is the first day of the week.
- ² Sunday is the first day of the week.
- ³ ISO 8601 week. Week 1 contains Jan 4th.
2020-10-09 22:11:55 +00:00
### Normalization Caveats
2020-10-18 20:47:35 +00:00
Package managers and installation tools will parse your version numbers. When doing so, your version number may go through a normalization process and may not be exactly as you specified. In the case of Python, the packaging tools (such as pip, twine, [setuptools][setuptools_ref]) follow [PEP440 normalization rules][pep_440_normalzation_ref].
2020-10-09 22:11:55 +00:00
According to these rules (among other things):
- Any non-numerical prefix (such as `v`) is removed
- Leading zeros in delimited parts are truncated `XX.08` -> `XX.8`
- Tags are converted to a short form (`-alpha` -> `a0`)
For example:
2020-10-18 20:47:35 +00:00
- Pattern: `vYY.0M.0D[-TAG]`
2020-10-09 22:11:55 +00:00
- Version: `v20.08.02-beta`
- PEP440 : `20.8.2b0`
2020-10-18 20:47:35 +00:00
I am not aware of any technical reason to use a normalized representation everywhere in your project. However, if you choose a pattern which is always in a normalized, it will help to avoid confusion. For example, it may not be obvious at a glance, that `v20.08.02-beta` is the same as `20.8.2b0` .
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
A further consideration for the choice of your `version_pattern` is that it may be processed by tools that *do not* interpret it as a version number, but treat it just like any other string. It may also be confusing to your users if they a list of version numbers, sorted lexicographically by some tool (e.g. from `git tags`) and versions are not listed in order of their release:
2020-10-09 22:11:55 +00:00
```
$ git tag
18.6b4
18.9b0
19.10b0
19.3b0
20.8b0
20.8b1
```
If you wish to avoid this, you should use a pattern which maintains lexicographical ordering.
2020-10-18 20:47:35 +00:00
[setuptools_ref]: https://setuptools.readthedocs.io/en/latest/setuptools.html#specifying-your-project-s-version
[pep_440_normalzation_ref]: https://www.python.org/dev/peps/pep-0440/#id31
2020-10-09 22:11:55 +00:00
### Pattern Examples
<!-- BEGIN pattern_examples -->
| pattern | examples | PEP440 | lexico. |
|---------------------------------|-------------------------------------|--------|---------|
| `MAJOR.MINOR.PATCH[PYTAGNUM]` | `0.13.10 0.16.10rc1` | yes | no |
| `MAJOR.MINOR[.PATCH[PYTAGNUM]]` | `1.11 0.3.0b5` | yes | no |
| `YYYY.BUILD[PYTAGNUM]` | `2020.1031 2020.1148a0` | yes | yes |
2020-10-18 20:47:35 +00:00
| `YYYY.BUILD[-TAG]` | `2021.1393-beta 2022.1279` | no | yes |
2020-10-09 22:11:55 +00:00
| `YYYY.INC0[PYTAGNUM]` | `2020.10 2021.12b2` | yes | no |
2020-10-18 20:47:35 +00:00
| `YYYY0M.PATCH[-TAG]` | `202005.12 202210.15-beta` | no | no¹ |
| `YYYY0M.BUILD[-TAG]` | `202106.1071 202106.1075-beta` | no | yes |
2020-10-09 22:11:55 +00:00
| `YYYY.0M` | `2020.02 2022.09` | no | yes |
| `YYYY.MM` | `2020.8 2020.10` | yes | no |
| `YYYY.WW` | `2020.8 2021.14` | yes | no |
| `YYYY.MM.PATCH[PYTAGNUM]` | `2020.3.12b0 2021.6.19b0` | yes | no |
| `YYYY.0M.PATCH[PYTAGNUM]` | `2020.10.15b0 2022.07.7b0` | no | no¹ |
| `YYYY.MM.INC0` | `2021.6.2 2022.8.9` | yes | no |
| `YYYY.MM.DD` | `2020.5.18 2021.8.2` | yes | no |
| `YYYY.0M.0D` | `2020.08.24 2022.05.03` | no | yes |
| `YY.0M.PATCH` | `21.04.2 21.11.12` | no | no² |
<!-- END pattern_examples -->
- ¹ If `PATCH > 9`
2020-10-15 19:54:26 +00:00
- ² For the year 2100, the part `YY` will produce 0
2020-10-09 22:11:55 +00:00
### Week Numbering
Week numbering is a bit special, as it depends on your definition of "week":
2020-10-18 20:47:35 +00:00
- First day of the week is either Monday or Sunday.
- Range either from 0-52 or 1-53.
- At the beginning/end of the year, you either have partial weeks or a week that spans multiple years.
2020-10-09 22:11:55 +00:00
If you use `VV`/`0V`, be aware that you cannot also use `YYYY`.
Instead use `GGGG`. This is to avoid an edge case where your version
number would run backwards if it was created around New Year.
<!-- BEGIN weeknum_example -->
2020-10-18 20:47:35 +00:00
```sql
2020-10-09 22:11:55 +00:00
YYYY WW UU GGGG VV
2020-12-26 (Sat): 2020 51 51 2020 52
2020-12-27 (Sun): 2020 51 52 2020 52
2020-12-28 (Mon): 2020 52 52 2020 53
2020-12-29 (Tue): 2020 52 52 2020 53
2020-12-30 (Wed): 2020 52 52 2020 53
2020-12-31 (Thu): 2020 52 52 2020 53
2021-01-01 (Fri): 2021 00 00 2020 53
2021-01-02 (Sat): 2021 00 00 2020 53
2021-01-03 (Sun): 2021 00 01 2020 53
2021-01-04 (Mon): 2021 01 01 2021 01
```
<!-- END weeknum_example -->
2020-10-04 20:46:20 +00:00
2020-10-09 22:11:55 +00:00
## Configuration
2018-11-05 00:18:49 +01:00
2020-10-15 19:54:26 +00:00
### Configuration Setup
2020-10-18 20:47:35 +00:00
The create an initial configuration for project with `bumpver init`.
2018-09-02 21:48:12 +02:00
2018-11-05 00:18:49 +01:00
```shell
2020-10-18 20:47:35 +00:00
$ pip install bumpver
2018-11-06 21:43:34 +01:00
...
2020-10-18 20:47:35 +00:00
Installing collected packages: click toml lexid bumpver
2020-10-18 21:17:33 +00:00
Successfully installed bumpver-2020.1103b0
2019-02-16 17:06:44 +01:00
$ cd myproject
2020-09-24 21:21:36 +00:00
~/myproject/
2019-02-16 17:06:44 +01:00
2020-10-18 20:47:35 +00:00
$ bumpver init --dry
Exiting because of '-d/--dry'. Would have written to bumpver.toml:
[bumpver]
current_version = "2020.1001a0"
version_pattern = "YYYY.BUILD[PYTAGNUM]"
2020-09-18 19:34:51 +00:00
commit_message = "bump version to {new_version}"
2019-02-16 17:06:44 +01:00
commit = true
tag = true
push = true
2020-10-18 20:47:35 +00:00
[bumpver.file_patterns]
2019-02-16 17:06:44 +01:00
"README.md" = [
"{version}",
"{pep440_version}",
]
2020-10-18 20:47:35 +00:00
"bumpver.toml" = [
2019-02-16 17:06:44 +01:00
'current_version = "{version}"',
]
2018-11-06 21:43:34 +01:00
```
2020-10-18 20:47:35 +00:00
If you already have configuration file in your project (such as `setup.cfg` or `pyproject.toml`), then `bumpver init` will update that file instead.
2018-11-06 21:43:34 +01:00
```
2020-09-24 21:21:36 +00:00
~/myproject
2020-10-18 20:47:35 +00:00
$ bumpver init
2018-11-05 00:18:49 +01:00
Updated setup.cfg
```
2018-09-02 21:48:12 +02:00
2020-10-09 22:11:55 +00:00
Your `setup.cfg` may now look something like this:
2018-09-02 21:48:12 +02:00
2018-11-05 00:18:49 +01:00
```ini
2020-10-18 20:47:35 +00:00
[bumpver]
2020-10-15 19:54:26 +00:00
current_version = "2019.1001-alpha"
2020-10-18 20:47:35 +00:00
version_pattern = "YYYY.BUILD[-TAG]"
2020-09-18 19:34:51 +00:00
commit_message = "bump version to {new_version}"
2018-11-05 00:18:49 +01:00
commit = True
tag = True
2018-12-05 09:37:34 +01:00
push = True
2018-09-02 23:36:57 +02:00
2020-10-18 20:47:35 +00:00
[bumpver:file_patterns]
2018-12-05 09:37:34 +01:00
setup.cfg =
2020-10-09 22:11:55 +00:00
current_version = "{version}"
2018-12-05 09:37:34 +01:00
setup.py =
2020-10-18 20:47:35 +00:00
version="{pep440_version}",
2018-12-05 09:37:34 +01:00
README.md =
2019-02-16 17:06:44 +01:00
{version}
{pep440_version}
2018-11-05 00:18:49 +01:00
```
2018-09-02 23:36:57 +02:00
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
### Debugging Configuration
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
For the entries in `[bumpver:file_patterns]` you can expect two failure modes:
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
- False negative: A pattern *will not* match a version number in the associated file *which it should* match.
- False positive: A pattern *will* match something it *should not match* (less likely).
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
Most obviously you will see such cases when you first attempt to use `bumpver update`:
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver update --dry --no-fetch
INFO - Old Version: 2020.1001-alpha
INFO - New Version: 2020.1002-alpha
ERROR - No match for pattern 'version="YYYY.BUILD[PYTAGNUM]",'
ERROR -
# https://regex101.com/?flavor=python&flags=gmx&regex=version%3D%5C%22%0A%28%3FP%3Cyear_y%3E%5B1-9%5D%5B0-9%5D%7B3%7D%29%0A%5C.%0A%28%3FP%3Cbid%3E%5B1-9%5D%5B0-9%5D%2A%29%0A%28%3F%3A%0A%20%20%20%20%28%3FP%3Cpytag%3Epost%7Crc%7Ca%7Cb%29%0A%20%20%20%20%28%3FP%3Cnum%3E%5B0-9%5D%2B%29%0A%29%3F%0A%5C%22%2C
regex = re.compile(r"""
version=\"
2020-10-09 22:11:55 +00:00
(?P<year_y>[1-9][0-9]{3})
2020-10-18 20:47:35 +00:00
\.
(?P<bid>[1-9][0-9]*)
(?:
(?P<pytag>post|rc|a|b)
(?P<num>[0-9]+)
)?
\",
2020-10-09 22:11:55 +00:00
""", flags=re.VERBOSE)
2020-10-18 20:47:35 +00:00
ERROR - No patterns matched for file 'setup.py'
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
The internally used regular expression is also shown, which you can use to debug the issue, for example on [regex101.com](https://regex101.com/r/ajQDTz/2).
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
To debug such issues, you can simplify your pattern and see if you can find a match with `bumpver grep` .
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver grep 'YYYY.BUILD[PYTAGNUM]' setup.py
45: name='myproject',
46: version='2019.1001b0',
47: license='MIT',
```
Here we can see that the pattern for setup.py should be changed to used single quotes instead of doublequotes.
As with `bumpver update`, if your pattern is not found, `bumpver grep` will show an error message with the regular expression it uses, to help you debug the issue.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
```shell
$ bumpver grep 'YYYY.BUILD[PYTAGNUM]' setup.py
ERROR - Pattern not found: 'YYYY.BUILD[PYTAGNUM]'
# https://regex101.com/...
2020-10-09 22:11:55 +00:00
```
2020-10-18 20:47:35 +00:00
An example of a more complex pattern is one where you want to keep a version badge in your README up to date.
```shell
$ bumpver grep 'shields.io/badge/CalVer-YYYY.BUILD[--TAG]-blue' README.md
2020-10-09 22:11:55 +00:00
61:
2020-10-18 20:47:35 +00:00
62: [img_version]: https://img.shields.io/badge/CalVer-2020.1001--beta-blue
2020-10-09 22:11:55 +00:00
63: [url_version]: https://pypi.org/org/package/
```
2020-10-18 20:47:35 +00:00
## Bump It Up
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
### Version State
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
The `current_version` is considered global state and must be stored somewhere. Typically this might be in a `VERSION` file, or some other file which is part of the repository. This creates the risk that parallel branches can have different states. If the `current_version` were defined only by files in the local checkout, the same version might be generated on different systems for different commits.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
To avoid this issue, `bumpver` treats Git/Mercurial tags as the canonical / [SSOT][url_ssot] for the most recent version and attempts to change this state in the most atomic way possible. This is why some actions of the `bumpver` command can take a few seconds, as it is synchronizing with the remote repository to get the most recent versions and to push any new version tags as soon as possible.
2020-10-09 22:11:55 +00:00
2020-10-18 20:47:35 +00:00
[url_ssot]: https://en.wikipedia.org/wiki/Single_source_of_truth
2018-09-02 21:48:12 +02:00
2020-10-18 20:47:35 +00:00
### The Current Version
The current version is either
- Typically: The largest Git/Mercurial tag which matches the `version_pattern` from your config, sorted using [`pkg_resources.parse_version`][url_setuptools_pkg_resources].
- Rarely: Before any tags have been created, the value of `current_version` in `bumpver.toml` / `setup.cfg` / `pyproject.toml`.
[url_setuptools_pkg_resources]: https://setuptools.readthedocs.io/en/latest/pkg_resources.html#parsing-utilities
As part of doing `bumpver update` and `bumpver show`, your local tags are updated using `git fetch --tags`/`hg pull`.
2018-11-11 15:07:21 +01:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver show -vv
2020-10-18T20:20:58.062 DEBUG bumpver.cli - Logging configured.
2020-10-18T20:20:58.065 DEBUG bumpver.config - Config Parsed: Config(
...
2020-10-18T20:20:58.067 DEBUG bumpver.vcs - vcs found: git
2020-10-18T20:20:58.067 INFO bumpver.vcs - fetching tags from remote (to turn off use: -n / --no-fetch)
2020-10-18T20:20:58.068 DEBUG bumpver.vcs - git fetch
2020-10-18T20:21:00.886 DEBUG bumpver.vcs - git tag --list
2020-10-18T20:21:00.890 INFO bumpver.cli - Latest version from git tag: 2020.1019
Current Version: 2020.1019
```
Here we see that:
- Git had a newer version than we had locally (`2020.1019` vs `2020.1018`).
- It took 2 seconds to fetch the tags from the remote repository.
The approach of fetching tags before the version is bumped/incremented, helps to reduce the risk that the newest tag is not known locally. This means that it less likely for the same version to be generated by different systems for different commits. This would result in an ambiguous version tag, which may not be the end of the world, but is better to avoid. Typically this might happen if you have a build system where multiple builds are triggered at the same time.
For a small project (with only one maintainer and no automated packaging) this is a non-issue and you can always use `-n/--no-fetch` to skip fetching the tags.
### Dry Mode
Once you have a valid configuration, you can use `bumpver update --dry` to see the changes it would make (and leave your project files untouched).
```diff
$ bumpver update --dry --no-fetch
INFO - Old Version: 2019.1001-beta
INFO - New Version: 2019.1002-beta
2018-12-22 00:24:04 +01:00
--- README.md
+++ README.md
@@ -11,7 +11,7 @@
[![Supported Python Versions][pyversions_img]][pyversions_ref]
2020-10-15 19:54:26 +00:00
-[![Version 2019.1001-beta][version_img]][version_ref]
+[![Version 2019.1002-beta][version_img]][version_ref]
2018-12-22 00:24:04 +01:00
[![PyPI Releases][pypi_img]][pypi_ref]
2019-02-21 15:53:33 +01:00
--- src/mymodule_v1/__init__.py
+++ src/mymodule_v1/__init__.py
2019-02-21 15:41:06 +01:00
@@ -1,1 +1,1 @@
2020-10-15 19:54:26 +00:00
-__version__ = "2019.1001-beta"
+__version__ = "2019.1002-beta"
2019-02-21 15:41:06 +01:00
2019-02-21 15:53:33 +01:00
--- src/mymodule_v2/__init__.py
+++ src/mymodule_v2/__init__.py
2018-12-22 00:24:04 +01:00
@@ -1,1 +1,1 @@
2020-10-15 19:54:26 +00:00
-__version__ = "2019.1001-beta"
+__version__ = "2019.1002-beta"
2018-12-22 00:24:04 +01:00
--- setup.py
+++ setup.py
@@ -44,7 +44,7 @@
name="myproject",
2020-10-15 19:54:26 +00:00
- version="2019.1001b0",
+ version="2019.1002b0",
2018-12-22 00:24:04 +01:00
license="MIT",
2018-11-11 15:07:21 +01:00
```
2020-09-17 16:24:21 +00:00
2020-10-27 14:26:51 +00:00
2020-10-18 20:47:35 +00:00
### VCS Parameters (git/mercurial)
2020-09-17 16:24:21 +00:00
2020-10-18 20:47:35 +00:00
The individual steps performed by `bumpver update`:
2020-09-17 16:24:21 +00:00
2020-10-18 20:47:35 +00:00
0. Check that you have no local changes that are uncommitted.
1. *Fetch* the most recent global VCS tags from origin.
2. Generate the updated version string.
3. Replace version strings in all files configured in `file_patterns`.
4. *Commit* the updated files.
5. *Tag* the new commit.
6. *Push* the new commit and tag.
2019-02-16 17:06:44 +01:00
2020-10-18 20:47:35 +00:00
The configuration for these steps can be done with the following parameters:
2020-10-18 20:47:35 +00:00
| Parameter | Type | Description |
|------------------|----------|-----------------------------------------|
| `commit_message` | string¹ | Template for commit message in step 4. |
| `commit` | boolean | Create a commit with all updated files. |
| `tag` | boolean² | Tag the newly created commit. |
| `push` | boolean² | Push to the default remote. |
2018-09-02 21:48:12 +02:00
2020-10-18 20:47:35 +00:00
- ¹ Available placeholders for the `commit_message`: `{new_version}`, `{old_version}`, `{new_version_pep440}`, `{old_version_pep440}`
- ² Requires `commit = True`
2018-09-02 21:48:12 +02:00
2020-10-18 20:47:35 +00:00
An example configuration might look like this:
2018-09-02 21:48:12 +02:00
2018-12-22 00:24:04 +01:00
```ini
2020-10-18 20:47:35 +00:00
[bumpver]
2019-02-16 17:06:44 +01:00
...
2020-09-18 19:34:51 +00:00
commit_message = "bump version to {new_version}"
2019-02-16 17:06:44 +01:00
commit = True
tag = True
push = True
```
2018-09-02 21:48:12 +02:00
2020-10-18 20:47:35 +00:00
If everything looks OK, you can do `bumpver update`.
2019-02-16 17:06:44 +01:00
```shell
2020-10-18 20:47:35 +00:00
$ bumpver update --verbose
INFO - fetching tags from remote (to turn off use: -n / --no-fetch)
INFO - Old Version: 2020.1005
INFO - New Version: 2020.1006
INFO - git commit --message 'bump version to 2020.1006'
INFO - git tag --annotate 2020.1006 --message 2020.1006
INFO - git push origin --follow-tags 2020.1006 HEAD
2019-02-16 17:06:44 +01:00
```