Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(CHANGELOG): use git-cliff to generate changelog #375

Merged
merged 1 commit into from
Dec 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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
Expand Down
94 changes: 88 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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"
Expand Down Expand Up @@ -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 = """
<!-- generated by git-cliff -->
"""
# postprocessors
postprocessors = [
{ pattern = '<REPO>', 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}](<REPO>/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
Expand Down
Loading