Skip to content

Commit d085df2

Browse files
committed
build(ci): replace bash changelog script with git-cliff
Removes ~40 lines of fragile grep/sed changelog generation in favor of git-cliff with cliff.toml config. Fixes the pipefail issue and adds proper grouping, commit links, and scope display.
1 parent 629b471 commit d085df2

3 files changed

Lines changed: 49 additions & 42 deletions

File tree

.github/workflows/release.yml

Lines changed: 7 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -76,45 +76,13 @@ jobs:
7676

7777
- name: Generate changelog
7878
id: changelog
79-
run: |
80-
TAG_NAME="v${{ inputs.version }}"
81-
PREV_TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]' | grep -v "$TAG_NAME" | head -1)
82-
if [ -z "$PREV_TAG" ]; then
83-
RANGE="$TAG_NAME"
84-
else
85-
RANGE="${PREV_TAG}..${TAG_NAME}"
86-
fi
87-
88-
echo "Generating changelog for $RANGE"
89-
90-
CHANGELOG=""
91-
add_section() {
92-
local title="$1" prefix="$2"
93-
local entries=$(git log "$RANGE" --pretty=format:"%s" --grep="^${prefix}" | sed "s/^${prefix}[:(][^)]*)[: ]*//" | sed "s/^${prefix}: //" | sed 's/^/- /')
94-
if [ -n "$entries" ]; then
95-
CHANGELOG="${CHANGELOG}### ${title}\n\n${entries}\n\n"
96-
fi
97-
}
98-
99-
add_section "Features" "feat"
100-
add_section "Bug Fixes" "fix"
101-
add_section "Performance" "perf"
102-
add_section "Refactor" "refactor"
103-
add_section "Documentation" "docs"
104-
105-
# Miscellaneous (chore, excluding release/version bumps)
106-
MISC=$(git log "$RANGE" --pretty=format:"%s" --grep="^chore" | grep -v -E "^chore\((release|version)\)" | grep -v "^chore: version" | sed 's/^chore[:(][^)]*)[: ]*//' | sed 's/^chore: //' | sed 's/^/- /' || true)
107-
if [ -n "$MISC" ]; then
108-
CHANGELOG="${CHANGELOG}### Miscellaneous\n\n${MISC}\n\n"
109-
fi
110-
111-
if [ -z "$CHANGELOG" ]; then
112-
CHANGELOG="No notable changes."
113-
fi
114-
115-
# Write to file for multi-line safety
116-
echo -e "$CHANGELOG" > changelog.md
117-
shell: bash
79+
uses: orhun/git-cliff-action@v4
80+
with:
81+
config: cliff.toml
82+
args: --latest --strip header
83+
env:
84+
OUTPUT: changelog.md
85+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
11886

11987
- name: Build and Release
12088
uses: tauri-apps/tauri-action@v0

cliff.toml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# git-cliff ~ configuration
2+
# https://git-cliff.org/docs/configuration
3+
4+
[changelog]
5+
body = """
6+
{% for group, commits in commits | group_by(attribute="group") %}\
7+
### {{ group | striptags | trim | upper_first }}
8+
{% for commit in commits %}\
9+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
10+
{{ commit.message | split(pat="\n") | first | upper_first | trim }}\
11+
{% if commit.breaking %} **[breaking]**{% endif %} \
12+
([{{ commit.id | truncate(length=7, end="") }}](https://github.com/kbzowski/ntfier/commit/{{ commit.id }}))\
13+
{% endfor %}
14+
{% endfor %}
15+
"""
16+
trim = true
17+
18+
[git]
19+
conventional_commits = true
20+
filter_unconventional = true
21+
split_commits = false
22+
commit_preprocessors = [
23+
{ pattern = '\((\w+\s)?#([0-9]+)\)', replace = "([#${2}](https://github.com/kbzowski/ntfier/issues/${2}))" },
24+
]
25+
commit_parsers = [
26+
{ message = "^feat", group = "<!-- 0 -->Features" },
27+
{ message = "^fix", group = "<!-- 1 -->Bug Fixes" },
28+
{ message = "^perf", group = "<!-- 2 -->Performance" },
29+
{ message = "^refactor", group = "<!-- 3 -->Refactoring" },
30+
{ message = "^docs", group = "<!-- 4 -->Documentation" },
31+
{ message = "^style", group = "<!-- 6 -->Style" },
32+
{ message = "^build", group = "<!-- 7 -->Build" },
33+
{ message = "^chore\\(release\\)", skip = true },
34+
{ message = "^chore\\(version\\)", skip = true },
35+
{ message = "^chore: release", skip = true },
36+
{ message = "^chore: bump version", skip = true },
37+
{ message = "^chore", group = "<!-- 5 -->Miscellaneous" },
38+
{ message = "^ci", group = "<!-- 5 -->Miscellaneous" },
39+
]
40+
filter_commits = false
41+
sort_commits = "newest"

src-tauri/src/commands/notifications.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ pub fn set_notification_favorite(
110110

111111
#[tauri::command]
112112
#[specta::specta]
113-
pub fn get_favorite_notifications(
114-
db: State<'_, Database>,
115-
) -> Result<Vec<Notification>, AppError> {
113+
pub fn get_favorite_notifications(db: State<'_, Database>) -> Result<Vec<Notification>, AppError> {
116114
db.get_favorite_notifications()
117115
}
118116

0 commit comments

Comments
 (0)