Skip to content

Add files via upload #141

Add files via upload

Add files via upload #141

Workflow file for this run

name: 将 Python 打包为 EXE
on:
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
env:
PYTHON_VERSION: '3.9'
OUTPUT_DIR: 'output'
ARTIFACT_NAME: 'Bloret-Launcher-Windows.zip'
steps:
- name: 检出代码
uses: actions/checkout@v2
- name: 设置 Python
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: 安装依赖
run: |
pip install --upgrade pip
pip install -r requirements.txt
pip install loguru==0.6.0
pip install PyQt-Fluent-Widgets==1.0.0 -i https://pypi.org/simple/
pip install pyinstaller==4.5.1
pip install pillow==8.4.0
- name: 将 PNG 图标转换为 ICO
run: |
python -c "
from PIL import Image
img = Image.open('icons/bloret.png')
img.save('icons/bloret.ico', format='ICO')
"
- name: 使用 PyInstaller 打包
run: pyinstaller --onefile --noconsole --icon=icons/bloret.ico --name=Bloret-Launcher main.py
- name: 创建包含其他文件夹的目录
run: |
mkdir -p ${{ env.OUTPUT_DIR }}
cp dist/Bloret-Launcher.exe ${{ env.OUTPUT_DIR }}/
cp -r cmcl/ ${{ env.OUTPUT_DIR }}/
cp -r icons/ ${{ env.OUTPUT_DIR }}/
cp -r log/ ${{ env.OUTPUT_DIR }}/
cp -r ui/ ${{ env.OUTPUT_DIR }}/
- name: 清理旧压缩包
run: |
if [ -f "${{ env.OUTPUT_DIR }}/${{ env.ARTIFACT_NAME }}" ]; then
rm "${{ env.OUTPUT_DIR }}/${{ env.ARTIFACT_NAME }}"
fi
- name: 创建压缩包
run: Compress-Archive -Path "${{ env.OUTPUT_DIR }}/*" -DestinationPath "${{ env.OUTPUT_DIR }}/${{ env.ARTIFACT_NAME }}"
shell: pwsh
- name: 上传构建产物
uses: actions/upload-artifact@v3
with:
name: Bloret-Launcher
path: "${{ env.OUTPUT_DIR }}/${{ env.ARTIFACT_NAME }}"