Skip to content

Commit

Permalink
ci: remove gem github_changelog_generator in favor of git-cliff-action (
Browse files Browse the repository at this point in the history
  • Loading branch information
ryancyq authored Oct 3, 2024
2 parents 3665a77 + 01deca2 commit 617f296
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 88 deletions.
22 changes: 12 additions & 10 deletions .github/workflows/changelog.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Generate CHANGELOG.md

on:
workflow_run: # workflow_run only runs on default branch
workflows: [publish]
workflow_run: # only runs on default branch
workflows: [CI]
types: [completed]
branches: [main] # prevent test runs in other branches trigger change log generation in main branch
workflow_dispatch: # allow manual run of workflow
branches: [main]
workflow_dispatch:
schedule:
- cron: 0 12 * * 5

Expand All @@ -14,7 +14,7 @@ concurrency:
cancel-in-progress: true

jobs:
changelog_generator:
changelog:
runs-on: ubuntu-latest
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
permissions:
Expand All @@ -23,14 +23,16 @@ jobs:

steps:
- uses: actions/checkout@v4

- uses: ruby/setup-ruby@v1
with:
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 @@ -20,6 +20,4 @@ group :development do
gem "rubocop", "~> 1.66", require: false
gem "rubocop-rake", require: false
gem "rubocop-rspec", require: false

gem "github_changelog_generator", "~> 1.16", require: false
end
67 changes: 0 additions & 67 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,70 +78,23 @@ GEM
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.15.3)
console (~> 1.26)
fiber-annotation
io-event (~> 1.6, >= 1.6.5)
async-http (0.70.0)
async (>= 2.10.2)
async-pool (~> 0.7)
io-endpoint (~> 0.11)
io-stream (~> 0.4)
protocol-http (~> 0.28)
protocol-http1 (~> 0.19)
protocol-http2 (~> 0.18)
traces (>= 0.10)
async-http-faraday (0.18.0)
async-http (~> 0.42)
faraday
async-pool (0.8.0)
async (>= 1.25)
base64 (0.2.0)
bigdecimal (3.1.8)
builder (3.3.0)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
console (1.27.0)
fiber-annotation
fiber-local (~> 1.1)
json
crass (1.0.6)
date (3.3.4)
diff-lcs (1.5.1)
docile (1.4.1)
drb (2.2.1)
erubi (1.13.0)
faraday (2.10.1)
faraday-net_http (>= 2.0, < 3.2)
logger
faraday-http-cache (2.5.1)
faraday (>= 0.8)
faraday-net_http (3.1.1)
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)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
io-endpoint (0.13.0)
io-event (1.6.5)
io-stream (0.4.0)
irb (1.14.0)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
Expand All @@ -159,9 +112,6 @@ GEM
marcel (1.0.4)
mini_mime (1.1.5)
minitest (5.25.1)
multi_json (1.15.0)
net-http (0.4.1)
uri
net-imap (0.4.14)
date
net-protocol
Expand All @@ -184,23 +134,12 @@ GEM
racc (~> 1.4)
nokogiri (1.16.7-x86_64-linux)
racc (~> 1.4)
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.0)
protocol-http (0.28.1)
protocol-http1 (0.19.1)
protocol-http (~> 0.22)
protocol-http2 (0.18.0)
protocol-hpack (~> 1.4)
protocol-http (~> 0.18)
psych (5.1.2)
stringio
public_suffix (6.0.1)
racc (1.8.1)
rack (3.1.7)
rack-session (2.0.0)
Expand Down Expand Up @@ -282,9 +221,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)
Expand All @@ -299,11 +235,9 @@ GEM
strscan (3.1.0)
thor (1.3.1)
timeout (0.4.1)
traces (0.11.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (0.13.0)
useragent (0.16.10)
webrick (1.8.1)
websocket-driver (0.7.6)
Expand All @@ -322,7 +256,6 @@ PLATFORMS
DEPENDENCIES
actionpack (~> 7.2)
activesupport (~> 7.2)
github_changelog_generator (~> 1.16)
mime_actor!
rails (~> 7.2)
rake (>= 11.0)
Expand Down
10 changes: 1 addition & 9 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,4 @@ require "rubocop/rake_task"
RuboCop::RakeTask.new

require "rspec/core/rake_task"
RSpec::Core::RakeTask.new(:spec)

require "github_changelog_generator/task"
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
config.user = "ryancyq"
config.project = "mime_actor"
config.since_tag = "v0.1.0"
config.exclude_tags_regex = %r{v[0-9]+\.[0-9]+\.[0-9]+\..+} # pre-releases
end
RSpec::Core::RakeTask.new(:spec)
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]($REPO/tree/HEAD)
{% 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/mime_actor" }, # 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|lint)", group = "Style" },
{ message = "^revert", group = "Revert" },
{ message = "^(test|spec)", 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"

0 comments on commit 617f296

Please sign in to comment.