添加 GitHub Actions 自动构建 Windows/macOS 安装包
每次推送 main 分支或手动触发时,分别在 windows-latest 和 macos-latest 上打包 Python 可执行文件 并生成 Electron 安装包,产物上传为 Artifact 保留 30 天。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6b2c87dc18
commit
2c649b8c7c
91
.github/workflows/build.yml
vendored
Normal file
91
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
name: 构建安装包
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 安装 Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: 安装 Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
|
||||||
|
- name: 安装 Node 依赖
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: 安装 Python 依赖并打包
|
||||||
|
run: |
|
||||||
|
cd python
|
||||||
|
python -m venv .venv
|
||||||
|
.venv\Scripts\pip install -r requirements.txt pyinstaller
|
||||||
|
.venv\Scripts\pyinstaller --onefile --name main --distpath dist --workpath build --specpath . --hidden-import xl_parser --hidden-import generator --collect-all openpyxl --collect-all et_xmlfile --collect-all PIL main.py
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
|
- name: 构建 Renderer
|
||||||
|
run: cd renderer && npx vite build --config vite.config.mjs
|
||||||
|
|
||||||
|
- name: 打包 Electron(Windows)
|
||||||
|
run: npx electron-builder --win
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: 上传 Windows 安装包
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-installer
|
||||||
|
path: dist/*.exe
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
|
build-mac:
|
||||||
|
runs-on: macos-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: 安装 Node.js
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 20
|
||||||
|
cache: npm
|
||||||
|
|
||||||
|
- name: 安装 Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
|
||||||
|
- name: 安装 Node 依赖
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: 安装 Python 依赖并打包
|
||||||
|
run: |
|
||||||
|
cd python
|
||||||
|
python3 -m venv .venv
|
||||||
|
.venv/bin/pip install -r requirements.txt pyinstaller
|
||||||
|
.venv/bin/pyinstaller --onefile --name main --distpath dist --workpath build --specpath . --hidden-import xl_parser --hidden-import generator --collect-all openpyxl --collect-all et_xmlfile --collect-all PIL main.py
|
||||||
|
|
||||||
|
- name: 构建 Renderer
|
||||||
|
run: cd renderer && npx vite build --config vite.config.mjs
|
||||||
|
|
||||||
|
- name: 打包 Electron(macOS)
|
||||||
|
run: npx electron-builder --mac
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
CSC_IDENTITY_AUTO_DISCOVERY: false
|
||||||
|
|
||||||
|
- name: 上传 macOS 安装包
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: mac-installer
|
||||||
|
path: dist/*.dmg
|
||||||
|
retention-days: 30
|
||||||
Loading…
x
Reference in New Issue
Block a user