添加打包配置文件和版本管理系统
This commit is contained in:
12
build.bat
Normal file
12
build.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
chcp 65001
|
||||
echo 开始打包流程...
|
||||
|
||||
:: 更新版本号
|
||||
python update_version.py
|
||||
|
||||
:: 使用新的spec文件进行打包
|
||||
pyinstaller --noconfirm build_nezha.spec
|
||||
|
||||
echo 打包完成!
|
||||
pause
|
||||
46
build_nezha.spec
Normal file
46
build_nezha.spec
Normal file
@@ -0,0 +1,46 @@
|
||||
# -*- mode: python ; coding: utf-8 -*-
|
||||
import os
|
||||
|
||||
def get_version():
|
||||
with open('version.txt', 'r', encoding='utf-8') as f:
|
||||
version = f.read().strip()
|
||||
return version
|
||||
|
||||
version = get_version()
|
||||
|
||||
a = Analysis(
|
||||
['main.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[('icon', 'icon'), ('version.txt', '.')],
|
||||
hiddenimports=[],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
noarchive=False,
|
||||
optimize=0,
|
||||
)
|
||||
pyz = PYZ(a.pure)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.datas,
|
||||
[],
|
||||
name=f'听泉cursor助手{version}',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
argv_emulation=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon=['icon\\two.ico'],
|
||||
)
|
||||
27
update_version.py
Normal file
27
update_version.py
Normal file
@@ -0,0 +1,27 @@
|
||||
def increment_version(version_str):
|
||||
major, minor, patch = map(int, version_str.split('.'))
|
||||
patch += 1
|
||||
if patch >= 10:
|
||||
patch = 0
|
||||
minor += 1
|
||||
if minor >= 10:
|
||||
minor = 0
|
||||
major += 1
|
||||
return f"{major}.{minor}.{patch}"
|
||||
|
||||
def update_version():
|
||||
# 读取当前版本
|
||||
with open('version.txt', 'r', encoding='utf-8') as f:
|
||||
current_version = f.read().strip()
|
||||
|
||||
# 计算新版本
|
||||
new_version = increment_version(current_version)
|
||||
|
||||
# 写入新版本
|
||||
with open('version.txt', 'w', encoding='utf-8') as f:
|
||||
f.write(new_version)
|
||||
|
||||
print(f"版本号已从 {current_version} 更新到 {new_version}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
update_version()
|
||||
@@ -1,8 +1 @@
|
||||
当前版本: 2.0.6
|
||||
|
||||
打包规则说明:
|
||||
1. 每次打包时小版本号增加1
|
||||
2. 版本号格式: 主版本.次版本.小版本
|
||||
3. 示例: 2.0.5 -> 2.0.6 -> 2.0.7
|
||||
|
||||
下次打包版本: 2.0.7
|
||||
3.0.1
|
||||
Reference in New Issue
Block a user