Skip to content

Commit ef84c9e

Browse files
committed
初始提交
0 parents  commit ef84c9e

33 files changed

Lines changed: 7680 additions & 0 deletions

.github/workflows/release.yml

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*'
9+
10+
jobs:
11+
create-tag:
12+
runs-on: ubuntu-latest
13+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
14+
permissions:
15+
contents: write
16+
outputs:
17+
tag_name: ${{ steps.set_tag.outputs.tag_name || '' }}
18+
steps:
19+
- name: 检出代码
20+
uses: actions/checkout@v6
21+
22+
- name: 设置 Python
23+
uses: actions/setup-python@v6
24+
with:
25+
python-version: '3.14'
26+
27+
- name: 检查版本号是否变化
28+
id: check_version
29+
run: |
30+
CURRENT_VERSION=$(python -c 'import version; print(version.BATCH_VERSION)')
31+
TAG_NAME="v$CURRENT_VERSION"
32+
echo "当前版本: $TAG_NAME"
33+
if git ls-remote --tags origin "$TAG_NAME" | grep -q "$TAG_NAME"; then
34+
echo "版本号未变化,跳过构建"
35+
echo "skip=true" >> $GITHUB_OUTPUT
36+
else
37+
echo "版本号已更新,继续构建"
38+
echo "skip=false" >> $GITHUB_OUTPUT
39+
fi
40+
41+
- name: 读取 Batch 版本号
42+
if: steps.check_version.outputs.skip == 'false'
43+
id: get_version
44+
run: |
45+
BATCH_VERSION=$(python -c 'import version; print(version.BATCH_VERSION)')
46+
echo "BATCH_VERSION=$BATCH_VERSION" >> $GITHUB_ENV
47+
echo "读取到 Batch 版本: $BATCH_VERSION"
48+
49+
- name: 创建并推送 Tag
50+
if: steps.check_version.outputs.skip == 'false'
51+
id: set_tag
52+
run: |
53+
git config user.name "github-actions[bot]"
54+
git config user.email "github-actions[bot]@users.noreply.github.com"
55+
56+
TAG_NAME="v${{ env.BATCH_VERSION }}"
57+
echo "tag_name=$TAG_NAME" >> $GITHUB_OUTPUT
58+
59+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
60+
git tag -d "$TAG_NAME"
61+
fi
62+
git tag -a "$TAG_NAME" -F release_notes.txt
63+
git push origin "$TAG_NAME"
64+
echo "✅ 已创建并推送 Tag: $TAG_NAME"
65+
shell: bash
66+
67+
build:
68+
runs-on: windows-latest
69+
needs: create-tag
70+
if: |
71+
always() &&
72+
needs.create-tag.result == 'success' &&
73+
needs.create-tag.outputs.tag_name != ''
74+
permissions:
75+
contents: write
76+
steps:
77+
- name: 检出代码
78+
uses: actions/checkout@v6
79+
80+
- name: 设置 Python
81+
uses: actions/setup-python@v6
82+
with:
83+
python-version: '3.14'
84+
85+
- name: 安装依赖
86+
run: |
87+
python -m pip install --upgrade pip
88+
pip install -r requirements.txt
89+
echo "===== 验证关键库 ====="
90+
python -c "import PyInstaller; print('PyInstaller OK')"
91+
python -c "import PySide6; print('PySide6 OK')"
92+
93+
- name: 提取版本号(从 version.py)
94+
id: get_versions
95+
run: |
96+
$pdfver = python -c "import version; print(f'v{version.PDF_VERSION}')"
97+
$imgver = python -c "import version; print(f'v{version.IMG_VERSION}')"
98+
$batchver = python -c "import version; print(f'v{version.BATCH_VERSION}')"
99+
$videover = python -c "import version; print(f'v{version.VIDEO_VERSION}')"
100+
echo "PDF_VERSION=$pdfver" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
101+
echo "IMG_VERSION=$imgver" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
102+
echo "BATCH_VERSION=$batchver" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
103+
echo "VIDEO_VERSION=$videover" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
104+
shell: pwsh
105+
106+
- name: 打包 PDFTool
107+
run: |
108+
pyinstaller --onedir --windowed --name=PDF批量处理工具 --icon=assets/logo_pdf.ico --add-data "assets;assets" --exclude-module=tkinter --exclude-module=unittest --exclude-module=test app_pdf.py
109+
110+
- name: 打包 IMGTool
111+
run: |
112+
pyinstaller --onedir --windowed --name=IMG批量处理工具 --icon=assets/logo_img.ico --add-data "assets;assets" --exclude-module=tkinter --exclude-module=unittest --exclude-module=test app_img.py
113+
114+
- name: 打包 BatchTool
115+
run: |
116+
pyinstaller --onedir --windowed --name=文件批量处理工具 --icon=assets/logo.ico --add-data "assets;assets" --exclude-module=tkinter --exclude-module=unittest --exclude-module=test app.py
117+
118+
- name: 打包 VideoTool
119+
run: |
120+
pyinstaller --onedir --windowed --name=视频批量处理工具 --icon=assets/logo_video.ico --add-data "assets;assets" --exclude-module=tkinter --exclude-module=unittest --exclude-module=test app_video.py
121+
122+
- name: 清理旧 zip
123+
run: |
124+
if (Test-Path *.zip) { Remove-Item *.zip -Force }
125+
126+
- name: 生成 ZIP 压缩包(英文名 + 版本号)
127+
run: |
128+
python -c "import zipfile, os; zf = zipfile.ZipFile(f'PDFTool_${{ env.PDF_VERSION }}.zip', 'w', zipfile.ZIP_DEFLATED, compresslevel=9); root = 'dist/PDF批量处理工具'; [zf.write(os.path.join(dirpath, f), os.path.relpath(os.path.join(dirpath, f), root)) for dirpath, _, filenames in os.walk(root) for f in filenames]; zf.close()"
129+
python -c "import zipfile, os; zf = zipfile.ZipFile(f'IMGTool_${{ env.IMG_VERSION }}.zip', 'w', zipfile.ZIP_DEFLATED, compresslevel=9); root = 'dist/IMG批量处理工具'; [zf.write(os.path.join(dirpath, f), os.path.relpath(os.path.join(dirpath, f), root)) for dirpath, _, filenames in os.walk(root) for f in filenames]; zf.close()"
130+
python -c "import zipfile, os; zf = zipfile.ZipFile(f'BatchTool_${{ env.BATCH_VERSION }}.zip', 'w', zipfile.ZIP_DEFLATED, compresslevel=9); root = 'dist/文件批量处理工具'; [zf.write(os.path.join(dirpath, f), os.path.relpath(os.path.join(dirpath, f), root)) for dirpath, _, filenames in os.walk(root) for f in filenames]; zf.close()"
131+
python -c "import zipfile, os; zf = zipfile.ZipFile(f'VideoTool_${{ env.VIDEO_VERSION }}.zip', 'w', zipfile.ZIP_DEFLATED, compresslevel=9); root = 'dist/视频批量处理工具'; [zf.write(os.path.join(dirpath, f), os.path.relpath(os.path.join(dirpath, f), root)) for dirpath, _, filenames in os.walk(root) for f in filenames]; zf.close()"
132+
shell: pwsh
133+
134+
- name: 创建 Release 并上传
135+
uses: softprops/action-gh-release@v3
136+
with:
137+
files: |
138+
*.zip
139+
tag_name: ${{ needs.create-tag.outputs.tag_name }}
140+
name: ${{ needs.create-tag.outputs.tag_name }}
141+
body_path: release_notes.txt
142+
draft: false
143+
prerelease: false

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Python
2+
__pycache__/
3+
*.pyc
4+
*.pyo
5+
*.pyd
6+
.Python
7+
*.so
8+
*.dylib
9+
10+
# Virtual Environment
11+
venv/
12+
.venv/
13+
env/
14+
ENV/
15+
16+
# PyInstaller
17+
dist/
18+
build/
19+
*.spec
20+
21+
# IDE
22+
.vscode/
23+
.idea/
24+
*.swp
25+
*.swo
26+
27+
# Project specific
28+
gs_config.json
29+
*.zip
30+
*.log
31+
.DS_Store
32+
33+
build.bat
34+
开发记录.md

0 commit comments

Comments
 (0)