Skip to content

Commit 3162001

Browse files
ci: release workflow
1 parent 06c9aa7 commit 3162001

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

.git-cliff.toml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
[changelog]
2+
body = """
3+
4+
<img src="https://raw.githubusercontent.com/rinlit-233-shiroko/class-widgets-2/main/docs/assets/release_banner.png" width="100%" />
5+
6+
> [!WARNING]
7+
> 目前 Class Widgets 2 SDK 仍然处于开发阶段。
8+
> 欢迎反馈意见和建议谢谢喵
9+
10+
## Class Widgets 2 SDK 更新速递
11+
> [!NOTE]
12+
> 当前版本:`{% if version %}({{ version }}){%- endif -%}`
13+
14+
{% for group, commits in commits | group_by(attribute="group") %}
15+
16+
{% if group != "✨ 新亮点" %}
17+
<details>
18+
<summary><h3>{{ group | upper_first }}</h3></summary>
19+
{% for commit in commits | unique(attribute="message") %}
20+
- {% if commit.scope %}{{ commit.scope }}: {%- endif -%}{{ commit.message | upper_first }}\
21+
{% if commit.remote.username %} 作者: @{{ commit.remote.username }}{%- endif -%}
22+
{% if commit.remote.pr_number %} 在 \
23+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
24+
{%- endif %}
25+
{% endfor %}
26+
</details>
27+
{% else %}
28+
### {{ group | upper_first }}
29+
{% for commit in commits | unique(attribute="message") %}
30+
- {% if commit.scope %}{{ commit.scope }}: {%- endif -%}{{ commit.message | upper_first }}\
31+
{% if commit.remote.username %} 作者: @{{ commit.remote.username }}{%- endif -%}
32+
{% if commit.remote.pr_number %} 在 \
33+
[#{{ commit.remote.pr_number }}]({{ self::remote_url() }}/pull/{{ commit.remote.pr_number }}) \
34+
{%- endif %}
35+
{% endfor %}
36+
{% endif %}
37+
38+
{% endfor -%}
39+
40+
{% if version %}
41+
{% if previous.version %}
42+
**完整 Changelog**: {{ self::remote_url() }}/compare/{{ previous.version }}...{{ version }}
43+
{% endif %}
44+
{% else -%}
45+
{% raw %}\n{% endraw %}
46+
{% endif %}
47+
48+
{%- macro remote_url() -%}
49+
https://github.com/rinlit-233-shiroko/class-widgets-sdk
50+
{%- endmacro -%}
51+
52+
"""
53+
trim = true
54+
footer = "<!-- generated by git-cliff -->"
55+
output = "CHANGELOG.md"
56+
57+
58+
[git]
59+
conventional_commits = true
60+
filter_unconventional = true
61+
split_commits = false
62+
commit_parsers = [
63+
{ message = "^feat", group = "✨ 新亮点"},
64+
{ message = "^fix", group = "🛠️ 修复的问题"},
65+
{ message = "^refactor", group = "🔃 功能重构"},
66+
{ message = "^docs", group = "📄 文档更新"}
67+
]
68+
protect_breaking_commits = false
69+
filter_commits = true
70+
topo_order = false
71+
sort_commits = "oldest"
72+
link_parsers = []

.github/workflows/release.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release ClassWidgets-2 SDK
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
release:
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: ⬇️ Checkout code
18+
uses: actions/checkout@v5
19+
with:
20+
fetch-depth: 0
21+
22+
- name: 🧱 Set up git-cliff
23+
uses: kenji-miyake/setup-git-cliff@v2
24+
25+
- name: 📜 Generate CHANGELOG.md
26+
run: |
27+
git cliff --latest --tag "${{ github.ref_name }}" --config .git-cliff.toml > CHANGELOG.md
28+
29+
- name: 🚀 Create GitHub Release
30+
uses: softprops/action-gh-release@v2
31+
with:
32+
name: Class Widgets 2 SDK ${{ github.ref_name }}
33+
tag_name: ${{ github.ref_name }}
34+
body_path: CHANGELOG.md
35+
prerelease: ${{ github.event_name == 'push' || github.ref != 'refs/heads/main' }}
36+
env:
37+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)