Skip to content

Commit afd58a4

Browse files
feat: update github action and build tools
1 parent fdfffca commit afd58a4

File tree

11 files changed

+282
-157
lines changed

11 files changed

+282
-157
lines changed

.github/workflows/bump_version.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/ci-tests.yaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: ✅ Code Quality & Tests
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
pull_request:
8+
workflow_dispatch:
9+
permissions:
10+
contents: read
11+
env:
12+
UV_INDEX_HOMELAB_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
13+
UV_INDEX_HOMELAB_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
14+
PYPI_SERVER_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
15+
PYPI_SERVER_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
16+
jobs:
17+
check:
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v4
22+
- name: Install Task
23+
uses: arduino/setup-task@v2
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@v5
26+
- name: Install dependencies
27+
run: task init
28+
- name: Run lint checks
29+
id: lint
30+
run: task lint
31+
- name: Run test all versions
32+
run: task test:all
33+
34+
docker-build-test:
35+
name: 🐳 Multi-platform Docker Build Test
36+
needs: check
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Check out the repo
40+
uses: actions/checkout@v4
41+
- name: Check if Dockerfile exists
42+
id: dockerfile-check
43+
run: |
44+
if [ -f "./docker/Dockerfile" ]; then
45+
echo "dockerfile-exists=true" >> $GITHUB_OUTPUT
46+
else
47+
echo "dockerfile-exists=false" >> $GITHUB_OUTPUT
48+
echo "Dockerfile not found, skipping Docker build test"
49+
fi
50+
- name: Set up QEMU
51+
if: steps.dockerfile-check.outputs.dockerfile-exists == 'true'
52+
uses: docker/setup-qemu-action@v3
53+
- name: Test Build Image (no push)
54+
if: steps.dockerfile-check.outputs.dockerfile-exists == 'true'
55+
id: build-image
56+
uses: redhat-actions/buildah-build@v2
57+
with:
58+
image: ${{ github.repository }}-test
59+
tags: test-${{ github.sha }}
60+
containerfiles: ./docker/Dockerfile
61+
platforms: linux/amd64,linux/arm64
62+
build-args: |-
63+
PYPI_SERVER_USERNAME=${{ env.PYPI_SERVER_USERNAME }}
64+
PYPI_SERVER_PASSWORD=${{ env.PYPI_SERVER_PASSWORD }}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
name: Deploy Docs
1+
name: 📚 Deploy Documentation
22
on:
33
push:
44
tags:
5-
- '[0-9]+.[0-9]+.[0-9]+' # 匹配类似 1.0.0, 2.1.3 等格式的标签
5+
- '[0-9]+.[0-9]+.[0-9]+' # 匹配类似 1.0.0, 2.1.3 等格式的标签
66
workflow_dispatch:
77
permissions:
8-
contents: write # 用于部署到 GitHub Pages
8+
contents: write # 用于部署到 GitHub Pages
99
jobs:
1010
deploy:
1111
runs-on: ubuntu-latest
@@ -17,6 +17,8 @@ jobs:
1717
- name: Install uv
1818
uses: astral-sh/setup-uv@v5
1919
- name: Build and deploy documentation
20-
run: task deploy:gh-pages
2120
env:
2221
GITHUB_TOKEN: ${{ github.token }}
22+
UV_INDEX_HOMELAB_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
23+
UV_INDEX_HOMELAB_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
24+
run: task deploy:gh-pages

.github/workflows/lint_and_unittest.yaml

Lines changed: 0 additions & 27 deletions
This file was deleted.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: 🚀 Release Build & Publish
2+
on:
3+
push:
4+
tags:
5+
- '[0-9]+.[0-9]+.[0-9]+' # 匹配类似 1.0.0, 2.1.3 等格式的标签
6+
permissions:
7+
contents: write # 用于创建 release
8+
id-token: write # 用于发布到 PyPI
9+
10+
jobs:
11+
test:
12+
runs-on: ubuntu-latest
13+
env:
14+
UV_INDEX_HOMELAB_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
15+
UV_INDEX_HOMELAB_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
16+
PYPI_SERVER_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
17+
PYPI_SERVER_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Install Task
21+
uses: arduino/setup-task@v2
22+
- name: Install uv
23+
uses: astral-sh/setup-uv@v5
24+
- name: init environment and test
25+
run: |
26+
task init # 初始化项目环境
27+
task lint # 运行代码检查
28+
- name: Run tests
29+
run: task test:all # 运行所有测试
30+
31+
publish-pypi:
32+
needs: test
33+
runs-on: ubuntu-latest
34+
permissions:
35+
contents: write
36+
id-token: write
37+
steps:
38+
- uses: actions/checkout@v4
39+
- name: Install Task
40+
uses: arduino/setup-task@v2
41+
- name: Install uv
42+
uses: astral-sh/setup-uv@v5
43+
- name: Build package
44+
run: task build
45+
- name: Publish to PyPI
46+
env:
47+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_TOKEN }}
48+
run: task publish:pypi
49+
50+
publish-private-pypi:
51+
needs: test
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: write
55+
env:
56+
UV_INDEX_HOMELAB_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
57+
UV_INDEX_HOMELAB_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
58+
PYPI_SERVER_USERNAME: ${{ secrets.PYPI_SERVER_USERNAME }}
59+
PYPI_SERVER_PASSWORD: ${{ secrets.PYPI_SERVER_PASSWORD }}
60+
steps:
61+
- uses: actions/checkout@v4
62+
- name: Install Task
63+
uses: arduino/setup-task@v2
64+
- name: Install uv
65+
uses: astral-sh/setup-uv@v5
66+
- name: Build and publish to PyPI Server
67+
run: task deploy:pypi-server
68+
69+
release:
70+
needs: [test, publish-pypi, publish-private-pypi]
71+
runs-on: ubuntu-latest
72+
permissions:
73+
contents: write
74+
steps:
75+
- uses: actions/checkout@v4
76+
- name: Install Task
77+
uses: arduino/setup-task@v2
78+
- name: Install uv
79+
uses: astral-sh/setup-uv@v5
80+
- name: Build package for release
81+
run: task build
82+
- name: Release
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: ${{ github.ref_name }}
86+
name: Release ${{ github.ref_name }}
87+
files: |
88+
dist/*.tar.gz
89+
dist/*.whl
90+
generate_release_notes: true
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}

.github/workflows/release_build.yaml

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/workflows/version-bump.yaml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: 🔄 Auto Version Bump
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- main
7+
workflow_dispatch:
8+
inputs:
9+
increment:
10+
description: 'Version increment type'
11+
required: false
12+
default: 'MAJOR'
13+
type: choice
14+
options:
15+
- 'MAJOR'
16+
- 'MINOR'
17+
- 'PATCH'
18+
permissions:
19+
contents: write # 用于创建和推送标签
20+
pull-requests: write # 用于创建 PR
21+
jobs:
22+
bump-version:
23+
if: ${{ github.event_name == 'workflow_dispatch' || !startsWith(github.event.head_commit.message, 'bump:') }}
24+
runs-on: ubuntu-latest
25+
name: Bump version and create changelog with commitizen
26+
steps:
27+
- name: Check out
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
32+
- name: Create bump and changelog
33+
uses: commitizen-tools/commitizen-action@master
34+
with:
35+
github_token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
36+
branch: master
37+
increment: ${{ github.event.inputs.increment || '' }}
38+
no_raise: '21'

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ repos:
22
- repo: https://github.com/astral-sh/uv-pre-commit
33
rev: 0.7.8
44
hooks:
5-
- id: uv-lock # Update the uv lockfile
5+
- id: uv-lock # Update the uv lockfile
66
- repo: https://github.com/google/yamlfmt
7-
rev: v0.14.0
7+
rev: v0.17.2
88
hooks:
99
- id: yamlfmt
1010
- repo: https://github.com/python-jsonschema/check-jsonschema
@@ -15,4 +15,4 @@ repos:
1515
- repo: https://github.com/rhysd/actionlint
1616
rev: v1.7.7
1717
hooks:
18-
- id: actionlint # lint github actions
18+
- id: actionlint # lint github actions

.yamlfmt.yaml

Lines changed: 15 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,25 @@
1+
doublestar: true
12
yaml_files:
23
- "**/*.yaml"
34
- "**/*.yml"
45
- ".yamlfmt"
5-
- "!**/vendor/**"
6-
- "!**/node_modules/**"
7-
regex_exclude:
8-
- ".*\\Taskfile\\.yml$"
9-
- ".*\\mkdocs\\.yml$"
10-
yaml_options:
11-
# 文档末尾是否需要一个空行
12-
end_of_document: true
13-
# 配置文档分隔符
14-
15-
document_start: false
6+
exclude:
7+
- "**/vendor/**"
8+
- "**/node_modules/**"
9+
- "repo_scaffold/templates/**"
10+
formatter:
11+
type: basic
12+
# 控制换行符保留 - 设为 false 可能减少不必要的空行
13+
retain_line_breaks: false
14+
# 只保留单个换行符,移除多余的空行
15+
retain_line_breaks_single: true
16+
# 注释前的空格数
17+
pad_line_comments: 2
18+
# 去除行尾空白字符
19+
trim_trailing_whitespace: true
1620
# 行长度限制
17-
1821
line_length: 100
1922
# 缩进大小
20-
2123
indentation: 2
2224
# 是否保留引号
23-
2425
preserve_quotes: true
25-
# 对齐方式
26-
27-
alignment:
28-
# 是否启用键值对齐
29-
enable: true
30-
# 键和冒号之间的最小间隔
31-
32-
key_value: 1
33-
# 对齐后冒号和值之间的空格数
34-
35-
colon_value: 1
36-
# 数组格式化
37-
38-
array:
39-
# 嵌套数组是否应该与父级对齐
40-
indent_nested: true
41-
# 数组项与前导符号 - 之间的空格数
42-
43-
item_spacing: 1
44-
# 是否移除文档注释
45-
46-
strip_comments: false
47-
# 是否保留文件开头的注释
48-
49-
preserve_header: true

0 commit comments

Comments
 (0)