添加 GitHub Actions Windows 构建流程
Some checks are pending
Build Windows Installer / build-windows (push) Waiting to run
Some checks are pending
Build Windows Installer / build-windows (push) Waiting to run
- 新增 .github/workflows/build-windows.yml,在 windows-latest runner 上构建 NSIS 安装包 - 修复 PYTHON_BIN 在 Windows 下需要 .exe 后缀 - 更新 extraResources 为目录式 glob,同时兼容 macOS (main) 和 Windows (main.exe) - package.json 新增 win/nsis electron-builder 目标配置 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
70a56ede36
commit
cb2c186f7f
66
.github/workflows/build-windows.yml
vendored
Normal file
66
.github/workflows/build-windows.yml
vendored
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Build Windows Installer
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main, master]
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-windows:
|
||||||
|
runs-on: windows-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Disable Windows Defender real-time protection
|
||||||
|
run: Set-MpPreference -DisableRealtimeMonitoring $true
|
||||||
|
shell: powershell
|
||||||
|
|
||||||
|
- name: Set up Python 3.11
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: "3.11"
|
||||||
|
|
||||||
|
- name: Install Python dependencies
|
||||||
|
run: pip install openpyxl==3.1.2 Pillow==10.3.0 pyinstaller
|
||||||
|
|
||||||
|
- name: Build Python executable
|
||||||
|
run: >
|
||||||
|
pyinstaller
|
||||||
|
--onefile
|
||||||
|
--name main
|
||||||
|
--distpath python/dist
|
||||||
|
--workpath python/build
|
||||||
|
--specpath python
|
||||||
|
--hidden-import xl_parser
|
||||||
|
--hidden-import generator
|
||||||
|
--collect-all openpyxl
|
||||||
|
--collect-all et_xmlfile
|
||||||
|
--collect-all PIL
|
||||||
|
python/main.py
|
||||||
|
|
||||||
|
- name: Set up Node.js 18
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "18"
|
||||||
|
|
||||||
|
- name: Install Node dependencies
|
||||||
|
run: npm ci
|
||||||
|
|
||||||
|
- name: Build renderer
|
||||||
|
run: npx vite build --config vite.config.mjs
|
||||||
|
working-directory: renderer
|
||||||
|
|
||||||
|
- name: Build Windows installer
|
||||||
|
run: npx electron-builder --win --x64
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Upload installer
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: windows-installer
|
||||||
|
path: dist/*.exe
|
||||||
|
if-no-files-found: error
|
||||||
|
retention-days: 30
|
||||||
@ -8,7 +8,11 @@ const APPDATA_DIR = path.join(app.getPath("userData"), "excel-batch-editor", "te
|
|||||||
fs.mkdirSync(APPDATA_DIR, { recursive: true });
|
fs.mkdirSync(APPDATA_DIR, { recursive: true });
|
||||||
|
|
||||||
const PYTHON_BIN = app.isPackaged
|
const PYTHON_BIN = app.isPackaged
|
||||||
? path.join(process.resourcesPath, "python", "main")
|
? path.join(
|
||||||
|
process.resourcesPath,
|
||||||
|
"python",
|
||||||
|
process.platform === "win32" ? "main.exe" : "main"
|
||||||
|
)
|
||||||
: path.join(__dirname, "../../python/main.py");
|
: path.join(__dirname, "../../python/main.py");
|
||||||
|
|
||||||
function callPython(payload) {
|
function callPython(payload) {
|
||||||
|
|||||||
16
package.json
16
package.json
@ -25,8 +25,9 @@
|
|||||||
],
|
],
|
||||||
"extraResources": [
|
"extraResources": [
|
||||||
{
|
{
|
||||||
"from": "python/dist/main",
|
"from": "python/dist/",
|
||||||
"to": "python/main"
|
"to": "python",
|
||||||
|
"filter": ["main", "main.exe"]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"mac": {
|
"mac": {
|
||||||
@ -43,6 +44,17 @@
|
|||||||
{ "x": 130, "y": 150, "type": "file" },
|
{ "x": 130, "y": 150, "type": "file" },
|
||||||
{ "x": 410, "y": 150, "type": "link", "path": "/Applications" }
|
{ "x": 410, "y": 150, "type": "link", "path": "/Applications" }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"win": {
|
||||||
|
"target": [
|
||||||
|
{ "target": "nsis", "arch": ["x64"] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"nsis": {
|
||||||
|
"oneClick": false,
|
||||||
|
"allowToChangeInstallationDirectory": true,
|
||||||
|
"createDesktopShortcut": true,
|
||||||
|
"createStartMenuShortcut": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user