Version Increment Tool for GIT
Project description
repo-version-inc
This tool will automatically increment the version in a repo.
Each succesful build will create a tag. A package can be built from a tag.
usage: version [-h] [-p] [-m] [-M] [-b] [-B BUILD_NUMBER] [-c CHANGELOG] [-n] [--plugin PLUGIN] [--skip-build] [--skip-tag] [-v] Version increment tool for GIT repositories optional arguments: -h, --help show this help message and exit -p, --patch increment the patch number -m, --minor increment minor number -M, --major increment major number -b, --build increment build number -B BUILD_NUMBER, --build-number BUILD_NUMBER create a tag with this exact build number -c CHANGELOG, --changelog CHANGELOG description of the changes in the new version -n, --dry-run don't perform any changes --plugin PLUGIN The plugin used to get the version and build the package --skip-build tag only, don't build --skip-tag build only, don't tag -v, --verbose more output
Jenkins
This tool is to be used in a jenkins build to automate versioning and packaging.
Automated versioning
The default plugin implements versions according to http://semver.org/. It is highly recommended to use that versioning scheme as well.
Versions are stored as tags in the repository. Each succesful build can yield a new tag. Each commit will only be tagged once. Since we might not need a package from every build, the tagging of a succesful build and the building of a package can be decoupled (--skip-build, --skip-tag). An example of a vdt-version command that tags a succesful build is:
# tag foo cd $WORKSPACE/src/foo $WORKSPACE/bin/version -v --build-number=$1 --plugin=debianize --skip-build git push --tags
Automated packaging
Only at the point where we need the packages, they will be created. For now, the tags are created in the DEVELOPMENT environment, and the packages are built in the TEST environment. Packages are built simply by looking up the latest tag and creating a package from that. An example of a vdt-version command that builds a package is:
# build foo package and upload needed files cd $WORKSPACE/src/foo fakeroot $WORKSPACE/bin/version -v --plugin=debianize --skip-tag upload python-foo_*.deb upload python-foo.d*.deb upload python-puka_*.deb
Here you can see that dependencies are also built automatically (and uploaded to the apt repo).
Plugins
With plugins the version tool can be taught how to version or package your repositories.
Create a new python package in the vdt.versionplugin namespace and implement any of the following methods:
def get_version() (must return am vdt.versionplugin.shared.Version object) def set_version(version) (must return am vdt.versionplugin.shared.Version object) def build_package(version) def set_package_version(version)
Implementing these methods is optional. The ones you don’t implement will be taken from https://github.com/devopsconsulting/vdt.versionplugin.default (WIP)
A good example of a plugin that has packaging covered is: https://github.com/devopsconsulting/vdt.versionplugin.debianize
If your plugin is called balla it should live in a package called vdt.versionplugin.balla.
The above four methods, if implemented will be imported like this:
from vdt.versionplugin.balla imported get_version
Extra arguments
When writing a plugin, it might be useful to have some extra arguments, which are passed to your plugin. Rest assured, that is possible. Any argument unknown to vdt.version will be available in the Version object passed to set_version, build_package and set_package_version.
That means in your plugin you can do something like:
import argparse plugin_arg_parser = argparse.ArgumentParser(description="Weeping plugin") plugin_arg_parser.p.add_argument("-Q", "--qq", help="Makes the plugin cry") def build_package(version): plugin_args = plugin_arg_parser.parse_args(version.extra_args) # do something and have args parsed!
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
File details
Details for the file vdt.version-0.1.5.tar.gz
.
File metadata
- Download URL: vdt.version-0.1.5.tar.gz
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c1a79743a4333c9223e977f0a0a028d427427379afafa67017f74f33e613aa4 |
|
MD5 | 2a9bf0db63c351f44d601cd0af3454a2 |
|
BLAKE2b-256 | d196ee529bd4241007f857c352a33ca282f7f7b2ebb2c736f49559bb3f0702ab |
File details
Details for the file vdt.version-0.1.5-py2-none-any.whl
.
File metadata
- Download URL: vdt.version-0.1.5-py2-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25bbad4ab8a07fddab971b7f240a7a11fffa5cdf2a534d333f16c0b4e130019d |
|
MD5 | 4bd91ae5927860eaf6ff0c0bab7bf44b |
|
BLAKE2b-256 | 387cc1d4623de9dfe659a03abe22abebdd2414f7957091a41a52d389a7039162 |