Create main.yml

This commit is contained in:
YoVinchen 2025-06-30 11:08:24 +08:00 committed by GitHub
parent e66a6cec84
commit 84f11a0906
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

89
.github/workflows/main.yml vendored Normal file
View File

@ -0,0 +1,89 @@
# GitHub Actions工作流 - 多平台构建
# 将此文件放在 .github/workflows/ 目录下
name: Build Multi-Platform Executables
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
build-windows:
runs-on: windows-latest
strategy:
matrix:
arch: [x64, x86]
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
architecture: ${{ matrix.arch }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas openpyxl pyinstaller
- name: Build executable
run: |
pyinstaller --onefile --console --name "座位分配系统_${{ matrix.arch }}" seat_allocation_system.py
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: windows-${{ matrix.arch }}
path: dist/座位分配系统_${{ matrix.arch }}.exe
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pandas openpyxl pyinstaller
- name: Build executable
run: |
pyinstaller --onefile --console --name "座位分配系统_macos" seat_allocation_system.py
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: macos
path: dist/座位分配系统_macos
create-release:
needs: [build-windows, build-macos]
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ github.run_number }}
name: Release v${{ github.run_number }}
files: |
windows-x64/座位分配系统_x64.exe
windows-x86/座位分配系统_x86.exe
macos/座位分配系统_macos
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}