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

ci: generate changelog using git-cliff #21

Merged
merged 2 commits into from
Oct 2, 2024
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
13 changes: 7 additions & 6 deletions .github/workflows/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,16 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
ruby-version: "3"
bundler-cache: true
fetch-depth: 0

- run: bundle exec rake changelog
- uses: orhun/git-cliff-action@v3
with:
config: cliff.toml
args: v1.0.0..HEAD
env:
CHANGELOG_GITHUB_TOKEN: ${{ github.token }}
OUTPUT: CHANGELOG.md
GITHUB_REPO: ${{ github.repository }}

- uses: ryancyq/github-signed-commit@v1
env:
Expand Down
2 changes: 0 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ group :development do
gem "rubocop", "~> 1.65", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false

gem "github_changelog_generator", "~> 1.16", require: false
end

group :test do
Expand Down
89 changes: 0 additions & 89 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,103 +7,23 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
async (2.17.0)
console (~> 1.26)
fiber-annotation
io-event (~> 1.6, >= 1.6.5)
async-http (0.79.0)
async (>= 2.10.2)
async-pool (~> 0.7)
io-endpoint (~> 0.11)
io-stream (~> 0.4)
protocol-http (~> 0.37)
protocol-http1 (~> 0.27)
protocol-http2 (~> 0.19)
traces (>= 0.10)
async-http-faraday (0.19.0)
async-http (~> 0.42)
faraday
async-pool (0.8.1)
async (>= 1.25)
metrics
traces
base64 (0.2.0)
bigdecimal (3.1.8)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
console (1.27.0)
fiber-annotation
fiber-local (~> 1.1)
json
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.1)
drb (2.2.1)
faraday (2.12.0)
faraday-net_http (>= 2.0, < 3.4)
json
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-net_http (3.3.0)
net-http
fiber-annotation (0.2.0)
fiber-local (1.1.0)
fiber-storage
fiber-storage (1.0.0)
github_changelog_generator (1.16.4)
activesupport
async (>= 1.25.0)
async-http-faraday
faraday-http-cache
multi_json
octokit (~> 4.6)
rainbow (>= 2.2.1)
rake (>= 10.0)
hashdiff (1.1.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-endpoint (0.13.1)
io-event (1.6.5)
io-stream (0.4.1)
json (2.7.2)
language_server-protocol (3.17.0.3)
logger (1.6.1)
metrics (0.10.2)
minitest (5.25.1)
multi_json (1.15.0)
net-http (0.4.1)
uri
octokit (4.25.1)
faraday (>= 1, < 3)
sawyer (~> 0.9)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
protocol-hpack (1.5.1)
protocol-http (0.37.0)
protocol-http1 (0.27.0)
protocol-http (~> 0.22)
protocol-http2 (0.19.2)
protocol-hpack (~> 1.4)
protocol-http (~> 0.18)
public_suffix (5.1.1)
racc (1.8.1)
rainbow (3.1.1)
Expand Down Expand Up @@ -140,10 +60,6 @@ GEM
rubocop-rspec (3.0.5)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
sawyer (0.9.2)
addressable (>= 2.3.5)
faraday (>= 0.17.3, < 3)
securerandom (0.3.1)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand All @@ -154,11 +70,7 @@ GEM
simplecov-html (0.13.0)
simplecov_json_formatter (0.1.4)
thor (1.3.2)
traces (0.13.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.1)
vcr (6.3.1)
base64
webmock (3.24.0)
Expand All @@ -174,7 +86,6 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
github_changelog_generator (~> 1.16)
rake (~> 13.0)
rodiff!
rspec (~> 3.12)
Expand Down
84 changes: 84 additions & 0 deletions cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# git-cliff ~ configuration file
# https://git-cliff.org/docs/configuration

[changelog]
# template for the changelog header
header = """
# Changelog\n
All notable changes to this project will be documented in this file. See [conventional commits](https://www.conventionalcommits.org/) for commit guidelines.\n
"""
# template for the changelog body
# https://keats.github.io/tera/docs/#introduction
body = """
---
{% if version %}\
{% if previous.version %}\
## [{{ version | trim_start_matches(pat="v") }}]($REPO/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
{% else %}\
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
{% endif %}\
{% else %}\
## [unreleased]
{% endif %}\
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | striptags | trim | upper_first }}
{% for commit in commits
| filter(attribute="scope")
| sort(attribute="scope") %}
- **({{commit.scope}})**{% if commit.breaking %} [**breaking**]{% endif %} \
{{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
{%- endfor -%}
{% raw %}\n{% endraw %}\
{%- for commit in commits %}
{%- if commit.scope -%}
{% else -%}
- {% if commit.breaking %} [**breaking**]{% endif %}\
{{ commit.message }} - ([{{ commit.id | truncate(length=7, end="") }}]($REPO/commit/{{ commit.id }})) - {{ commit.author.name }}
{% endif -%}
{% endfor -%}
{% endfor %}\n
"""
# template for the changelog footer
footer = """
<!-- generated by git-cliff -->
"""
# remove the leading and trailing whitespace from the templates
trim = true
# postprocessors
postprocessors = [
{ pattern = '\$REPO', replace = "https://github.com/ryancyq/rodiff" }, # replace repository URL
]

[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
# 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 = "Refactoring" },
{ message = "^style", group = "Style" },
{ message = "^revert", group = "Revert" },
{ message = "^test", group = "Tests" },
{ message = "^chore\\(version\\):", skip = true },
{ message = "^chore", group = "Miscellaneous Chores", skip = true },
{ message = "^ci", skip = true },
{ message = "^release", skip = true },
{ body = ".*security", group = "Security" },
]
# filter out the commits that are not matched by commit parsers
filter_commits = false
# sort the tags topologically
topo_order = false
# sort the commits inside sections by oldest/newest order
sort_commits = "oldest"
7 changes: 0 additions & 7 deletions tasks/changelog.rake

This file was deleted.