https://github.com/atudomain/git-conventional-version
Increment version automatically based on git tags and commit messages.
https://github.com/atudomain/git-conventional-version
changelog changelog-generator conventional conventional-changelog conventional-commits git python release release-automation tags versioning versions
Last synced: 27 days ago
JSON representation
Increment version automatically based on git tags and commit messages.
- Host: GitHub
- URL: https://github.com/atudomain/git-conventional-version
- Owner: atudomain
- License: mit
- Created: 2021-10-23T12:31:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-05T15:28:50.000Z (over 3 years ago)
- Last Synced: 2025-09-28T02:30:06.467Z (3 months ago)
- Topics: changelog, changelog-generator, conventional, conventional-changelog, conventional-commits, git, python, release, release-automation, tags, versioning, versions
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# GIT-CONVENTIONAL-VERSION

Find version automatically based on git tags and commit messages.
The tool is very specific in its function, so it is very flexible.
You can use it as a part of many different integrations and it will not break your process.
## Install
```
python3 -m pip install git-conventional-version
```
## Usage
Get new bumped final version:
```
gcv
```
Get new bumped release candidate version:
```
gcv --type=rc
```
Get current (old) version, 0.0.0 if none exists:
```
gcv --old
```
Example of CI automation script:
```
old=$(gcv --old)
new=$(gcv)
# check if version bump would happen
if [ ! $new == $old ]; then
# if yes, update setup.cfg
sed -i "s/^version.*/version = $new/g" setup.cfg
# and commit release
git add setup.cfg
git commit -m "$new"
git tag "$new"
git push --tags
git push
fi
```
## Version formats
Tags are equivalent to versions, no suffix or prefix is added or interpreted.
Formats follow https://www.python.org/dev/peps/pep-0440/.
- Final version
Standard tag is in the format `\d+\.\d+\.d+` ie. `1.0.0`. It can be divided into `major` . `minor` . `patch` versions.
It is automatically bumped based on commits messages and old version of the same type (look at `Git commit message convention` below).
- Pre-release versions
Pre-release versions bumps are calculated based on last final version, its expected bump and old version of the same pre-release type.
- - Release candidate version
Format `\d+\.\d+\.d+rc\d+` ie. `1.0.0rc1`.
- - Developmental version
Format `\d+\.\d+\.d+dev\d+` ie. `1.0.0dev1`.
- - Alpha version
Format `\d+\.\d+\.d+a\d+` ie. `1.0.0a1`.
- - Beta version
Format `\d+\.\d+\.d+b\d+` ie. `1.0.0b1`.
- Local version
Also, local version can be created from commit sha and old version: `\d+\.\d+\.d\+.+` ie. `0.0.0+79ad`.
## Git commit message convention
Convention is based on https://www.conventionalcommits.org/en/v1.0.0/ (it's good!).
At the moment, only the following rules apply (I usually use only these but more can be added easily):
- Start commit with 'fix:' or 'fix(.*):' to bump patch version.
- Start commit with 'feat:' or 'feat(.*):' to bump minor version.
- Include in the commit line with 'breaking change:' to bump major version.
## Automatic changelog
On branch where your version tags are present, you can generate changelog:
```
gcv-log
```
Full changelog is generated and printed to stdout. You can redirect it to a file.
Assumes that you are about to release next version if not on commit with final version.
## Notices
Automatically handling many types of version tags in git is more complicated than it initially seems like.