更新 GitHub Actions 工作流,统一使用 ubuntu-24.04 作为运行环境;新增发布 WebUI 产物的工作流

This commit is contained in:
DrSmoothl
2026-02-15 16:19:13 +08:00
parent 5799ce7efe
commit 0dccc23e76
7 changed files with 147 additions and 15 deletions

View File

@@ -4,7 +4,7 @@ on: [pull_request]
jobs:
conflict-check:
runs-on: [self-hosted, Windows, X64]
runs-on: ubuntu-24.04
outputs:
conflict: ${{ steps.check-conflicts.outputs.conflict }}
steps:
@@ -25,7 +25,7 @@ jobs:
}
shell: pwsh
labeler:
runs-on: [self-hosted, Windows, X64]
runs-on: ubuntu-24.04
needs: conflict-check
if: needs.conflict-check.outputs.conflict == 'true'
steps:

View File

@@ -0,0 +1,86 @@
name: Publish WebUI Dist
on:
push:
branches:
- main
paths:
- "dashboard/**"
workflow_dispatch:
permissions:
contents: read
jobs:
build-and-publish:
runs-on: ubuntu-24.04
environment: webui
steps:
- uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Build dashboard
working-directory: dashboard
run: |
npm install
npm run build
- name: Prepare dist package
run: |
rm -rf .webui_dist_pkg
mkdir -p .webui_dist_pkg/maibot_dashboard/dist
WEBUI_VERSION=$(python -c "import json; print(json.load(open('dashboard/package.json'))['version'])")
cat > .webui_dist_pkg/pyproject.toml <<'EOF'
[project]
name = "maibot-dashboard"
version = "${WEBUI_VERSION}"
description = "MaiBot WebUI static assets"
readme = "README.md"
requires-python = ">=3.10"
[build-system]
requires = ["setuptools>=80.9.0", "wheel"]
build-backend = "setuptools.build_meta"
[tool.setuptools]
packages = ["maibot_dashboard"]
include-package-data = true
[tool.setuptools.package-data]
maibot_dashboard = ["dist/**"]
EOF
cat > .webui_dist_pkg/README.md <<'EOF'
# MaiBot WebUI Dist
该包仅包含 MaiBot WebUI 的前端构建产物dist
EOF
cat > .webui_dist_pkg/maibot_dashboard/__init__.py <<'EOF'
from .resources import get_dist_path
__all__ = ["get_dist_path"]
EOF
cat > .webui_dist_pkg/maibot_dashboard/resources.py <<'EOF'
from pathlib import Path
def get_dist_path() -> Path:
return Path(__file__).parent / "dist"
EOF
cp -a dashboard/dist/. .webui_dist_pkg/maibot_dashboard/dist/
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Build and publish
working-directory: .webui_dist_pkg
env:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m pip install --upgrade build twine
python -m build
python -m twine upload -u __token__ -p "$PYPI_API_TOKEN" dist/*

View File

@@ -2,7 +2,7 @@ name: Ruff PR Check
on: [ pull_request ]
jobs:
ruff:
runs-on: [self-hosted, Windows, X64]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
with:

View File

@@ -8,17 +8,12 @@ on:
# - dev-refactor # 例如:匹配所有以 feature/ 开头的分支
# # 添加你希望触发此 workflow 的其他分支
workflow_dispatch: # 允许手动触发工作流
branches:
- main
- dev
- dev-refactor
permissions:
contents: write
jobs:
ruff:
runs-on: [self-hosted, Windows, X64]
runs-on: ubuntu-24.04
# 关键修改:添加条件判断
# 确保只有在 event_name 是 'push' 且不是由 Pull Request 引起的 push 时才运行
if: github.event_name == 'push' && !startsWith(github.ref, 'refs/pull/')