Versions¶
Versions section help you with bookkeeping a version in your application, here is the sample of versioning for python application
versions:
- file: setup.py
regex: ^\s*version\s*=\s*["']([^"']+)["']
- file: your_module/__init__.py
regex: ^__version__\s*=\s*["']([^"']+)["']
You might also add an example to your readme and keep version in documentation updated too:
versions:
- file: setup.py
regex: ^\s*version\s*=\s*["']([^"']+)["']
- file: your_module/__init__.py
regex: ^__version__\s*=\s*["']([^"']+)["']
- file: doc/conf.py
regex: ^version\s*=\s*u?["']([^"']+)["']
partial-version: ^\d+\.\d+ # no patch version
- file: doc/conf.py
regex: ^release\s*=\s*u?["']([^"']+)["']
- file: README.rst
regex: pip\s+install\s+your-module==(\S+)
Options:
file- Filename to search version in, relative to project directory (usually
a directory that contains
bulk.yaml) filesA list of files to search. This is useful if you can use same regex in multiple files.
Note
Neither existence of
fileor any one infilesis enforced. if you make a typo file will be silently skipped. Always usebulk check-versionafter modifying rules.On the upside is that you can use same
bulk.yamlfor many similar projects and versions that aren’t present will be skipped.regexA regular expression that matches version. It must contain a single capturing group (i.e.
a (parenthised expression)) for capturing actual version. Regex can match only on a single line.The expression shouldn’t be too strict and should not try to validate the version number itself. I.e. if version is quoted anything inside the quotes should be considered version, if it isn’t anything to next white space or newline is okay.
Too strict version pattern risk to be either to replace
1.2.3to1.2.4in1.2.3-beta.1keeping beta suffix, or to skip1.2.3-beta.1line in a file without updating it because it doesn’t match.If
regexmatches multiple times all matching lines are treated as version number. Also multiple entries with the same file and different rules can be configured.partial-versionA regular expression that allows to select only portion of version number. Few examples:
^\d+\.\d+– selects major.minor version but not patch-.*$– selects-alpha,-beta.1,-31-g12bd530or any other pre-release suffix in version number.
block-start,block-endMarks block where to find version number in.
For example, in
Cargo.tomlversion number is in the[package]section and namedversion, whereasversion=in other case may denote version of other things like pedependencies. So we use this:- file: Cargo.toml block-start: ^\[package\] block-end: ^\[.*\] regex: ^version\s*=\s*"(\S+)"
You can specify single file multiple times in versions section. Which effectively means you can fix version in multiple different sections.
multiple-blocks- (default
false) By default bulk stops scanning this file for this rule on the firstblock-endafterblock-start. If this setting is set totruesearches for the nextblock-startistead. This option does nothing if no block defined.