Automatic Semantic Versioning with Git Flow.
Project description
versionflow 0.4.0
Automatic Semantic Versioning with Git Flow.
The point of versionflow is to enhance the Git Flow branching model with an automated approach to semantic versioning of your software's releases. It installs a command line utility which you can use to check your repo's status, initialise the versionflow approach, and create semantically versioned releases.
Installation
versionflow
is a Python package. With a Python installation, do
pip install versionflow
to install it.
Getting Started With versionflow
versionflow
works on two assumptions: that you will use the Git Flow methodology for development, and that you want to tag commits on the master
branch of your project with semantic version numbers.
To get started with a project, you need to initialise it to use Git and Git Flow, and have a versionflow configuration file. You could do all that by hand, but luckily versionflow
can do it for you. Just run
versionflow init
in youir project's root directory and versionflow
will create a git repo, initialise it with Git Flow branches, create the config file, and tag the first (empty) commit as "0.0.0".
Now we do some work and commit it to our development branch, and we're ready to create our first release! Let's first check that we're ready:
versionflow check
This will run through a few checks to make sure we're ready to start a release:
- We're in a git repo, initialised for Git Flow.
- The repo is clean: there are no tracked files with uncommitted changes.
- We have a versionflow config file, and the version number in it is consistent with the last version tag.
These checks all get done before you can actually perform a versionflow release & bump action, but it's good to be able to see your current status without the possibility of affecting anything.
Now, let's do our release! It's our first one, so we'll say it's a minor release, i.e. we're going to release v0.1.0.
versionflow minor
That's it! versionflow will do the same checks as above, and if everything is OK it will perform a few actions:
- Create a "Release/0.1.0" branch from the current development commit.
- Update the version number in the versionflow configuration file from 0.0.0 to 0.1.0.
- Merging "Release/0.1.0/ into master, and remove the release branch.
- Tag the merge commit on master as "0.1.0".
- Merge the master branch into develop, so that the latest tag and version number in there is 0.1.0.
So now you'll have a nice, consistent repo: the master branch will contain your latest release, tagged to the appropriate version number.
Using the version number in code
It's nice to have a version number in the tags of your repo which you can easily manage from the command line, but your code itself might want to make use of the same number. This is simple with versionflow - just write the current version number in any of your files, then versionflow add
those files. From now on those files will be modified by versionflow
whenever it updates the current version number. Any instances of the old version number in the specified files will be replaced by the new version number.
For example, suppose we add a README.md
file to the above example. In that file we put
# My awesome program v0.1.0
It's 1337!
We don't want to have to manage that version number by hand. So we do
versionflow add `README.md`
We do some more development and now we're ready to release v.0.2.0, so we run
versionflow minor
Now versionflow
will bump the version in both its own configuration and the README.md
file, merge the develop branch into master, and tag the resulting commit with "0.2.0". README.md
now looks like this:
# My awesome program v0.2.0
It's 1337!
We never have to worry about manually updating the version number in the README ever again. You can add as many files as you want to versionflow
and it will update the version number in all of them.
Commands
- check
Check whether this directory is correctly initialised for versionflow, and ready to bump a version number: is it a git repo; is the repo clean (i.e. not dirty); does it have the standard Git Flow branches; does it have a versionflow config file; does it have a semantic version tag on the
master
branch matching the versionflow config? - init Initialise this directory as a versionflow project: create a git repo (if there isn't already one); set up the Git Flow branches (if they don't already exist); and create a versionflow config file (if it does not exist).
- major
Create a release of this project from the latest commit on
development
with the major version number bumped. - minor
Create a release of this project from the latest commit on
development
with the minor version number bumped. - patch
Create a release of this project from the latest commit on
development
with the patch version number bumped. - describe Show just the current version number in the repo, including a description of the current/parent commit if it is untagged.
- add
Add a file to
versionflow
.
Common Options
All the commands described above take the following options:
- --repo-dir PATH Use the given PATH as the root of the versionflow repo. Defaults to the current directory.
- --config FILE
Use the given FILE as the versionflow configuration file. Defaults to
.versionflow
. - --version Print the current version of versionflow, and exit.
- --help Print a help message
Development
To create an environment in which to develop versionflow
, clone the git repository and create a Python virtual environment using virtualenv. Then in the cloned repo, using the virtual environment, do
pip -r requirements-dev.txt
This will install all the Python modules needed for developing versionflow.
Testing
It is a good idea to create different testing virtual envs for versionflow as well as your dev environment. This will ensure that the package is configured to install properly via the configuration in setup.cfg
, and that you don't have a hidden dependency on something installed in your dev environment.
To install your development version of versionflow in a testing virtual env, activate it, then do
pip install -e .
in your local copy of the versionflow repo. Now as you work on it your latest changes will always be available in the virtual environment.
Acknowledgements
versionflow
uses:
- setuptools_scm to find version numbers from commit tags;
- nu-gitflow to perform Git Flow actions;
- bump2version to increment version numbers in files;
- and gitpython to perform miscellaneous git actions.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file versionflow-0.4.0.tar.gz
.
File metadata
- Download URL: versionflow-0.4.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebb72ee3ee6f90585c602568e92da51b5dfba85bde688106a69e0e3892f53a55 |
|
MD5 | fea3af618cc9ca95c3aa23da458aa9f2 |
|
BLAKE2b-256 | 590340fc1c467f694466f14bf0bd6faddffe103b08e2f0bf48e90226242b7ada |
File details
Details for the file versionflow-0.4.0-py3-none-any.whl
.
File metadata
- Download URL: versionflow-0.4.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a378c5d1ef8aedd965d2e43b21ca2c02918ddfbeab69d3025cc56837e0d24850 |
|
MD5 | c6b6a4ef6ec4d39e3876eda6bbedd756 |
|
BLAKE2b-256 | 2fc6514da9ec5490f27f87045a163287a10cff984549ea5bfed73c7bab0e0e37 |
File details
Details for the file versionflow-0.4.0-py2-none-any.whl
.
File metadata
- Download URL: versionflow-0.4.0-py2-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.37.0 CPython/2.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c59822c5097e9058acd5ddcfe74d4472446c04a9fca47a2b465dee62ca2aa778 |
|
MD5 | 1d5495ffb107f3bad8f8775a7795c64a |
|
BLAKE2b-256 | b32b15a88b803c8350c74cce0afafe5fed112fd6354f489c6ff74dfdd31973d0 |