Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions .github/cliff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[remote.github]
owner = "MAA-AI"
repo = "MaaMCP"

[changelog]
# 标题
header = """
# 更新日志
"""

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 | split(pat="\n") | first | upper_first }} \
{% if commit.remote.username %} @{{ commit.remote.username }}{% else %} {{ commit.author.name }}{% endif %}\
{%- if commit.footers -%}
{%- for footer in commit.footers -%}
{%- if footer.token == "Co-authored-by" -%}
{%- set co_author_name = footer.value | split(pat=" <") | first | trim %} @{{ co_author_name }}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{% endmacro -%}

{% if version %}
## {{ version | trim_start_matches(pat="v") }} ({{ timestamp | date(format="%Y-%m-%d") }})
{% else %}
## 未发布
{% 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 %}
## 新贡献者 ❤️
{% 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 %}
"""

# 尾部
footer = """
{%- set latest_version = "" -%}
{%- for release in releases -%}
{%- if release.version and latest_version == "" -%}
{%- set_global latest_version = release.version -%}
{%- endif -%}
{%- endfor %}
{% if latest_version %}
# 安装

```sh
pip install maa-mcp=={{ latest_version }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · 安装命令使用了无效版本

当发布标签使用 v 前缀(符合工作流预期的正式发布标签格式)时,生成的页脚和后备内容都会保留此前缀,因此 pip 会查找 v1.3.0 这样的软件包版本,而不是实际发布的 1.3.0;按照任一安装命令操作的发布读者都无法安装该版本。

请在两个安装命令中,从根据标签生成的版本号中去掉开头的 v。

另见 .github/workflows/publish.yml:63。

给 AI 代理的提示
在 `.github/cliff.toml` 第 74 行:

**安装命令使用了无效版本**

当发布标签使用 `v` 前缀(符合工作流预期的正式发布标签格式)时,生成的页脚和后备内容都会保留此前缀,因此 pip 会查找 `v1.3.0` 这样的软件包版本,而不是实际发布的 `1.3.0`;按照任一安装命令操作的发布读者都无法安装该版本。

请在两个安装命令中,从根据标签生成的版本号中去掉开头的 `v`。

另见 `.github/workflows/publish.yml:63`。
Original comment in English

🟠 High · Install command uses invalid version

When a release tag uses the v prefix, as the workflow’s formal-release tag pattern expects, the generated footer and fallback retain the v prefix, so pip looks for a package version such as v1.3.0 instead of the published 1.3.0; release readers following either installation command cannot install that version.

Strip the leading v from the tag-derived version in both installation commands.

Also at .github/workflows/publish.yml:63.

Prompt for AI agents
In `.github/cliff.toml` at line 74:

**Install command uses invalid version**

When a release tag uses the `v` prefix, as the workflow’s formal-release tag pattern expects, the generated footer and fallback retain the `v` prefix, so pip looks for a package version such as `v1.3.0` instead of the published `1.3.0`; release readers following either installation command cannot install that version.

Strip the leading `v` from the tag-derived version in both installation commands.

Also at `.github/workflows/publish.yml:63`.

```

# 使用

```sh
maa-mcp
```
{%- endif %}
"""

[git]
# 过滤提交
conventional_commits = true # 使用约定式提交格式
filter_unconventional = false # 不过滤非约定式提交
# 启用完整的 commit 信息
split_commits = false
# 保留完整的 commit body
protect_breaking_commits = false
commit_parsers = [
# 跳过包含 [skip changelog] 的 commit
{ message = ".*\\[skip changelog\\].*", skip = true },
{ body = ".*\\[skip changelog\\].*", skip = true },
{ message = "^feat", group = "<!-- 0 -->✨ 新功能" },
{ message = "^fix", group = "<!-- 1 -->🐛 Bug修复" },
{ message = "^docs", group = "<!-- 4 -->📚 文档" },
{ message = "^perf", group = "<!-- 3 -->🚀 性能优化" },
{ message = "^refactor", group = "<!-- 2 -->🚜 代码重构" },
{ message = "^style", group = "<!-- 5 -->🎨 样式" },
{ message = "^test", group = "<!-- 6 -->🧪 测试" },
{ message = "^chore", group = "<!-- 8 -->🔧 日常维护" },
{ message = "^ci", group = "<!-- 7 -->⚙️ 持续集成" },
{ message = "^remove", group = "<!-- 11 -->🗑️ 移除" },
{ body = ".*security", group = "<!-- 9 -->🔒 安全" },
{ message = "^[Rr]evert", group = "<!-- 10 -->◀️ 撤销" },
]

# 排序规则
sort_commits = "oldest"

# 启用GitHub集成
[git.github]
commits = true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · API 限流会导致变更日志丢失

当运行器发出的 GitHub API 请求超过未认证请求的速率限制时,GitHub 集成需要通过 API 获取提交元数据,但该作业只传递了 GITHUB_REPO,没有传递令牌。一旦未认证 API 请求受到限流,git-cliff 就会失败,而 continue-on-error 会导致发布仅使用静态后备内容,从而丢失变更摘要。

请将 ${{ secrets.GITHUB_TOKEN }} 作为 GITHUB_TOKEN 传递给 git-cliff 步骤。

另见 .github/workflows/publish.yml:52。

给 AI 代理的提示
在 `.github/cliff.toml` 第 116 行:

**API 限流会导致变更日志丢失**

当运行器发出的 GitHub API 请求超过未认证请求的速率限制时,GitHub 集成需要通过 API 获取提交元数据,但该作业只传递了 `GITHUB_REPO`,没有传递令牌。一旦未认证 API 请求受到限流,git-cliff 就会失败,而 `continue-on-error` 会导致发布仅使用静态后备内容,从而丢失变更摘要。

请将 `${{ secrets.GITHUB_TOKEN }}` 作为 `GITHUB_TOKEN` 传递给 git-cliff 步骤。

另见 `.github/workflows/publish.yml:52`。
Original comment in English

🟡 Medium · API throttling drops the changelog

When gitHub API requests from the runner exceed the unauthenticated rate limit, the GitHub integration needs API access for commit metadata, but the job passes only GITHUB_REPO and no token. Once unauthenticated API requests are rate-limited, git-cliff fails and continue-on-error makes the release use only the static fallback, losing the change summary.

Pass ${{ secrets.GITHUB_TOKEN }} to the git-cliff step as GITHUB_TOKEN.

Also at .github/workflows/publish.yml:52.

Prompt for AI agents
In `.github/cliff.toml` at line 116:

**API throttling drops the changelog**

When gitHub API requests from the runner exceed the unauthenticated rate limit, the GitHub integration needs API access for commit metadata, but the job passes only `GITHUB_REPO` and no token. Once unauthenticated API requests are rate-limited, git-cliff fails and `continue-on-error` makes the release use only the static fallback, losing the change summary.

Pass `${{ secrets.GITHUB_TOKEN }}` to the git-cliff step as `GITHUB_TOKEN`.

Also at `.github/workflows/publish.yml:52`.

75 changes: 63 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,70 @@ on:
required: false

jobs:
changelog:
name: Generate changelog
runs-on: ubuntu-latest
permissions:
contents: read # checkout 仓库
pull-requests: read # git-cliff 拉取 PR 元数据(贡献者统计)
outputs:
release_body: ${{ steps.git-cliff.outputs.content || steps.fallback.outputs.body }}
steps:
- name: Checkout
uses: actions/checkout@v4

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · 可变 Action 会暴露 checkout 令牌

当上游 Action 标签遭到入侵或被重新指向恶意代码时,orhun/git-cliff-action@v4 会在 checkout 后运行;而 checkout 默认会将其凭据持久化到仓库的 Git 配置中。遭入侵或被重新指向的 Action 代码可以读取并窃取作业令牌,随后利用它所拥有的仓库权限。

请将 Action 固定到经过审核的完整提交 SHA,设置作业所需的最低令牌权限;如果 Action 不需要 Git 凭据,请禁用 checkout 凭据持久化。

另见 .github/workflows/publish.yml:38。

给 AI 代理的提示
在 `.github/workflows/publish.yml` 第 21 行:

**可变 Action 会暴露 checkout 令牌**

当上游 Action 标签遭到入侵或被重新指向恶意代码时,`orhun/git-cliff-action@v4` 会在 checkout 后运行;而 checkout 默认会将其凭据持久化到仓库的 Git 配置中。遭入侵或被重新指向的 Action 代码可以读取并窃取作业令牌,随后利用它所拥有的仓库权限。

请将 Action 固定到经过审核的完整提交 SHA,设置作业所需的最低令牌权限;如果 Action 不需要 Git 凭据,请禁用 checkout 凭据持久化。

另见 `.github/workflows/publish.yml:38`。
Original comment in English

🟡 Medium · Mutable action exposes checkout token

When the upstream action tag is compromised or retargeted to malicious code, orhun/git-cliff-action@v4 runs after checkout, which persists its credential in the repository’s Git config by default; compromised or retargeted action code can read and exfiltrate the job token, then use whatever repository permissions it has.

Pin the action to a reviewed full commit SHA, set the job’s minimum required token permissions, and disable checkout credential persistence if the action does not need Git credentials.

Also at .github/workflows/publish.yml:38.

Prompt for AI agents
In `.github/workflows/publish.yml` at line 21:

**Mutable action exposes checkout token**

When the upstream action tag is compromised or retargeted to malicious code, `orhun/git-cliff-action@v4` runs after checkout, which persists its credential in the repository’s Git config by default; compromised or retargeted action code can read and exfiltrate the job token, then use whatever repository permissions it has.

Pin the action to a reviewed full commit SHA, set the job’s minimum required token permissions, and disable checkout credential persistence if the action does not need Git credentials.

Also at `.github/workflows/publish.yml:38`.

with:
fetch-depth: 0 # git-cliff 需要完整历史与 tag 才能算出版本区间
ref: ${{ inputs.tag || github.ref }} # 检出版本对应的 tag,--current 才有归属

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · 发布制品使用了不同的代码

当手动触发运行时提供的标签与工作流引用不同时,变更日志作业会检出指定标签,而 build 作业会检出工作流引用,因此发布说明描述的代码与以该标签发布的软件包和制品不一致。

请让 build 作业检出与变更日志作业相同的指定标签。

给 AI 代理的提示
在 `.github/workflows/publish.yml` 第 24 行:

**发布制品使用了不同的代码**

当手动触发运行时提供的标签与工作流引用不同时,变更日志作业会检出指定标签,而 `build` 作业会检出工作流引用,因此发布说明描述的代码与以该标签发布的软件包和制品不一致。

请让 `build` 作业检出与变更日志作业相同的指定标签。
Original comment in English

🟠 High · Release artifacts use different code

When a manual dispatch supplies a tag that differs from the workflow ref, the changelog job checks out the requested tag, but the build job checks out the workflow ref, so the release notes describe different code from the package and artifacts published under that tag.

Make the build job check out the same requested tag used by the changelog job.

Prompt for AI agents
In `.github/workflows/publish.yml` at line 24:

**Release artifacts use different code**

When a manual dispatch supplies a tag that differs from the workflow ref, the changelog job checks out the requested tag, but the `build` job checks out the workflow ref, so the release notes describe different code from the package and artifacts published under that tag.

Make the `build` job check out the same requested tag used by the changelog job.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · 新的手动标签会阻止发布

当 workflow_dispatch 运行提供尚未推送的新标签名称时,actions/checkout 会在 git-cliff 的后备逻辑运行之前失败,而 build 会因 needs: changelog 被阻止;因此,手动请求的发布既不会构建,也不会发布。

对于手动运行,如果指定标签不存在,请检出 dispatch 引用;或者确保在启动工作流前标签已存在。

给 AI 代理的提示
在 `.github/workflows/publish.yml` 第 24 行:

**新的手动标签会阻止发布**

当 `workflow_dispatch` 运行提供尚未推送的新标签名称时,`actions/checkout` 会在 git-cliff 的后备逻辑运行之前失败,而 `build` 会因 `needs: changelog` 被阻止;因此,手动请求的发布既不会构建,也不会发布。

对于手动运行,如果指定标签不存在,请检出 dispatch 引用;或者确保在启动工作流前标签已存在。
Original comment in English

🟡 Medium · New manual tags block publishing

When a workflow_dispatch run supplies a new tag name that has not been pushed yet, actions/checkout fails before the git-cliff fallback runs, and build is blocked by needs: changelog; the manually requested release therefore never builds or publishes.

For manual runs, check out the dispatch ref when the requested tag does not exist, or ensure the tag exists before starting the workflow.

Prompt for AI agents
In `.github/workflows/publish.yml` at line 24:

**New manual tags block publishing**

When a workflow_dispatch run supplies a new tag name that has not been pushed yet, `actions/checkout` fails before the git-cliff fallback runs, and `build` is blocked by `needs: changelog`; the manually requested release therefore never builds or publishes.

For manual runs, check out the dispatch ref when the requested tag does not exist, or ensure the tag exists before starting the workflow.


- name: Determine release tag
id: meta
run: |
tag="${{ inputs.tag || github.ref_name }}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟠 High · 标签输入会执行 Shell 命令

当提供或推送的标签包含 Shell 语法时,bash 会在赋值给 tag 之前,将插入的标签解析为脚本源码;后备命令也会再次进行相同的插值,因此 Shell 命令会在变更日志运行器上执行,并可访问其凭据或环境变量。

请通过环境变量传递标签,并在这两条命令中将其作为数据使用。

另见 .github/workflows/publish.yml:61-63。

给 AI 代理的提示
在 `.github/workflows/publish.yml` 第 29 行:

**标签输入会执行 Shell 命令**

当提供或推送的标签包含 Shell 语法时,bash 会在赋值给 `tag` 之前,将插入的标签解析为脚本源码;后备命令也会再次进行相同的插值,因此 Shell 命令会在变更日志运行器上执行,并可访问其凭据或环境变量。

请通过环境变量传递标签,并在这两条命令中将其作为数据使用。

另见 `.github/workflows/publish.yml:61-63`。
Original comment in English

🟠 High · Tag input executes shell commands

When a supplied or pushed tag contains shell syntax, bash parses the interpolated tag as script source before assigning tag, and the fallback command repeats that interpolation, so shell commands run on the changelog runner and can access its credentials or environment.

Pass the tag through an environment variable and use it as data in both commands.

Also at .github/workflows/publish.yml:61-63.

Prompt for AI agents
In `.github/workflows/publish.yml` at line 29:

**Tag input executes shell commands**

When a supplied or pushed tag contains shell syntax, bash parses the interpolated tag as script source before assigning `tag`, and the fallback command repeats that interpolation, so shell commands run on the changelog runner and can access its credentials or environment.

Pass the tag through an environment variable and use it as data in both commands.

Also at `.github/workflows/publish.yml:61-63`.

if [[ "$tag" =~ ^v[0-9]+[.][0-9]+[.][0-9]+$ ]]; then
echo "is_prerelease=false" >> "$GITHUB_OUTPUT"
else
echo "is_prerelease=true" >> "$GITHUB_OUTPUT"
fi

- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
continue-on-error: true # 生成失败时退回静态说明,不阻塞发版
with:
config: .github/cliff.toml
# --current 只处理「属于当前 tag 的提交」,即本次要发布的这一版;
# --strip header 去掉「更新日志」大标题
# 正式版加 tag-pattern 把基线锁定在「上一个正式版」,这样 beta 期间的
# 提交也会并入本次发布说明;预发布版则用上一个任意 tag 作为基线
args: >-
-vv --current --strip header
${{ steps.meta.outputs.is_prerelease == 'false' && '--tag-pattern "^v[0-9]+[.][0-9]+[.][0-9]+$"' || '' }}
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}

- name: Fallback release body
id: fallback
run: |
{
echo 'body<<CHANGES_EOF'
echo '# Installation'
echo ''
echo '```sh'
echo "pip install maa-mcp==${{ inputs.tag || github.ref_name }}"
echo '```'
echo ''
echo '# Usage'
echo ''
echo '```sh'
echo 'maa-mcp'
echo '```'
echo 'CHANGES_EOF'
} >> "$GITHUB_OUTPUT"

build:
name: Build distribution
needs: changelog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -41,18 +103,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ inputs.tag || github.ref_name }}
body: "# Installation

```sh
pip install maa-mcp==${{ inputs.tag || github.ref_name }}
```

# Usage

```sh
maa-mcp
```
"
body: ${{ needs.changelog.outputs.release_body }}

publish-to-pypi:
name: Publish to PyPI
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ dependencies = [
]

[project.urls]
Homepage = "https://github.com/MistEO/MaaMCP"
Documentation = "https://github.com/MistEO/MaaMCP#readme"
Repository = "https://github.com/MistEO/MaaMCP"
Issues = "https://github.com/MistEO/MaaMCP/issues"
Homepage = "https://github.com/MAA-AI/MaaMCP"
Documentation = "https://github.com/MAA-AI/MaaMCP#readme"
Repository = "https://github.com/MAA-AI/MaaMCP"
Issues = "https://github.com/MAA-AI/MaaMCP/issues"

[project.scripts]
maa-mcp = "maa_mcp.__main__:main"
Expand Down
Loading