From b2d80e345093e5f5b7d7b186d6e89217b58501b3 Mon Sep 17 00:00:00 2001 From: engeir Date: Mon, 11 Dec 2023 09:19:56 +0100 Subject: [PATCH] docs(CHANGELOG): use git-cliff to generate changelog --- .github/workflows/release.yml | 10 +++- pyproject.toml | 94 ++++++++++++++++++++++++++++++++--- 2 files changed, 97 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 98dba01..b38f1fc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,7 +19,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" - name: Upgrade pip run: | @@ -51,6 +51,14 @@ jobs: version=$(poetry version | awk '{ print $2 }') && poetry version $version.dev.$(date +%s) + - name: Generate a changelog + uses: orhun/git-cliff-action@v2 + with: + config: pyproject.toml + args: --verbose + env: + OUTPUT: CHANGELOG.md + - name: Build package run: | poetry build --ansi diff --git a/pyproject.toml b/pyproject.toml index 59dfb5a..a06e34a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,10 +9,10 @@ homepage = "https://github.com/engeir/ncdump-rich" repository = "https://github.com/engeir/ncdump-rich" documentation = "https://ncdump-rich.readthedocs.io" classifiers = [ - "Development Status :: 5 - Production/Stable", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", + "Development Status :: 5 - Production/Stable", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11", ] [tool.poetry.urls] @@ -31,9 +31,9 @@ ncdump-rich = "ncdump_rich.__main__:main" [tool.poetry.group.dev.dependencies] pytest = "^7.1.2" -coverage = {extras = ["toml"], version = "^6.4"} +coverage = { extras = ["toml"], version = "^6.4" } typeguard = "^2.13.2" -xdoctest = {extras = ["colors"], version = "^1.0.0"} +xdoctest = { extras = ["colors"], version = "^1.0.0" } sphinx = "^4.5.0" sphinx-autobuild = "^2021.3.14" pre-commit = "^2.19.0" @@ -70,6 +70,88 @@ directory = "htmlcov" requires = ["poetry-core>=1.0.0"] build-backend = "poetry.core.masonry.api" +[tool.git-cliff.changelog] +# git-cliff ~ default configuration file +# https://git-cliff.org/docs/configuration +# +# Lines starting with "#" are comments. +# Configuration options are organized into tables and keys. +# See documentation for more information on available options. + +# changelog header +header = """ +# Changelog\n +All notable changes to this project will be documented in this file.\n +""" +# template for the changelog body +# https://keats.github.io/tera/docs/#introduction +body = """ +{% if version %}\ + ## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }} +{% else %}\ + ## [unreleased] +{% endif %}\ +{% for group, commits in commits | group_by(attribute="group") %} + ### {{ group | upper_first }} + {% for commit in commits %} + - {% if commit.breaking %}[**breaking**] {% endif %}{{ commit.message | upper_first }}\ + {% endfor %} +{% endfor %}\n +""" +# remove the leading and trailing whitespace from the template +trim = true +# changelog footer +footer = """ + +""" +# postprocessors +postprocessors = [ + { pattern = '', replace = "https://github.com/engeir/ncdump-rich" }, # replace repository URL +] +[tool.git-cliff.git] +# parse the commits based on https://www.conventionalcommits.org +conventional_commits = true +filter_unconventional = true +split_commits = true +# regex for preprocessing the commit messages +commit_preprocessors = [ + { pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](/issues/${2}))" }, # replace issue numbers +] +# regex for parsing and grouping commits +commit_parsers = [ + { message = "^feat", group = "Features" }, + { message = "^fix", group = "Bug Fixes" }, + { message = "^doc", group = "Documentation" }, + { message = "^perf", group = "Performance" }, + { message = "^refactor", group = "Refactor" }, + { message = "^style", group = "Styling" }, + { message = "^test", group = "Testing" }, + { message = "^chore\\(release\\): prepare for", skip = true }, + { message = "^chore\\(deps\\)", skip = true }, + { message = "^chore\\(pr\\)", skip = true }, + { message = "^chore\\(pull\\)", skip = true }, + { message = "^chore|ci", group = "Miscellaneous Tasks" }, + { body = ".*security", group = "Security" }, + { message = "^revert", group = "Revert" }, +] +# protect breaking changes from being skipped due to matching a skipping commit_parser +protect_breaking_commits = false +# filter out the commits that are not matched by commit parsers +filter_commits = false +# regex for matching git tags +tag_pattern = "v[0-9].*" + +# regex for skipping tags +skip_tags = "v0.1.0-beta.1" +# regex for ignoring tags +ignore_tags = "" +# sort the tags topologically +topo_order = false +# sort the commits inside sections by oldest/newest order +sort_commits = "oldest" +# limit the number of commits included in the changelog. +# limit_commits = 42 + [tool.mypy] allow_redefinition = false check_untyped_defs = true