-
Notifications
You must be signed in to change notification settings - Fork 2
165 lines (142 loc) · 4.8 KB
/
Copy pathci.yml
File metadata and controls
165 lines (142 loc) · 4.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
# 同一分支的新推送取消还在跑的旧流水线(tag 推送各占一个 group,互不影响)
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
# ---------- ① 测试 + 前端构建 + 部署包(每次推送/PR 都跑) ----------
test-and-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13" # 对齐线上生产版本
- name: 后端单元测试
run: |
pip install -r app/requirements.txt
python -m unittest discover -s app/tests -t . -v
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
cache-dependency-path: frontend/package-lock.json
- name: 前端构建(含 vue-tsc 全量类型检查)
working-directory: frontend
run: |
npm ci
npm run build
- name: 确认前端产物就位
run: test -f app/static/index.html
# 成员路径必须是 app/...(对齐 DEPLOY.md 坑①),排除运行时数据
- name: 打部署包
run: >
tar czf gpu-fan-console-app.tgz
--exclude='__pycache__' --exclude='*.pyc' --exclude='app/data'
-C . app
- uses: actions/upload-artifact@v4
with:
name: gpu-fan-console-app
path: gpu-fan-console-app.tgz
# ---------- ② 控制台双平台可执行(PR 不跑,省 Windows 时长) ----------
build-console:
if: github.event_name != 'pull_request'
needs: test-and-build
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: utf-8 # Windows runner 控制台 cp1252,防中文输出炸编码
steps:
- uses: actions/checkout@v4
# 前端产物在 ubuntu 上构建,这里从部署包里解开复用(静态资源与平台无关)
- uses: actions/download-artifact@v4
with:
name: gpu-fan-console-app
- run: tar xzf gpu-fan-console-app.tgz
- uses: actions/setup-python@v5
with:
python-version: "3.13"
# build_console.py 构建完直接产出 dist/gpu-fan-console-windows-x64.zip
# 或 dist/gpu-fan-console-linux-x64.tar.gz(zipfile/tarfile 实现,跨平台一致)
- name: 构建控制台可执行
run: |
pip install -r app/requirements.txt pyinstaller
python packaging/build_console.py
- uses: actions/upload-artifact@v4
with:
name: gpu-fan-console-${{ matrix.os }}
path: dist/gpu-fan-console-*
# ---------- ③ 旧版脚本单文件可执行(PR 不跑) ----------
build-legacy:
if: github.event_name != 'pull_request'
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
- os: windows-latest
runs-on: ${{ matrix.os }}
env:
PYTHONIOENCODING: utf-8
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.13"
- name: 构建旧脚本单文件可执行
run: |
pip install pyinstaller
python packaging/build_legacy.py
- name: 按平台重命名产物
shell: bash
run: |
cd dist
for f in fancontroller fancontroller_once; do
if [ "$RUNNER_OS" = "Windows" ]; then
mv "$f.exe" "$f-windows-x64.exe"
else
mv "$f" "$f-linux-x64"
fi
done
- uses: actions/upload-artifact@v4
with:
name: legacy-${{ matrix.os }}
path: dist/fancontroller*
# ---------- ④ 打 tag(v*)自动发 Release ----------
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: [test-and-build, build-console, build-legacy]
runs-on: ubuntu-latest
permissions:
contents: write # 发 Release 需要
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: 创建 Release 并上传全部产物
env:
GH_TOKEN: ${{ github.token }}
run: |
ls -l artifacts
# 本 job 没有 checkout(无 .git),必须显式 --repo,否则 gh 推断不出仓库
gh release create "$GITHUB_REF_NAME" artifacts/* \
--repo "$GITHUB_REPOSITORY" \
--title "gpu-fan-console $GITHUB_REF_NAME" \
--generate-notes \
|| gh release upload "$GITHUB_REF_NAME" artifacts/* \
--repo "$GITHUB_REPOSITORY" --clobber