Merge pull request #392 from CL4R3T/main #346
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build realtime release | |
# 触发条件:手动触发或推送触发 | |
on: | |
workflow_dispatch: | |
pull_request: | |
paths: | |
- "**.py" | |
push: | |
branches: | |
- main | |
paths: | |
- "**.py" | |
# 权限设置:需要写入仓库内容的权限 | |
permissions: | |
contents: write | |
jobs: | |
build: | |
name: Build | |
runs-on: windows-latest | |
steps: | |
# 步骤1:签出代码 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
submodules: "false" | |
# 步骤2:设置Python环境 | |
- name: Set up python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.12" | |
cache: "pip" | |
# 步骤3:安装依赖 | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt pyinstaller | |
# 步骤4:生成程序 | |
- name: Generate program | |
run: | | |
pyinstaller -D --distpath .\dist\ -i .\assets\logo\Terminal.ico --contents-directory libraries --exclude-module PyQt5 --uac-admin -n "March7th Assistant" main.py -y | |
pyinstaller -D --distpath .\dist\ -i .\assets\logo\March7th.ico --contents-directory libraries --uac-admin -n "March7th Launcher" app.py -y -w | |
pyinstaller -F --distpath .\dist\March7thAssistant\ -i .\assets\logo\Updater.ico -n "March7th Updater" updater.py -y | |
# 步骤5:移动资源到dist目录 | |
- name: Move assets to dist directory | |
run: | | |
Copy-Item -Path ".\dist\March7th Assistant\*" -Destination ".\dist\March7thAssistant\" -Recurse -Force | |
Copy-Item -Path ".\dist\March7th Launcher\*" -Destination ".\dist\March7thAssistant\" -Recurse -Force | |
Copy-Item -Path ".\assets\" -Destination ".\dist\March7thAssistant\assets\" -Recurse -Force | |
Copy-Item -Path ".\README.md" -Destination ".\dist\March7thAssistant\" -Force | |
# 步骤6:创建压缩包 | |
- name: Create archive | |
run: | | |
Rename-Item -Path .\dist\March7thAssistant -NewName March7thAssistant_${{ github.run_number }} | |
.\assets\binary\7za.exe a -t7z .\dist\March7thAssistant_${{ github.run_number }}.7z .\dist\March7thAssistant_${{ github.run_number }}\ | |
# 步骤7:上传压缩包 | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: March7thAssistant_${{ github.run_number }}.7z | |
path: ./dist/March7thAssistant_${{ github.run_number }}.7z | |
compression-level: 0 # no compression |