-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(changelog): create changelog generation (#449)
* chore(changelog): create changelog generation * ci: add conventional commit validation for PRs * fix: remove unused changelog * ci: restructure workflows * ci: update workflows * ci: pr workflow to run on synchronize events
- Loading branch information
1 parent
942897d
commit e65d173
Showing
7 changed files
with
641 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: Build & Test & Push Image | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "develop" | ||
tags: | ||
- "v*" | ||
jobs: | ||
changelog: | ||
name: Generate changelog | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- name: Generate changelog | ||
uses: orhun/git-cliff-action@v4 | ||
with: | ||
config: cliff.toml | ||
args: --verbose | ||
env: | ||
OUTPUT: CHANGELOG.md | ||
GITHUB_REPO: ${{ github.repository }} | ||
- name: Commit | ||
run: | | ||
git checkout ${GITHUB_REF_NAME} | ||
git config user.name 'github-actions[bot]' | ||
git config user.email 'github-actions[bot]@users.noreply.github.com' | ||
set +e | ||
git add CHANGELOG.md | ||
git commit -m "chore(changelog): Update changelog [skip ci]" | ||
git push https://${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git ${GITHUB_REF_NAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: PR Conventional Commit Validation | ||
on: | ||
pull_request: | ||
types: [opened, synchronize, reopened, edited] | ||
|
||
jobs: | ||
validate-pr-title: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: PR Conventional Commit Validation | ||
uses: ytanikin/[email protected] | ||
with: | ||
task_types: '["feat","fix","docs","test","ci","refactor","perf","chore","revert", "security"]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# 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 = "f-eld-ch" | ||
repo = "sitrep" | ||
|
||
[changelog] | ||
# template for the changelog body | ||
# https://keats.github.io/tera/docs/#introduction | ||
body = """ | ||
{%- macro remote_url() -%} | ||
https://github.com/{{ remote.github.owner }}/{{ remote.github.repo }} | ||
{%- endmacro -%} | ||
{% macro print_commit(commit) -%} | ||
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\ | ||
{% if commit.breaking %}[**breaking**] {% endif %}\ | ||
{{ commit.message | upper_first }} - \ | ||
([{{ commit.id | truncate(length=7, end="") }}]({{ self::remote_url() }}/commit/{{ commit.id }}))\ | ||
{% endmacro -%} | ||
{% if version %}\ | ||
{% if previous.version %}\ | ||
## [{{ version | trim_start_matches(pat="v") }}]\ | ||
({{ self::remote_url() }}/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") %} | ||
{{ self::print_commit(commit=commit) }} | ||
{%- endfor %} | ||
{% for commit in commits %} | ||
{%- if not commit.scope -%} | ||
{{ self::print_commit(commit=commit) }} | ||
{% endif -%} | ||
{% endfor -%} | ||
{% endfor -%} | ||
{%- if github -%} | ||
{% 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 | ||
{%- if contributor.pr_number %} in \ | ||
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \ | ||
{%- endif %} | ||
{%- endfor -%} | ||
{%- endif %} | ||
""" | ||
# template for the changelog footer | ||
footer = """ | ||
Made with ♥️ in Switzerland by F-ELD | ||
""" | ||
# 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 = false | ||
# 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}](https://github.com/f-eld-ch/sitrep/issues/${2}))" }, | ||
{ pattern = '^Update dependabot\.yml', replace = "chore(dependabot): update dependabot configuration" }, | ||
{ pattern = '^Bump', replace = "chore(deps): update" }, | ||
{ pattern = '^Update French Translations', replace = "feat(translation): update french translations" }, | ||
# Check spelling of the commit with https://github.com/crate-ci/typos | ||
# If the spelling is incorrect, it will be automatically fixed. | ||
#{ pattern = '.*', replace_command = 'typos --write-changes -' }, | ||
] | ||
|
||
# regex for parsing and grouping commits | ||
commit_parsers = [ | ||
{ message = "^feat", group = "<!-- 0 -->⛰️ Features" }, | ||
{ body = "^chore\\(security\\):|^security: ", group = "<!-- 8 -->🛡️ Security" }, | ||
{ message = "^fix", group = "<!-- 1 -->🐛 Bug Fixes" }, | ||
{ message = "^doc", group = "<!-- 3 -->📚 Documentation" }, | ||
{ message = "^perf", group = "<!-- 4 -->⚡ Performance" }, | ||
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" }, | ||
{ message = "^style", group = "<!-- 5 -->🎨 Styling" }, | ||
{ message = "^test", group = "<!-- 6 -->🧪 Testing" }, | ||
{ message = "^chore\\(release\\):|^chore: (r|R)elease|^chore: prepare release", skip = true }, | ||
{ message = "^chore\\(deps-dev\\)", skip = true }, | ||
{ message = "^chore\\(pull\\)", skip = true }, | ||
{ message = "^chore\\(changelog\\):", skip = true }, | ||
{ message = "^chore|^ci", group = "<!-- 7 -->⚙️ Other" }, | ||
{ body = ".*security", group = "<!-- 8 -->🛡️ Security" }, | ||
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" }, | ||
] | ||
# 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 = false | ||
# regex for matching git tags | ||
tag_pattern = "v[0-9].*" | ||
# regex for skipping tags | ||
skip_tags = "beta|alpha" | ||
# regex for ignoring tags | ||
ignore_tags = "rc|v2.1.0|v2.1.1" | ||
# sort the tags topologically | ||
topo_order = false | ||
# sort the commits inside sections by oldest/newest order | ||
sort_commits = "newest" |