Skip to content

Commit d0d0e93

Browse files
committed
feat: introduce auto release
1 parent 51accfc commit d0d0e93

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-0
lines changed

β€Ž.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Setup My Action Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*.*.*"
7+
8+
jobs:
9+
changelog:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Get Tag Version
18+
id: tag_version
19+
run: echo "CURRENT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
20+
21+
- name: Generate Full Changelog
22+
uses: orhun/git-cliff-action@v3
23+
with:
24+
config: cliff.toml
25+
args: --verbose
26+
env:
27+
OUTPUT: CHANGELOG.md
28+
GITHUB_REPO: ${{ github.repository }}
29+
30+
- name: Commit Changelog
31+
run: |
32+
git config user.name 'github-actions[bot]'
33+
git config user.email 'github-actions[bot]@users.noreply.github.com'
34+
set +e
35+
git switch main
36+
git add CHANGELOG.md
37+
git commit -m "chore(release-bot): prepare for release notes on ${CURRENT_TAG}"
38+
git push
39+
40+
release:
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout Code
44+
uses: actions/checkout@v4
45+
with:
46+
fetch-depth: 0
47+
48+
- name: Generate Latest Release Notes
49+
id: latest_release_notes
50+
uses: orhun/git-cliff-action@v3
51+
with:
52+
config: cliff.toml
53+
args: --latest --strip all
54+
env:
55+
OUTPUT: CHANGELOG.txt
56+
57+
- name: Create GitHub Release
58+
uses: softprops/action-gh-release@v2
59+
with:
60+
body_path: CHANGELOG.txt

β€Žcliff.toml

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# git-cliff ~ default configuration file
2+
# https://git-cliff.org/docs/configuration
3+
#
4+
# Lines starting with "#" are comments.
5+
# Configuration options are organized into tables and keys.
6+
# See documentation for more information on available options.
7+
8+
[remote.github]
9+
owner = "pplmx"
10+
repo = "setup-my-action"
11+
12+
[changelog]
13+
# template for the changelog footer
14+
header = """
15+
# Changelog\n
16+
All notable changes to this project will be documented in this file.\n
17+
"""
18+
# template for the changelog body
19+
# https://keats.github.io/tera/docs/#introduction
20+
body = """
21+
{%- macro remote_url() -%}
22+
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }}
23+
{%- endmacro -%}
24+
25+
{% macro print_commit(commit) -%}
26+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
27+
{% if commit.breaking %}[**breaking**] {% endif %}\
28+
{{ commit.message | upper_first }} - \
29+
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\
30+
{% endmacro -%}
31+
32+
{% if version %}\
33+
{% if previous.version %}\
34+
## [{{ version | trim_start_matches(pat="v") }}]\
35+
({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
36+
{% else %}\
37+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
38+
{% endif %}\
39+
{% else %}\
40+
## [unreleased]
41+
{% endif %}\
42+
43+
{% for group, commits in commits | group_by(attribute="group") %}
44+
### {{ group | striptags | trim | upper_first }}
45+
{% for commit in commits
46+
| filter(attribute="scope")
47+
| sort(attribute="scope") %}
48+
{{ self::print_commit(commit=commit) }}
49+
{%- endfor -%}
50+
{% raw %}\n{% endraw %}\
51+
{%- for commit in commits %}
52+
{%- if not commit.scope -%}
53+
{{ self::print_commit(commit=commit) }}
54+
{% endif -%}
55+
{% endfor -%}
56+
{% endfor -%}
57+
{%- if github -%}
58+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
59+
## New Contributors ❀️
60+
{% endif %}\
61+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
62+
* @{{ contributor.username }} made their first contribution
63+
{%- if contributor.pr_number %} in \
64+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
65+
{%- endif %}
66+
{%- endfor -%}
67+
{%- endif %}
68+
{% raw %}\n{% endraw -%}
69+
"""
70+
# template for the changelog footer
71+
footer = """
72+
<!-- generated by git-cliff -->
73+
"""
74+
# remove the leading and trailing s
75+
trim = true
76+
# postprocessors
77+
postprocessors = [
78+
{ pattern = '<REPO>', replace = "https://github.com/pplmx/setup-my-action" }, # replace repository URL
79+
]
80+
81+
[git]
82+
# parse the commits based on https://www.conventionalcommits.org
83+
conventional_commits = true
84+
# filter out the commits that are not conventional
85+
filter_unconventional = true
86+
# process each line of a commit as an individual commit
87+
split_commits = false
88+
# regex for preprocessing the commit messages
89+
commit_preprocessors = [
90+
# Replace issue numbers
91+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))"},
92+
# Check spelling of the commit with https://github.com/crate-ci/typos
93+
# If the spelling is incorrect, it will be automatically fixed.
94+
#{ pattern = '.*', replace_command = 'typos --write-changes -' },
95+
]
96+
# regex for parsing and grouping commits
97+
commit_parsers = [
98+
{ message = "^feat", group = "<!-- 0 -->πŸš€ Features" },
99+
{ message = "^fix", group = "<!-- 1 -->πŸ› Bug Fixes" },
100+
{ message = "^doc", group = "<!-- 3 -->πŸ“š Documentation" },
101+
{ message = "^perf", group = "<!-- 4 -->⚑ Performance" },
102+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
103+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
104+
{ message = "^test", group = "<!-- 6 -->πŸ§ͺ Testing" },
105+
{ message = "^chore\\(release\\): prepare for", skip = true },
106+
{ message = "^chore\\(release-bot\\): prepare for", skip = true },
107+
{ message = "^chore: bump version to", skip = true },
108+
{ message = "^chore\\(deps.*\\)", skip = true },
109+
{ message = "^chore\\(pr\\)", skip = true },
110+
{ message = "^chore\\(pull\\)", skip = true },
111+
{ message = "^chore|^ci", group = "<!-- 7 -->βš™οΈ Miscellaneous Tasks" },
112+
{ body = ".*security", group = "<!-- 8 -->πŸ›‘οΈ Security" },
113+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
114+
]
115+
# protect breaking changes from being skipped due to matching a skipping commit_parser
116+
protect_breaking_commits = false
117+
# filter out the commits that are not matched by commit parsers
118+
filter_commits = false
119+
# regex for matching git tags
120+
# tag_pattern = "v[0-9].*"
121+
# regex for skipping tags
122+
# skip_tags = ""
123+
# regex for ignoring tags
124+
# ignore_tags = ""
125+
# sort the tags topologically
126+
topo_order = false
127+
# sort the commits inside sections by oldest/newest order
128+
sort_commits = "newest"
129+
# limit the number of commits included in the changelog.
130+
# limit_commits = 42

0 commit comments

Comments
Β (0)