Skip to content

Commit

Permalink
feat(version-control): Allows rawdataapi to follow version control us…
Browse files Browse the repository at this point in the history
…ing commitizen
  • Loading branch information
kshitijrajsharma committed Mar 6, 2024
1 parent 322b45f commit 397413a
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
60 changes: 60 additions & 0 deletions docs/src/version_control.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# Version Control

## Conventional Commits

A [specification](https://www.conventionalcommits.org/en/v1.0.0) for adding human and machine readable meaning to commit messages.

**Format**: <type>[optional scope]: <description>

Example `feat: allow provided config object to extend other configs`
Example `fix: fixed the bug in issue #123`

**Advantage**: Automated SemVer version management (major.minor.patch), and automated changelogs.

## Commitizen CLI

[Commitizen](https://commitizen-tools.github.io/commitizen) is a Python tool to help with creating **conventional commits** and automating version control.

### Install

`pip install commitizen`

### Commiting Code

- Instead of `git commit` use `cz commit` and follow the prompts.
- You can select the type of commit, plus additional metadata.

### Bumping a Version

- When you decide it is time to create a new version:

1. Create a new branch

`git checkout -b bump/new_release`

2. Bump the version and push

```bash
pip install commitizen # (if not installed)

cz bump

git push
```

This will:
- Update the SemVer version number in locations specific in `pyproject.toml`, throughout the codebase.
- If a `feat` commit is included, the version is bumped by a minor increment (0.x.0), if only `fix` is included a patch will be used (0.0.x).
- Automatically update CHANGELOG.md with all changes since the last version.
- Create a tag matching the version number.

> Note: in a repo where you have direct push access, you would simply update on develop and push. As we are using Git-Flow, a PR is necessary.
## Creating Releases

1. Update the version throughout the code ([Bumping a Version](#bumping-a-version)).
2. Click `Draft a new release`.
3. Click `Choose a tag`, then input the current version number and press enter (this will automatically create a matching tag for your release).
4. Set the `Release title` to v`x.x.x`, replacing with your version number.
5. Add a description if possible, then release.

62 changes: 62 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
[build-system]
requires = ["setuptools>=61.0.0", "wheel"]
build-backend = "setuptools.build_meta"

[project]
name = "raw-data-api"
version = "1.0.17"
description = "Set of high-performant APIs for transforming and exporting OpenStreetMap (OSM) data in different GIS file formats."
readme = "README.md"
authors = [{ name = "Hot Tech Team", email = "[email protected]" }]
license = { file = "LICENSE" }
classifiers = [
"Programming Language :: Python :: 3",
]
keywords = [
"OSM", "rawdataapi",
]
dependencies = [
"pytest==7.4.3",
"psycopg2",
"boto3==1.24.38",
"fastapi==0.105.0",
"geojson==3.1.0",
"area==1.1.1",
"orjson==3.9.10",
"slowapi==0.1.8",
]
requires-python = ">=3.8"

[project.optional-dependencies]
build = ["build", "twine"]
dev = ["black", "bumpver", "isort"]

[project.urls]
repository = "https://github.com/hotosm/fAIr-utilities"

[tool.bumpver]
current_version = "1.0.51"
version_pattern = "MAJOR.MINOR.PATCH"
commit_message = "bump version {old_version} -> {new_version}"
commit = true
tag = true
push = false

[tool.bumpver.file_patterns]
"pyproject.toml" = [
'current_version = "{version}"',
'version = "{version}"',
]

[tool.isort]
profile = "black"
import_heading_stdlib = "Standard library imports"
import_heading_thirdparty = "Third party imports"
import_heading_firstparty = "Reader imports"

[tool.commitizen]
name = "cz_conventional_commits"
tag_format = "$version"
version_scheme = "semver"
version_provider = "pep621"
update_changelog_on_bump = true

0 comments on commit 397413a

Please sign in to comment.