Repository navigation
182 lines (168 loc) · 7.16 KB
/
Copy pathrelease.yml
File metadata and controls
182 lines (168 loc) · 7.16 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Release
# push v* tag → 构建 sdist/wheel + 三端二进制 → 自动创建 GitHub Release 并附产物。
# 由 auto-tag.yml 自动打 tag 触发(GITHUB_TOKEN 推 tag 不触发 push,
# 由 dispatch 事件叫醒),也可手动 git tag v0.x.y && git push --tags。
on:
push:
tags: ["v*"] # 手动 push tag 也能发版
repository_dispatch: # auto-tag.yml 打 tag 后显式叫醒
types: [release]
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.tag || github.ref }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install build
- name: 校验 tag 与 _version.py 版本一致
run: |
TAG="${{ github.event.client_payload.tag || github.ref_name }}"
VERSION=$(sed -n 's/^__version__ *= *"\([^"]*\)".*/\1/p' wbspy/_version.py | head -1)
[ -n "$VERSION" ] || { echo "无法从 wbspy/_version.py 读取版本号"; exit 1; }
[ "v$VERSION" = "$TAG" ] || {
echo "tag $TAG 与 _version.py 版本 v$VERSION 不一致"; exit 1; }
- run: python -m build
- uses: actions/upload-artifact@v4
with:
name: dist-pypi
path: dist/
# -- 三端二进制:Windows exe / Linux AppImage / macOS(arm64 + x86_64)----
build-bin:
strategy:
fail-fast: false
matrix:
include:
- os: windows-latest
name: bin-windows
- os: ubuntu-22.04 # glibc 2.35,兼容 22.04+ 的 x86_64 发行版
name: bin-linux
- os: macos-15 # Apple Silicon(macos-14 已于 2026-11-02 退役)
name: bin-macos-arm64
# macos-13(Intel)已移除:免费层 Intel runner 排队 24h 超时,
# 连带整个 Release 被取消。Intel Mac 用户走 pip 安装。
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.tag || github.ref }}
- uses: actions/setup-python@v5
with:
python-version: "3.11"
- run: pip install . pyinstaller pillow
- name: PyInstaller 单文件打包
run: >
pyinstaller --onefile --name wbspy --clean --noconfirm
--collect-all wbspy wbspy/launcher.py
- name: 冒烟(跑不起来不算构建成功)
if: matrix.os == 'windows-latest'
run: |
.\dist\wbspy.exe --version
.\dist\wbspy.exe accounts list
- name: 冒烟
if: matrix.os != 'windows-latest'
run: |
./dist/wbspy --version
./dist/wbspy accounts list
# -- Linux:组装 AppDir → AppImage ------------------------------------
- name: 组装 AppImage
if: matrix.os == 'ubuntu-22.04'
run: |
mkdir -p AppDir/usr/bin
cp dist/wbspy AppDir/usr/bin/wbspy
python - <<'EOF'
from PIL import Image, ImageDraw
img = Image.new("RGB", (256, 256), "#0078d4")
d = ImageDraw.Draw(img)
d.rectangle([32, 32, 224, 224], outline="white", width=12)
d.rectangle([76, 104, 180, 192], fill="white")
img.save("wbspy.png")
EOF
cp wbspy.png AppDir/wbspy.png # 图标必须在 AppDir 顶层,.DirIcon 由工具生成
cat > AppDir/wbspy.desktop <<'EOF'
[Desktop Entry]
Type=Application
Name=WorkBuddy Switch
Comment=多账号 · 扫码登录 · 积分自动化 · 本机 API 网关
Exec=wbspy
Icon=wbspy
Categories=Development;
Terminal=true
EOF
cat > AppDir/AppRun <<'EOF'
#!/bin/sh
HERE=$(dirname "$(readlink -f "$0")")
exec "$HERE/usr/bin/wbspy" "$@"
EOF
chmod +x AppDir/AppRun
ln -sf wbspy.png AppDir/.DirIcon
mkdir -p AppDir/usr/share/icons/hicolor/256x256/apps
cp wbspy.png AppDir/usr/share/icons/hicolor/256x256/apps/wbspy.png
wget -q https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool-x86_64.AppImage
./appimagetool-x86_64.AppImage --appimage-extract-and-run \
AppDir dist/wbspy-linux-x86_64.AppImage
- name: AppImage 冒烟(CI 无 FUSE,用 extract-and-run)
if: matrix.os == 'ubuntu-22.04'
run: ./dist/wbspy-linux-x86_64.AppImage --appimage-extract-and-run --version
# -- macOS:产物改名带架构 --------------------------------------------
- name: 重命名 macOS 产物
if: runner.os == 'macOS'
run: >
mv dist/wbspy dist/wbspy-macos-${{ runner.arch == 'ARM64' && 'arm64' || 'x86_64' }}
&& file dist/wbspy-macos-${{ runner.arch == 'ARM64' && 'arm64' || 'x86_64' }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.name }}
path: |
dist/wbspy.exe
dist/wbspy-linux-x86_64.AppImage
dist/wbspy-macos-*
release:
needs: [build, build-bin]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # 生成「本版变更」需要提交历史
- uses: actions/download-artifact@v4
with:
pattern: dist-pypi
path: dist/
merge-multiple: true
- uses: actions/download-artifact@v4
with:
pattern: bin-*
path: dist/
merge-multiple: true
- run: ls -lh dist/
- name: 生成发布说明(安装指引 + 自动变更日志)
run: |
TAG="${{ github.event.client_payload.tag || github.ref_name }}"
cat > body.md <<EOF
## 安装
| 平台 | 下载 | 使用方式 |
|---|---|---|
| Windows | \`wbspy.exe\` | 下载后直接命令行运行:\`wbspy.exe web\`(无需安装 Python) |
| Linux | \`wbspy-linux-x86_64.AppImage\` | \`chmod +x wbspy-linux-x86_64.AppImage && ./wbspy-linux-x86_64.AppImage web\`(需 glibc 2.35+) |
| macOS (Apple Silicon) | \`wbspy-macos-arm64\` | \`chmod +x wbspy-macos-arm64 && ./wbspy-macos-arm64 web\` |
| macOS (Intel) | 无预编译包 | \`pip install . && wbspy web\`(需 Python 3.9+) |
| pip(全平台) | \`wbspy-${TAG#v}-py3-none-any.whl\` 或源码 | \`pip install . && wbspy web\` |
| Docker | 见 README | \`docker compose up -d\` |
启动 \`web\` 后浏览器打开提示的地址:扫码登录 → 自动化托管 → OpenAI 兼容网关。
检查更新:\`wbspy update\`(国内网络自动走 DoH / 优选 IP)。
## 本版变更
$(git log $(git describe --tags --abbrev=0 HEAD^ 2>/dev/null)..HEAD --oneline 2>/dev/null || true)
---
EOF
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.client_payload.tag || github.ref_name }}
body_path: body.md
generate_release_notes: true # 自动 notes 追加在 body 之后
files: dist/*