本文档说明如何使用自动化工具打包和发布应用程序。
项目使用 GitHub Actions 自动构建 Windows、macOS 和 Linux 三个平台的安装包。
- 项目已推送到 GitHub
- 本地已安装 git
- 有推送权限
编辑项目根目录下的 VERSION 文件:
echo "1.0.1" > VERSIONgit add .
git commit -m "Release v1.0.1"./scripts/release.sh脚本会自动执行以下操作:
- ✅ 检查是否有未提交的修改
- ✅ 同步更新
src/utils/constants.py中的APP_VERSION - ✅ 自动提交版本号更新
- ✅ 检查是否有未推送的提交
- ✅ 推送所有提交到远端
- ✅ 根据 VERSION 文件创建标签(如
v1.0.1) - ✅ 检查并处理已存在的标签(本地和远端)
- ✅ 推送标签触发 GitHub Actions
推送标签后,GitHub Actions 会自动开始构建:
-
访问 GitHub Actions 页面查看进度:
https://github.com/jiulingyun/ecommerce-image-ai-processor/actions -
构建完成后,自动创建 Release:
https://github.com/jiulingyun/ecommerce-image-ai-processor/releases -
构建内容包括:
ecommerce-image-processor-windows-v1.0.1.zip- Windows 版本ecommerce-image-processor-macos-v1.0.1.zip- macOS 版本ecommerce-image-processor-linux-v1.0.1.tar.gz- Linux 版本
如果需要在本地测试打包(不发布),可以手动运行 PyInstaller:
pip install pyinstallerpyinstaller app.spec打包后的文件在 dist/ 目录下。
macOS:
open "dist/电商图片AI处理工具.app"Windows:
dist\电商图片AI处理工具\电商图片AI处理工具.exeLinux:
./dist/电商图片AI处理工具/电商图片AI处理工具发布新版本前,请确保:
- 更新了
VERSION文件 - 更新了
CHANGELOG.md(如有) - 所有测试通过
- 文档已更新
- 所有修改已提交
- 在
.github/workflows/build.yml的 Release body 中更新了更新日志
编辑 app.spec 文件:
app_name = '你的应用名称'-
准备图标文件:
- Windows:
.ico格式 - macOS:
.icns格式 - Linux:
.png格式
- Windows:
-
修改
app.spec:icon='path/to/icon.ico' # Windows/Linux
-
macOS 的 BUNDLE 配置中设置:
app = BUNDLE( ... icon='path/to/icon.icns', )
编辑 app.spec 的 excludes 列表,添加不需要打包的模块:
excludes = [
'matplotlib',
'numpy',
'pandas',
# 添加更多...
]A:
- 检查 GitHub Actions 日志查看具体错误
- 确保
requirements.txt包含所有依赖 - 检查代码在目标平台上的兼容性
A:
- 在 GitHub Release 页面手动删除
- 删除对应的 git 标签:
git tag -d v1.0.1 git push origin --delete v1.0.1
A: 编辑 .github/workflows/build.yml,注释掉对应的 job。