v9.3.8 #56
Workflow file for this run
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 NFO Tools | |
on: | |
push: | |
tags: | |
- 'v*.*.*' # 仅在创建符合格式 v*.*.* 的标签时触发 | |
workflow_dispatch: # 允许手动触发构建 | |
jobs: | |
build: | |
runs-on: windows-latest # 只在 Windows 上构建 | |
steps: | |
- name: 检出代码 | |
uses: actions/checkout@v4 | |
- name: 设置 Python 版本 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12.2' | |
- name: 缓存 pip 依赖 | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/pip | |
key: windows-pip-${{ hashFiles('**/requirements.txt') }} | |
restore-keys: | | |
windows-pip- | |
- name: 安装依赖 | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: 设置构建名称 | |
id: set_build_name | |
run: | | |
if ($env:GITHUB_EVENT_NAME -eq "push" -and $env:GITHUB_REF -match '^refs/tags/v.*') { | |
$BUILD_NAME = $env:GITHUB_REF.Substring(10) # 去掉 "refs/tags/" | |
} else { | |
# 获取最新的标签 | |
git fetch --tags | |
$latestTag = git describe --tags $(git rev-list --tags --max-count=1) | |
if ($null -eq $latestTag) { | |
Write-Error "未找到任何标签,无法继续。" | |
exit 1 | |
} | |
$BUILD_NAME = $latestTag | |
} | |
echo "BUILD_NAME=$BUILD_NAME" >> $env:GITHUB_ENV | |
- name: 构建所有程序 | |
run: | | |
# 首先构建 cg_crop | |
pyinstaller --name "cg_crop" --onefile --noconsole --icon="chuizi.ico" --add-data "chuizi.ico;." --add-data "Img;Img" "cg_crop.py" | |
# 确保临时目录存在 | |
New-Item -ItemType Directory -Force -Path "temp" | |
# 将 cg_crop.exe 复制到临时目录,供 NFO.Editor 使用 | |
Copy-Item -Path "dist/cg_crop.exe" -Destination "temp/cg_crop.exe" | |
# 构建 NFO.Editor | |
pyinstaller --name "NFO.Editor" --onefile --noconsole --icon="chuizi.ico" --add-data "chuizi.ico;." --add-data "mapping_actor.xml;." --add-data "Img;Img" --exclude-module matplotlib --exclude-module numpy --exclude-module pandas --clean --hidden-import xml.etree.ElementTree --hidden-import xml.dom.minidom "NFO.Editor.py" | |
# 构建 NFO.Editor.Qt5 | |
pyinstaller --name "NFO.Editor.Qt5" --onefile --noconsole --icon="chuizi.ico" --add-data "chuizi.ico;." --add-data "mapping_actor.xml;." --add-data "Img;Img" --exclude-module matplotlib --exclude-module numpy --exclude-module pandas --clean --hidden-import xml.etree.ElementTree --hidden-import xml.dom.minidom "NFO.Editor.Qt5.py" | |
# 构建 cg_rename | |
pyinstaller --name "cg_rename" --onefile --noconsole --icon="chuizi.ico" --add-data "chuizi.ico;." --add-data "mapping_actor.xml;." "cg_rename.py" | |
# 构建 cg_dedupe | |
pyinstaller --name "cg_dedupe" --onefile --noconsole --icon="chuizi.ico" --add-data "chuizi.ico;." "cg_dedupe.py" | |
# 重命名生成的文件 | |
Move-Item -Path "dist/NFO.Editor.exe" -Destination "dist/NFO.Editor.${{ env.BUILD_NAME }}.exe" -Force | |
Move-Item -Path "dist/NFO.Editor.Qt5.exe" -Destination "dist/NFO.Editor.Qt5.${{ env.BUILD_NAME }}.exe" -Force | |
Move-Item -Path "dist/cg_crop.exe" -Destination "dist/cg_crop.${{ env.BUILD_NAME }}.exe" -Force | |
Move-Item -Path "dist/cg_rename.exe" -Destination "dist/cg_rename.${{ env.BUILD_NAME }}.exe" -Force | |
Move-Item -Path "dist/cg_dedupe.exe" -Destination "dist/cg_dedupe.${{ env.BUILD_NAME }}.exe" -Force | |
# 清理临时文件 | |
Remove-Item -Path "temp" -Recurse -Force | |
- name: 创建 Release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ env.BUILD_NAME }} | |
release_name: Release ${{ env.BUILD_NAME }} | |
draft: false | |
prerelease: false | |
files: | | |
dist/NFO.Editor.${{ env.BUILD_NAME }}.exe | |
dist/NFO.Editor.Qt5.${{ env.BUILD_NAME }}.exe | |
dist/cg_crop.${{ env.BUILD_NAME }}.exe | |
dist/cg_rename.${{ env.BUILD_NAME }}.exe | |
dist/cg_dedupe.${{ env.BUILD_NAME }}.exe | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |