Skip to content

Commit 2a1f398

Browse files
authored
feat: semver (#8)
Signed-off-by: Dmitriy Safronov <zimniy@cyberbrain.pw>
1 parent cfee30a commit 2a1f398

File tree

6 files changed

+225
-4
lines changed

6 files changed

+225
-4
lines changed

.cliff.git.toml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
[changelog]
2+
# changelog header
3+
header = """
4+
# Changelog\n
5+
All notable changes to this project will be documented in this file.\n
6+
"""
7+
# template for the changelog body
8+
# https://keats.github.io/tera/docs/#introduction
9+
body = """
10+
{% if version %}\
11+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
12+
{% else %}\
13+
## [unreleased]
14+
{% endif %}\
15+
{% for group, commits in commits | group_by(attribute="group") %}
16+
### {{ group | striptags | trim | upper_first }}
17+
{% for commit in commits %}
18+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
19+
{% if commit.breaking %}[**breaking**] {% endif %}\
20+
{{ commit.message | upper_first }}\
21+
{% endfor %}
22+
{% endfor %}\n
23+
"""
24+
# template for the changelog footer
25+
footer = """
26+
<!-- generated by git-cliff -->
27+
"""
28+
# remove the leading and trailing s
29+
trim = true
30+
31+
[git]
32+
# parse the commits based on https://www.conventionalcommits.org
33+
conventional_commits = true
34+
# filter out the commits that are not conventional
35+
filter_unconventional = true
36+
# process each line of a commit as an individual commit
37+
split_commits = false
38+
# regex for parsing and grouping commits
39+
commit_parsers = [
40+
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
41+
{ message = "^fix|^bugfix|^hotfix", group = "<!-- 1 -->🐛 Bug Fixes" },
42+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
43+
{ message = "^doc.*update changelog.*", group = "<!-- 3 -->📚 Documentation", skip = true },
44+
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
45+
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
46+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
47+
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
48+
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks", skip = true },
49+
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
50+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
51+
{ message = "^chore\\(release\\): prepare for", skip = true },
52+
{ message = "^chore\\(deps.*\\)", skip = true },
53+
{ message = "^chore\\(pr\\)", skip = true },
54+
{ message = "^chore\\(pull\\)", skip = true },
55+
]
56+
# protect breaking changes from being skipped due to matching a skipping commit_parser
57+
protect_breaking_commits = true
58+
# filter out the commits that are not matched by commit parsers
59+
filter_commits = true
60+
# sort the tags topologically
61+
topo_order = false
62+
# sort the commits inside sections by oldest/newest order
63+
sort_commits = "newest"
64+
# limit the number of commits included in the changelog.
65+
limit_commits = 100000

.cliff.release.toml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
[changelog]
2+
# template for the changelog body
3+
# https://keats.github.io/tera/docs/#introduction
4+
body = """
5+
{% for group, commits in commits | group_by(attribute="group") %}
6+
## {{ group | striptags | trim | upper_first }}
7+
{% for commit in commits %}
8+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
9+
{% if commit.breaking %}[**breaking**] {% endif %}\
10+
{{ commit.message | upper_first }}\
11+
{% endfor %}
12+
{% endfor %}
13+
"""
14+
# remove the leading and trailing s
15+
trim = true
16+
17+
[git]
18+
# parse the commits based on https://www.conventionalcommits.org
19+
conventional_commits = true
20+
# filter out the commits that are not conventional
21+
filter_unconventional = true
22+
# process each line of a commit as an individual commit
23+
split_commits = false
24+
# regex for parsing and grouping commits
25+
commit_parsers = [
26+
{ message = "^feat", group = "<!-- 0 -->🚀 Features" },
27+
{ message = "^fix|^bugfix|^hotfix", group = "<!-- 1 -->🐛 Bug Fixes" },
28+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
29+
{ message = "^doc.*update changelog.*", group = "<!-- 3 -->📚 Documentation", skip = true },
30+
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" },
31+
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" },
32+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
33+
{ message = "^test", group = "<!-- 6 -->🧪 Testing" },
34+
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Miscellaneous Tasks", skip = true },
35+
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" },
36+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
37+
{ message = "^chore\\(release\\): prepare for", skip = true },
38+
{ message = "^chore\\(deps.*\\)", skip = true },
39+
{ message = "^chore\\(pr\\)", skip = true },
40+
{ message = "^chore\\(pull\\)", skip = true },
41+
]
42+
# protect breaking changes from being skipped due to matching a skipping commit_parser
43+
protect_breaking_commits = true
44+
# filter out the commits that are not matched by commit parsers
45+
filter_commits = true
46+
# sort the tags topologically
47+
topo_order = false
48+
# sort the commits inside sections by oldest/newest order
49+
sort_commits = "newest"
50+
# limit the number of commits included in the changelog.
51+
limit_commits = 100000

.github/dependabot.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
version: 2
88
updates:
9-
- package-ecosystem: "pip" # See documentation for possible values
10-
directory: "/.requirements" # Location of package manifests
9+
- package-ecosystem: "pip"
10+
directory: "/.requirements"
1111
schedule:
1212
interval: "weekly"
1313
labels:
1414
- "dependencies"
1515
- package-ecosystem: "github-actions"
16-
directory: "/"
16+
directory: "/.github/workflows"
1717
schedule:
18-
interval: "daily"
18+
interval: "weekly"
1919
labels:
2020
- "dependencies"
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Push [create tag]
2+
"on":
3+
push:
4+
branches:
5+
- main
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: false
9+
jobs:
10+
merge:
11+
name: Push [create tag]
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
if: "${{ ! startsWith(github.event.head_commit.message, 'docs: update changelog for ') }}"
16+
uses: actions/checkout@v4.1.6
17+
with:
18+
token: ${{ secrets.PAT }}
19+
fetch-depth: 0
20+
21+
- name: Get Next Version
22+
if: "${{ ! startsWith(github.event.head_commit.message, 'docs: update changelog for ') }}"
23+
id: semver
24+
uses: ietf-tools/semver-action@v1.8.0
25+
with:
26+
token: ${{ github.token }}
27+
branch: main
28+
noVersionBumpBehavior: silent
29+
noNewCommitBehavior: silent
30+
31+
- name: Update CHANGELOG.md
32+
if: "${{ ! startsWith(github.event.head_commit.message, 'docs: update changelog for ') && steps.semver.outputs.next != '' }}"
33+
uses: orhun/git-cliff-action@v4
34+
with:
35+
config: .cliff.git.toml
36+
args: --tag ${{ steps.semver.outputs.next }}
37+
env:
38+
OUTPUT: CHANGELOG.md
39+
40+
- uses: EndBug/add-and-commit@v9.1.4
41+
if: "${{ ! startsWith(github.event.head_commit.message, 'docs: update changelog for ') && steps.semver.outputs.next != '' }}"
42+
with:
43+
add: 'CHANGELOG.md'
44+
commit: --signoff
45+
default_author: github_actor
46+
fetch: true
47+
message: 'docs: update changelog for ${{ steps.semver.outputs.next }}'
48+
tag: '${{ steps.semver.outputs.next }} --force'
49+
tag_push: '--force'

.github/workflows/push-rebase.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Push [rebase]
2+
"on":
3+
push:
4+
branches:
5+
- main
6+
concurrency:
7+
group: push-rebase-main
8+
cancel-in-progress: true
9+
jobs:
10+
rebase:
11+
name: Push [rebase]
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Rebase all pull requests on push to the main branch
15+
uses: peter-evans/rebase@v3.0.0
16+
with:
17+
base: main
18+
exclude-drafts: true
19+
exclude-labels: |
20+
no-rebase
21+
dependencies
22+
if: "${{ startsWith(github.event.head_commit.message, 'docs: update changelog for ') }}"

.github/workflows/tag-release.yaml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Tag [release]
2+
"on":
3+
push:
4+
tags:
5+
- v[0-9]+.[0-9]+.[0-9]+
6+
jobs:
7+
tag_release:
8+
name: Tag [release]
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4.1.6
13+
with:
14+
token: ${{ secrets.PAT }}
15+
fetch-depth: 0
16+
17+
- name: Update release description .CHANGELOG.md
18+
uses: orhun/git-cliff-action@v4
19+
id: changelog-release
20+
with:
21+
config: .cliff.release.toml
22+
args: --current --strip all
23+
env:
24+
OUTPUT: .CHANGELOG.md
25+
26+
- name: Create Release
27+
uses: ncipollo/release-action@v1.14.0
28+
with:
29+
allowUpdates: true
30+
draft: false
31+
makeLatest: true
32+
name: ${{ github.ref_name }}
33+
body: ${{ steps.changelog-release.outputs.content }}
34+
token: ${{ secrets.PAT }}

0 commit comments

Comments
 (0)