From 397413af06fd985e6de7b3597de1e0b5847324b7 Mon Sep 17 00:00:00 2001 From: kshtiijrajsharma Date: Wed, 6 Mar 2024 22:07:15 +0545 Subject: [PATCH] feat(version-control): Allows rawdataapi to follow version control using commitizen --- docs/src/version_control.md | 60 +++++++++++++++++++++++++++++++++++ pyproject.toml | 62 +++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 docs/src/version_control.md create mode 100644 pyproject.toml diff --git a/docs/src/version_control.md b/docs/src/version_control.md new file mode 100644 index 00000000..e5bcb06c --- /dev/null +++ b/docs/src/version_control.md @@ -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**: [optional scope]: + +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. + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..a138d443 --- /dev/null +++ b/pyproject.toml @@ -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 = "sysadmin@hotosm.org" }] +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