Skip to content

Commit ed8997d

Browse files
authored
ci: replace the new release CI and add the release drafter CI (#18)
* 🐎 ci: change new release and add release drafter ci * 📃 docs: update readme for publish * 📃 docs: 更新 release 触发说明 * 📃 docs: 更新 Readme * 📃 docs: update readme * 📃 docs: update readme * 🐳 chore: update pre-commit ruff hook to v0.12.9 * 📃 docs: update readme
1 parent b8a5157 commit ed8997d

File tree

11 files changed

+405
-77
lines changed

11 files changed

+405
-77
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Bug 反馈
2+
title: "Bug: 出现异常"
3+
description: 提交 Bug 反馈以帮助我们改进代码
4+
labels: ["bug"]
5+
body:
6+
- type: textarea
7+
id: describe
8+
attributes:
9+
label: 描述问题
10+
description: 清晰简洁地说明问题是什么
11+
validations:
12+
required: true
13+
14+
- type: textarea
15+
id: reproduction
16+
attributes:
17+
label: 复现步骤
18+
description: 提供能复现此问题的详细操作步骤
19+
placeholder: |
20+
1. 首先……
21+
2. 然后……
22+
3. 发生……
23+
validations:
24+
required: true
25+
26+
- type: textarea
27+
id: expected
28+
attributes:
29+
label: 期望的结果
30+
description: 清晰简洁地描述你期望发生的事情
31+
32+
- type: textarea
33+
id: logs
34+
attributes:
35+
label: 截图或日志
36+
description: 提供有助于诊断问题的任何日志和截图

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
blank_issues_enabled: false
2+
contact_links:
3+
- name: 讨论区
4+
url: https://github.com/${REPO_OWNER}/${REPO_NAME}/discussions
5+
about: 使用中若遇到问题,请先在这里求助。
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: 功能建议
2+
title: "Feature: 功能描述"
3+
description: 提出关于项目新功能的想法
4+
labels: ["enhancement"]
5+
body:
6+
- type: textarea
7+
id: problem
8+
attributes:
9+
label: 希望能解决的问题
10+
description: 在使用中遇到什么问题而需要新的功能?
11+
validations:
12+
required: true
13+
14+
- type: textarea
15+
id: feature
16+
attributes:
17+
label: 描述所需要的功能
18+
description: 请说明需要的功能或解决方法
19+
validations:
20+
required: true

.github/release-drafter.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
template: $CHANGES
2+
name-template: "v$RESOLVED_VERSION"
3+
tag-template: "v$RESOLVED_VERSION"
4+
exclude-labels:
5+
- "dependencies"
6+
- "skip-changelog"
7+
autolabeler:
8+
- label: "bug"
9+
branch:
10+
- '/fix\/.+/'
11+
- label: "change"
12+
branch:
13+
- '/change\/.+/'
14+
- label: "enhancement"
15+
branch:
16+
- '/feature\/.+/'
17+
- '/feat\/.+/'
18+
- '/improve\/.+/'
19+
- label: "ci"
20+
files:
21+
- .github/**/*
22+
- label: "breaking-change"
23+
title:
24+
- "/.+!:.+/"
25+
categories:
26+
- title: 💥 Breaking Changes
27+
labels:
28+
- breaking-change
29+
- title: 🚀 Features
30+
labels:
31+
- enhancement
32+
- title: 🐛 Bug Fixes
33+
labels:
34+
- bug
35+
- title: 💫 Others
36+
change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
37+
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
38+
version-resolver:
39+
major:
40+
labels:
41+
- "major"
42+
minor:
43+
labels:
44+
- "minor"
45+
patch:
46+
labels:
47+
- "patch"
48+
default: patch

.github/workflows/pypi-publish.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [opened, reopened, synchronize]
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
update_release_draft:
15+
name: Update Release Draft
16+
runs-on: ubuntu-latest
17+
permissions:
18+
# write permission is required to create a github release
19+
contents: write
20+
# write permission is required for autolabeler
21+
# otherwise, read permission is required at least
22+
pull-requests: write
23+
steps:
24+
- uses: release-drafter/release-drafter@v6
25+
env:
26+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
release:
10+
name: Release
11+
runs-on: ubuntu-latest
12+
environment: release
13+
permissions:
14+
id-token: write
15+
contents: write
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v5
19+
20+
- name: Install the latest version of uv
21+
uses: astral-sh/setup-uv@v6
22+
with:
23+
enable-cache: true
24+
python-version: "3.12"
25+
version: 'latest'
26+
27+
- name: Get Version
28+
id: version
29+
run: |
30+
echo "VERSION=$(uv version --short)" >> $GITHUB_OUTPUT
31+
echo "TAG_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
32+
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
33+
34+
- name: Check Version
35+
if: steps.version.outputs.VERSION != steps.version.outputs.TAG_VERSION
36+
run: exit 1
37+
38+
- name: Build
39+
run: uv build
40+
41+
- name: Publish a Python distribution to PyPI
42+
uses: pypa/gh-action-pypi-publish@release/v1
43+
44+
- name: Upload Release Asset
45+
run: gh release upload --clobber ${{ steps.version.outputs.TAG_NAME }} dist/*.tar.gz dist/*.whl
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
49+

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ci:
77
autoupdate_commit_msg: ":arrow_up: auto update by pre-commit hooks"
88
repos:
99
- repo: https://github.com/astral-sh/ruff-pre-commit
10-
rev: v0.12.7
10+
rev: v0.12.9
1111
hooks:
1212
- id: ruff-check
1313
args: [--fix]

README.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515

1616
> [!IMPORTANT]
17-
> **收藏项目** 方便下次创建插件仓库~⭐️
17+
> **收藏项目** 以便创建插件仓库~⭐️
1818
1919
<img width="100%" src="https://starify.komoridevs.icu/api/starify?owner=fllesser&repo=nonebot-plugin-template" alt="starify" />
2020

@@ -25,19 +25,31 @@
2525
3.`Add file` 菜单中选择 `Create new file`, 在新文件名处输入`LICENSE`, 此时在右侧会出现一个 `Choose a license template` 按钮, 点击此按钮选择开源协议模板, 然后在最下方提交新文件到主分支(这会触发一个工作流,生成新的 `README`,并修改 `pyproject.toml` 等文件中的插件名称)
2626

2727
> [!NOTE]
28-
> 模板库中自带了一个发布工作流, 你可以使用此工作流自动发布你的插件到 pypi
28+
> 模板库中自带了一个 Release 工作流, 你可以使用此工作流发布你的插件到 PyPI
2929
3030
<details>
31-
<summary>配置发布工作流</summary>
31+
<summary>配置 PyPI Trusted Publisher</summary>
32+
配置文档: https://docs.pypi.org/trusted-publishers/adding-a-publisher/
33+
</details>
34+
35+
<details>
36+
<summary>使用 bump-my-version 工具更新版本号,并触发 Release 工作流 (推荐)</summary>
37+
38+
`bump-my-version` 在 dev 依赖组中,使用 `uv sync --all-groups` 安装,或者使用 `uv tool install bump-my-version` 全局安装
39+
40+
bump-my-version bump patch
41+
42+
该操作会有以下行为:
43+
1. 更新 `pyproject.toml``project.version``tool.bumpversion.current_version`
44+
2. 更新 `uv.lock` 中的版本号
45+
3. 创建一个带 `tag` 的提交, 提交信息可以在 `pyproject.toml` 中的 `[tool.bumpversion]` 中配置
3246

33-
1. 前往 https://pypi.org/manage/account/#api-tokens 并创建一个新的 API 令牌。创建成功后不要关闭页面,不然你将无法再次查看此令牌。
34-
2. 在单独的浏览器选项卡或窗口中,打开 [Actions secrets and variables](./settings/secrets/actions) 页面。你也可以在 Settings - Secrets and variables - Actions 中找到此页面。
35-
3. 点击 New repository secret 按钮,创建一个名为 `PYPI_API_TOKEN` 的新令牌,并从第一步复制粘贴令牌。
47+
接下来你只需要推送提交,并推送 `tag` (git push origin --tags) 即可触发 Release 工作流
3648

3749
</details>
3850

3951
<details>
40-
<summary>触发发布工作流</summary>
52+
<summary>触发 Release 工作流 (手动)</summary>
4153

4254
更新版本号
4355

@@ -97,10 +109,10 @@ possible values: major, minor, patch, stable, alpha, beta, rc, post, dev
97109

98110
安装 `nonemoji`
99111

100-
pipx install nonemoji
112+
uv tool install nonemoji
101113
安装 `pre-commit`
102114

103-
pipx install pre-commit
115+
uv tool install pre-commit
104116

105117
pre-commit install
106118
添加到暂存区

pyproject.toml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ authors = [{ name = "owner", email = "[email protected]" }]
77
urls = { Repository = "https://github.com/owner/nonebot-plugin-template" }
88
requires-python = ">=3.10"
99
dependencies = [
10-
"nonebot2>=2.4.2,<3.0.0",
10+
"nonebot2>=2.4.3,<3.0.0",
1111

1212
"nonebot-plugin-localstore>=0.7.4,<1.0.0", # 存储文件
1313
"nonebot-plugin-apscheduler>=0.5.0,<1.0.0", # 定时任务
1414

1515
"nonebot-plugin-uninfo>=0.9.0,<1.0.0", # 多平台用户信息获取
16-
"nonebot-plugin-alconna>=0.59.3,<1.0.0", # 跨平台命令解析拓展
16+
"nonebot-plugin-alconna>=0.59.4,<1.0.0", # 跨平台命令解析拓展
1717
# "nonebot-adapter-onebot>=2.4.6,<3.0.0"
1818

1919
"httpx>=0.27.0,<1.0.0",
@@ -22,9 +22,10 @@ dependencies = [
2222
[dependency-groups]
2323
dev = [
2424
"nonebot2[fastapi]>=2.4.2,<3.0.0",
25-
"ruff>=0.12.7,<1.0.0",
25+
"ruff>=0.12.9,<1.0.0",
2626
"nonemoji>=0.1.4,<1.0.0",
27-
"pre-commit>=4.1.0",
27+
"pre-commit>=4.3.0",
28+
"bump-my-version>=1.2.1",
2829
]
2930

3031
test = [
@@ -76,6 +77,7 @@ select = [
7677
"TID", # flake8-tidy-imports
7778
"RUF", # Ruff-specific rules
7879
]
80+
7981
ignore = [
8082
"E402", # module-import-not-at-top-of-file
8183
"UP037", # quoted-annotation
@@ -118,3 +120,14 @@ disableBytesTypePromotions = true
118120
[build-system]
119121
requires = ["uv_build>=0.8.0,<0.9.0"]
120122
build-backend = "uv_build"
123+
124+
[tool.bumpversion]
125+
current_version = "0.1.0"
126+
commit = true
127+
message = "🔖 release: bump vesion from {current_version} to {new_version}"
128+
tag = true
129+
130+
[[tool.bumpversion.files]]
131+
filename = "uv.lock"
132+
search = "name = \"nonebot-plugin-template\"\nversion = \"{current_version}\""
133+
replace = "name = \"nonebot-plugin-template\"\nversion = \"{new_version}\""

0 commit comments

Comments
 (0)