Files
2025-08-29 01:05:56 +08:00

70 lines
1.8 KiB
YAML

name: Build and Release
# 触发工作流的事件
on:
push:
tags:
- 'v*'
jobs:
build-and-release:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ windows-latest ]
permissions:
contents: write
steps:
# 检出代码
- name: Checkout code
uses: actions/checkout@v4
# 设置 Python 环境
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
# 安装依赖和 PyInstaller
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install pyinstaller
shell: bash
# 运行 PyInstaller 打包
- name: Build with PyInstaller
run: |
pyinstaller -y --clean -D -c -n wxdown-service --add-data=resources/credential.py:resources --hiddenimport bs4 main.py
shell: bash
# 调试:列出 dist/ 目录内容
- name: List dist directory
run: |
ls -al
shell: bash
# 压缩 dist/wxdown-service/ 为 wxdown-service.zip
- name: Zip the bundle
if: runner.os == 'Windows'
run: |
Compress-Archive -Path dist/wxdown-service/* -DestinationPath wxdown-service-windows.zip
shell: pwsh
- name: Zip the bundle
if: runner.os == 'macOS'
run: |
cd dist
zip -r wxdown-service-macos.zip wxdown-service
mv wxdown-service-macos.zip ..
shell: bash
# 上传打包结果
- name: Upload release assets
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
with:
files: ${{ runner.os == 'Windows' && 'wxdown-service-windows.zip' || 'wxdown-service-macos.zip' }}