Skip to content

Commit

Permalink
feat(example): add github-keepachangelog example
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Dec 25, 2023
1 parent 226fb9e commit 485adeb
Show file tree
Hide file tree
Showing 4 changed files with 195 additions and 11 deletions.
92 changes: 92 additions & 0 deletions examples/github-keepachangelog.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[changelog]
# changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\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 -%}
### Details\
{% for group, commits in commits | group_by(attribute="group") %}
#### {{ group | upper_first }}
{%- for commit in commits %}
- {{ commit.message | upper_first | trim }}\
{% if commit.github.username %} by @{{ commit.github.username }}{%- endif -%}
{% if commit.github.pr_number %} in #{{ commit.github.pr_number }}{%- endif -%}
{% endfor %}
{% endfor %}
{%- if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
## New Contributors
{%- endif -%}
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
* @{{ contributor.username }} made their first contribution in #{{ contributor.pr_number }}\
{%- endfor %}\n
"""
# template for the changelog footer
footer = """
{% for release in releases -%}
{% if release.version -%}
{% if release.previous.version -%}
[{{ release.version | trim_start_matches(pat="v") }}]: \
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}\
/compare/{{ release.previous.version }}..{{ release.version }}
{% endif -%}
{% else -%}
[unreleased]: https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}\
/compare/{{ release.previous.version }}..HEAD
{% endif -%}
{% endfor %}
<!-- generated by git-cliff -->
"""
# remove the leading and trailing whitespace from the templates
trim = true

[git]
# parse the commits based on https://www.conventionalcommits.org
conventional_commits = true
# filter out the commits that are not conventional
filter_unconventional = true
# process each line of a commit as an individual commit
split_commits = false
commit_preprocessors = [{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "" }]
# regex for parsing and grouping commits
commit_parsers = [
{ message = "^.*: add", group = "Added" },
{ message = "^.*: support", group = "Added" },
{ message = "^.*: remove", group = "Removed" },
{ message = "^.*: delete", group = "Removed" },
{ message = "^test", group = "Fixed" },
{ message = "^fix", group = "Fixed" },
{ message = "^.*: fix", group = "Fixed" },
{ message = "^.*", group = "Changed" },
]
# 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 = true
# 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"
4 changes: 0 additions & 4 deletions examples/github.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# git-cliff ~ 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.

# [remote.github]
# owner = "orhun"
Expand Down
102 changes: 102 additions & 0 deletions website/docs/templating/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,108 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

</details>

#### [GitHub + Keep a Changelog](https://github.com/orhun/git-cliff/tree/main/examples/github-keepachangelog.toml)

<details>
<summary>Raw Output</summary>

```
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Details
#### Added
- Support multiple file formats by @orhun
#### Changed
- Use cache while fetching pages by @orhun
## [1.0.1] - 2021-07-18
### Details
#### Added
- Add release script by @orhun
#### Changed
- Expose string functions by @orhun
## [1.0.0] - 2021-07-18
### Details
#### Added
- Add README.md by @orhun
- Add ability to parse arrays by @orhun
- Add tested usage example by @orhun
#### Fixed
- Rename help argument due to conflict by @orhun
[unreleased]: https://github.com/orhun/git-cliff-readme-example/compare/v1.0.1..HEAD
[1.0.1]: https://github.com/orhun/git-cliff-readme-example/compare/v1.0.0..v1.0.1
<!-- generated by git-cliff -->
```

</details>

<details>
<summary>Rendered Output</summary>

# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Details

#### Added

- Support multiple file formats by @orhun

#### Changed

- Use cache while fetching pages by @orhun

## [1.0.1] - 2021-07-18

### Details

#### Added

- Add release script by @orhun

#### Changed

- Expose string functions by @orhun

## [1.0.0] - 2021-07-18

### Details

#### Added

- Add README.md by @orhun
- Add ability to parse arrays by @orhun
- Add tested usage example by @orhun

#### Fixed

- Rename help argument due to conflict by @orhun

[unreleased]: https://github.com/orhun/git-cliff-readme-example/compare/v1.0.1..HEAD
[1.0.1]: https://github.com/orhun/git-cliff-readme-example/compare/v1.0.0..v1.0.1

<!-- generated by git-cliff -->

</details>

#### [Minimal](https://github.com/orhun/git-cliff/tree/main/examples/minimal.toml)

<details>
Expand Down
8 changes: 1 addition & 7 deletions website/docs/usage/initializing.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,10 @@ Here are the list of available templates:

- [`keepachangelog.toml`](https://github.com/orhun/git-cliff/tree/main/examples/keepachangelog.toml): changelog in [Keep a Changelog format](https://keepachangelog.com/en/1.1.0/).
- [`github.toml`](https://github.com/orhun/git-cliff/tree/main/examples/github.toml): changelog in the [GitHub's format](https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes).
- [`github-keepachangelog.toml`](https://github.com/orhun/git-cliff/tree/main/examples/github-keepachangelog.toml): combination of the previous two formats.
- [`detailed.toml`](https://github.com/orhun/git-cliff/tree/main/examples/detailed.toml): changelog that contains links to the commits.
- [`minimal.toml`](https://github.com/orhun/git-cliff/tree/main/examples/minimal.toml): minimal changelog.
- [`scoped.toml`](https://github.com/orhun/git-cliff/tree/main/examples/scoped.toml): changelog with commits are grouped by their scopes.
- [`scopesorted.toml`](https://github.com/orhun/git-cliff/tree/main/examples/scopesorted.toml): changelog with commits grouped by their scopes and sorted by group.
- [`cocogitto.toml`](https://github.com/orhun/git-cliff/tree/main/examples/cocogitto.toml): changelog similar to [cocogitto's format](https://github.com/cocogitto/cocogitto/blob/main/CHANGELOG.md).
- [`unconventional.toml`](https://github.com/orhun/git-cliff/tree/main/examples/unconventional.toml): changelog for unconventional commits.
- [`keepachangelog.toml`](https://github.com/orhun/git-cliff/tree/main/examples/keepachangelog.toml)
- [`detailed.toml`](https://github.com/orhun/git-cliff/tree/main/examples/detailed.toml)
- [`minimal.toml`](https://github.com/orhun/git-cliff/tree/main/examples/minimal.toml)
- [`scoped.toml`](https://github.com/orhun/git-cliff/tree/main/examples/scoped.toml)
- [`scopesorted.toml`](https://github.com/orhun/git-cliff/tree/main/examples/scopesorted.toml)
- [`cocogitto.toml`](https://github.com/orhun/git-cliff/tree/main/examples/cocogitto.toml)
- [`unconventional.toml`](https://github.com/orhun/git-cliff/tree/main/examples/unconventional.toml)

0 comments on commit 485adeb

Please sign in to comment.