Skip to content

Commit 2b6662b

Browse files
committed
ci: 发版 workflow(Windows x64) + git-cliff changelog
release.yml(tag v* 或手动触发): - package(windows-latest):pnpm check + check:py + pyinstaller aao.spec + logo.png→ico(Pillow) + rcedit 嵌 exe 图标 + 复制外置 resource/data/config + 7z 打包 zip - git_cliff:按 .github/cliff.toml 生成 release notes(conventional commits 分组) - release:softprops/action-gh-release 上传 zip + changelog cliff.toml 从 ../maa-project-new 搬入(通用 conventional 模板,feat/fix/... 分组 + 贡献者 + [skip changelog] 过滤)。 git-cliff 本地试跑验证:changelog 按 commit 类型正确分组、作者正确。
1 parent 2e6f1fe commit 2b6662b

2 files changed

Lines changed: 175 additions & 0 deletions

File tree

.github/cliff.toml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
[changelog]
2+
header = """
3+
# 更新日志 | Release Notes
4+
"""
5+
6+
body = """
7+
{% macro print_commit(commit) -%}
8+
- {% if commit.scope %}*({{ commit.scope }})* {% endif %}\
9+
{% if commit.breaking %}[**breaking**] {% endif %}\
10+
{{ commit.message | split(pat="\n") | first | upper_first }} \
11+
{% if commit.github.username %}@{{ commit.github.username }}{% else %}{{ commit.author.name }}{% endif %}
12+
{%- if commit.footers -%}
13+
{%- for footer in commit.footers -%}
14+
{%- if footer.token == "Co-authored-by" -%}
15+
{%- set co_author_name = footer.value | split(pat=" <") | first | trim %} @{{ co_author_name }}
16+
{%- endif -%}
17+
{%- endfor -%}
18+
{%- endif %}
19+
{% endmacro -%}
20+
21+
{% if version %}\
22+
## {{ version | trim_start_matches(pat="v") }} ({{ timestamp | date(format="%Y-%m-%d") }})
23+
{% else %}\
24+
## 未发布 | Unreleased
25+
{% endif %}\
26+
27+
{% for group, commits in commits | group_by(attribute="group") %}
28+
### {{ group | striptags | trim | upper_first }}
29+
{% for commit in commits | filter(attribute="scope") | sort(attribute="scope") %}
30+
{{ self::print_commit(commit=commit) }}
31+
{%- endfor %}
32+
{% for commit in commits %}
33+
{%- if not commit.scope -%}
34+
{{ self::print_commit(commit=commit) }}
35+
{% endif -%}
36+
{% endfor -%}
37+
{% endfor -%}
38+
{%- if github -%}
39+
{% if github.contributors | filter(attribute="is_first_time", value=true) | length != 0 %}
40+
## 新贡献者 | New Contributors
41+
{% endif %}\
42+
{% for contributor in github.contributors | filter(attribute="is_first_time", value=true) %}
43+
* @{{ contributor.username }} made their first contribution
44+
{%- if contributor.pr_number %} in #{{ contributor.pr_number }}{% endif %}
45+
{%- endfor -%}
46+
{%- endif %}
47+
"""
48+
49+
[git]
50+
conventional_commits = true
51+
filter_unconventional = false
52+
split_commits = false
53+
protect_breaking_commits = false
54+
commit_parsers = [
55+
{ message = ".*\\[skip changelog\\].*", skip = true },
56+
{ body = ".*\\[skip changelog\\].*", skip = true },
57+
{ message = "^feat", group = "<!-- 0 -->新功能 | Features" },
58+
{ message = "^fix", group = "<!-- 1 -->问题修复 | Bug Fixes" },
59+
{ message = "^(refactor|rft)", group = "<!-- 2 -->代码重构 | Refactoring" },
60+
{ message = "^perf", group = "<!-- 3 -->性能优化 | Performance" },
61+
{ message = "^docs", group = "<!-- 4 -->文档 | Documentation" },
62+
{ message = "^(style|styles)", group = "<!-- 5 -->样式 | Style" },
63+
{ message = "^test", group = "<!-- 6 -->测试 | Tests" },
64+
{ message = "^ci", group = "<!-- 7 -->持续集成 | Continuous Integration" },
65+
{ message = "^chore\\(deps\\)", group = "<!-- 8 -->依赖更新 | Dependencies" },
66+
{ message = "^chore", group = "<!-- 9 -->日常维护 | Maintenance" },
67+
{ body = ".*security", group = "<!-- 10 -->安全 | Security" },
68+
{ message = "^[Rr]evert", group = "<!-- 11 -->撤销 | Reverts" },
69+
]
70+
sort_commits = "oldest"
71+
72+
[git.github]
73+
commits = true

.github/workflows/release.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
workflow_dispatch:
8+
9+
jobs:
10+
package:
11+
permissions:
12+
contents: read
13+
runs-on: windows-latest
14+
steps:
15+
- uses: actions/checkout@v6
16+
- uses: actions/setup-python@v6
17+
with:
18+
python-version: '3.13'
19+
- uses: astral-sh/setup-uv@v8.1.0
20+
- uses: pnpm/action-setup@v6
21+
- uses: actions/setup-node@v6
22+
with:
23+
node-version: 24
24+
cache: pnpm
25+
- run: pnpm install --frozen-lockfile
26+
- run: pnpm check
27+
- run: pnpm check:py
28+
- name: Build (PyInstaller)
29+
run: uv run pyinstaller aao.spec --noconfirm
30+
- name: Convert logo.png to ico
31+
shell: bash
32+
run: uv run python -c "from PIL import Image; Image.open('logo.png').save('logo.ico', format='ICO', sizes=[(256,256),(128,128),(64,64),(48,48),(32,32),(16,16)])"
33+
- name: Apply app icon
34+
shell: bash
35+
run: |
36+
cp logo.ico dist/aao.app/logo.ico
37+
curl -fsSL https://github.com/electron/rcedit/releases/download/v2.0.0/rcedit-x64.exe -o rcedit.exe
38+
./rcedit.exe dist/aao.app/aao.app.exe --set-icon logo.ico
39+
echo "[OK] Applied Windows executable icon"
40+
- name: Stage external resources
41+
shell: bash
42+
run: |
43+
cp -r resource data config dist/aao.app/
44+
- name: Package
45+
shell: bash
46+
run: |
47+
mkdir -p dist
48+
archive="ArknightsAutoOperator-win-x64-${GITHUB_REF_NAME}.zip"
49+
( cd dist/aao.app && 7z a "../$archive" . )
50+
- uses: actions/upload-artifact@v7
51+
with:
52+
name: win-x64
53+
path: dist/*.zip
54+
55+
git_cliff:
56+
name: Generate release notes
57+
if: startsWith(github.ref, 'refs/tags/')
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout
61+
uses: actions/checkout@v6
62+
with:
63+
fetch-depth: 0
64+
- name: Generate release notes
65+
shell: bash
66+
env:
67+
GITHUB_REPO: ${{ github.repository }}
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
run: |
70+
version="2.13.1"
71+
archive="git-cliff-${version}-x86_64-unknown-linux-gnu.tar.gz"
72+
mkdir -p "$RUNNER_TEMP/git-cliff"
73+
curl -fsSL "https://github.com/orhun/git-cliff/releases/download/v${version}/$archive" -o "$RUNNER_TEMP/$archive"
74+
tar -xzf "$RUNNER_TEMP/$archive" -C "$RUNNER_TEMP/git-cliff"
75+
git_cliff="$(find "$RUNNER_TEMP/git-cliff" -type f -name git-cliff -perm -111 | head -n 1)"
76+
if [[ -z "$git_cliff" ]]; then
77+
echo "[ERR] git-cliff binary was not found after extraction"
78+
exit 1
79+
fi
80+
"$git_cliff" --config .github/cliff.toml --latest --strip header --output CHANGES.md
81+
- name: Upload release notes
82+
uses: actions/upload-artifact@v7
83+
with:
84+
name: release-notes
85+
path: CHANGES.md
86+
87+
release:
88+
if: startsWith(github.ref, 'refs/tags/')
89+
needs: [package, git_cliff]
90+
permissions:
91+
contents: write
92+
runs-on: ubuntu-latest
93+
steps:
94+
- uses: actions/download-artifact@v7
95+
with:
96+
path: release-assets
97+
merge-multiple: true
98+
- uses: softprops/action-gh-release@v3
99+
with:
100+
body_path: release-assets/CHANGES.md
101+
files: |
102+
release-assets/*.zip

0 commit comments

Comments
 (0)