chore: 优化可执行程序构建流程

This commit is contained in:
JoeanAmier
2024-08-24 21:56:01 +08:00
parent 15e412e6ae
commit bc81d9700c
3 changed files with 88 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
name: Build Executables
name: Manually build executable programs
on:
workflow_dispatch:
@@ -9,8 +9,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, windows-latest,macos-latest-large ]
python-version: [ 3.12 ]
os: [ macos-latest, windows-latest, macos-13 ]
steps:
- name: 签出存储库
@@ -19,7 +18,7 @@ jobs:
- name: 设置 Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
python-version: "3.12"
- name: 安装依赖项
run: |
@@ -41,5 +40,5 @@ jobs:
- name: 上传文件
uses: actions/upload-artifact@v4
with:
name: executable-${{ matrix.os }}
name: XHS-Downloader_${{ runner.os }}_${{ runner.arch }}
path: dist/main/

View File

@@ -0,0 +1,58 @@
name: Release build executable program
on:
release:
types: [ created ]
permissions:
contents: write
discussions: write
jobs:
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ macos-latest, windows-latest, macos-13 ]
steps:
- name: 签出存储库
uses: actions/checkout@v3
- name: 设置 Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: 安装依赖项
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: 构建 Win 可执行文件
if: runner.os == 'Windows'
run: |
pyinstaller --icon=./static/XHS-Downloader.ico --add-data "static:static" --add-data "locale:locale" main.py
shell: pwsh
- name: 构建 Mac 可执行文件
if: runner.os == 'macOS'
run: |
pyinstaller --icon=./static/XHS-Downloader.icns --add-data "static:static" --add-data "locale:locale" main.py
- name: 创建压缩包
run: |
7z a "XHS-Downloader_V${{ github.event.release.tag_name }}_${{ runner.os }}_${{ runner.arch }}.zip" ./dist/main/*
shell: bash
- name: 上传文件到 release
uses: softprops/action-gh-release@v2
with:
files: |
./XHS-Downloader_V*.zip
name: XHS-Downloader V${{ github.event.release.tag_name }}
body_path: ./static/Release_Notes.md
draft: ${{ github.event.release.draft }}
prerelease: ${{ github.event.release.prerelease }}