Skip to content

Commit 5f55174

Browse files
committed
fix: release body and release works
1 parent d05f5c8 commit 5f55174

File tree

3 files changed

+155
-14
lines changed

3 files changed

+155
-14
lines changed

β€Ž.github/workflows/cliff.ymlβ€Ž

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Fill Release Body
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
push:
8+
tags:
9+
- "v*"
10+
workflow_dispatch:
11+
inputs:
12+
release_name:
13+
description: "Name of release (optional)"
14+
required: false
15+
default: ""
16+
create_release:
17+
description: "Create a GitHub release? (true/false)"
18+
required: false
19+
default: "false"
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
outputs:
25+
release_name: ${{ steps.release_name.outputs.release_name }}
26+
steps:
27+
- uses: actions/checkout@v4
28+
- name: Get release name
29+
id: release_name
30+
run: |
31+
if [ -n "${{ github.event.inputs.release_name }}" ]; then
32+
echo "release_name=${{ github.event.inputs.release_name }}" >> $GITHUB_OUTPUT
33+
else
34+
echo "release_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
35+
fi
36+
37+
38+
changelog:
39+
name: Generate changelog
40+
runs-on: ubuntu-latest
41+
needs: build
42+
if: ${{ (github.event.inputs.create_release == 'true' || github.event_name == 'push') && github.event_name != 'pull_request' }}
43+
outputs:
44+
release_body: ${{ steps.git-cliff.outputs.content }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
- name: Generate a changelog
48+
uses: orhun/git-cliff-action@v4
49+
id: git-cliff
50+
with:
51+
config: cliff.toml
52+
args: -vv --latest
53+
env:
54+
OUTPUT: CHANGES.md
55+
GITHUB_REPO: ${{ github.repository }}
56+
57+
create-release:
58+
runs-on: ubuntu-latest
59+
needs: [build, changelog]
60+
if: ${{ github.event.inputs.create_release == 'true' || github.event_name == 'push' }}
61+
steps:
62+
- name: Create Release
63+
uses: softprops/action-gh-release@v2
64+
with:
65+
tag_name: ${{ needs.build.outputs.release_name }}
66+
name: ${{ needs.build.outputs.release_name }}
67+
body: ${{ needs.changelog.outputs.release_body }}

β€Ž.github/workflows/release.ymlβ€Ž

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ on:
2323
jobs:
2424
build:
2525
runs-on: ubuntu-latest
26+
outputs:
27+
release_name: ${{ steps.release_name.outputs.RELEASE_NAME }}
2628
strategy:
2729
fail-fast: false
2830
matrix:
@@ -76,18 +78,9 @@ jobs:
7678
id: release_name
7779
run: |
7880
if [ -n "${{ github.event.inputs.release_name }}" ]; then
79-
echo "RELEASE_NAME=${{ github.event.inputs.release_name }}" >> $GITHUB_ENV
81+
echo "release_name=${{ github.event.inputs.release_name }}" >> $GITHUB_OUTPUT
8082
else
81-
echo "RELEASE_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
82-
fi
83-
84-
- name: Get commit history with mentions
85-
id: commit_history
86-
run: |
87-
if [ -n "${{ github.event.inputs.release_name }}" ]; then
88-
echo "COMMIT_HISTORY=$(git log --pretty=format:'- %s (by @%an)' -n 10)" >> $GITHUB_ENV
89-
else
90-
echo "COMMIT_HISTORY=$(git log --pretty=format:'- %s (by @%an)' $(git describe --tags --abbrev=0)..HEAD)" >> $GITHUB_ENV
83+
echo "release_name=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
9184
fi
9285
9386
- name: Upload ISO as artifact
@@ -116,8 +109,9 @@ jobs:
116109
- name: Create Release
117110
uses: softprops/action-gh-release@v2
118111
with:
119-
tag_name: ${{ needs.build.outputs.RELEASE_NAME }}
120-
name: ${{ needs.build.outputs.RELEASE_NAME }}
121-
body: ${{ needs.build.outputs.COMMIT_HISTORY }}
112+
make_latest: true
113+
prerelease: ${{ needs.build.outputs.release_name != '' && contains(needs.build.outputs.release_name, 'a') }}
114+
tag_name: ${{ needs.build.outputs.release_name }}
115+
name: ${{ needs.build.outputs.release_name }}
122116
files: |
123117
combined_isos/*.iso

β€Žcliff.tomlβ€Ž

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# https://git-cliff.org/docs/configuration
2+
[changelog]
3+
header = ""
4+
# template for the changelog body
5+
# https://keats.github.io/tera/docs/#introduction
6+
body = """
7+
{% if version %}\
8+
{% if previous.version %}\
9+
## [{{ version | trim_start_matches(pat="v") }}]\
10+
({{ self::remote_url() }}/compare/{{ previous.version }}..{{ version }}) - {{ timestamp | date(format="%Y-%m-%d") }}
11+
{% else %}\
12+
## [{{ version | trim_start_matches(pat="v") }}] - {{ timestamp | date(format="%Y-%m-%d") }}
13+
{% endif %}\
14+
{% else %}\
15+
## [unreleased]
16+
{% endif %}\
17+
18+
{% for group, commits in commits | group_by(attribute="group") %}
19+
### {{ group | striptags | trim | upper_first }}
20+
{% for commit in commits
21+
| filter(attribute="scope")
22+
| sort(attribute="scope") %}
23+
{{ self::print_commit(commit=commit) }}
24+
{%- endfor %}
25+
{% for commit in commits %}
26+
{%- if not commit.scope -%}
27+
{{ self::print_commit(commit=commit) }}
28+
{% endif -%}
29+
{% endfor -%}
30+
{% endfor -%}
31+
32+
{%- if github -%}
33+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
34+
## New Contributors ❀️
35+
{% endif %}\
36+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
37+
* @{{ contributor.username }} made their first contribution
38+
{%- if contributor.pr_number %} in \
39+
[#{{ contributor.pr_number }}]({{ self::remote_url() }}/pull/{{ contributor.pr_number }}) \
40+
{%- endif %}
41+
{%- endfor -%}
42+
{%- endif %}
43+
"""
44+
footer = ""
45+
trim = true
46+
postprocessors = [
47+
{ pattern = '<REPO>', replace = "https://github.com/RustLangES/memsos" },
48+
]
49+
50+
[git]
51+
# parse the commits based on https://www.conventionalcommits.org
52+
conventional_commits = true
53+
# filter out the commits that are not conventional
54+
filter_unconventional = true
55+
split_commits = false
56+
# sort the commits inside sections by oldest/newest order
57+
sort_commits = "newest"
58+
commit_parsers = [
59+
{ message = "^feat", group = "<!-- 0 -->πŸš€ Features" },
60+
{ message = "^fix", group = "<!-- 1 -->πŸ› Bug Fixes" },
61+
{ message = "^doc", group = "<!-- 3 -->πŸ“š Documentation" },
62+
{ message = "^perf", group = "<!-- 4 -->⚑ Performance" },
63+
{ message = "^refactor", group = "<!-- 2 -->🚜 Refactor" },
64+
{ message = "^style", group = "<!-- 5 -->🎨 Styling" },
65+
{ message = "^test", group = "<!-- 6 -->πŸ§ͺ Testing" },
66+
{ message = "^chore\\(release\\): prepare for", skip = true },
67+
{ message = "^chore\\(deps.*\\)", skip = true },
68+
{ message = "^chore\\(pr\\)", skip = true },
69+
{ message = "^chore\\(pull\\)", skip = true },
70+
{ message = "^chore|^ci", group = "<!-- 7 -->βš™οΈ Miscellaneous Tasks" },
71+
{ body = ".*security", group = "<!-- 8 -->πŸ›‘οΈ Security" },
72+
{ message = "^revert", group = "<!-- 9 -->◀️ Revert" },
73+
]
74+
commit_preprocessors = [
75+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](<REPO>/issues/${2}))" },
76+
]
77+
# protect breaking changes from being skipped due to matching a skipping commit_parser
78+
protect_breaking_commits = false
79+
# filter out the commits that are not matched by commit parsers
80+
filter_commits = false

0 commit comments

Comments
Β (0)