From b531e9052b89030159f0e53e81a98d6bf694d1c2 Mon Sep 17 00:00:00 2001 From: huangzhenpc Date: Wed, 12 Feb 2025 09:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=93=E5=8C=85=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E6=96=87=E4=BB=B6=E5=92=8C=E7=89=88=E6=9C=AC=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E7=B3=BB=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.bat | 12 ++++++++++++ build_nezha.spec | 46 ++++++++++++++++++++++++++++++++++++++++++++++ update_version.py | 27 +++++++++++++++++++++++++++ version.txt | 9 +-------- 4 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 build.bat create mode 100644 build_nezha.spec create mode 100644 update_version.py diff --git a/build.bat b/build.bat new file mode 100644 index 0000000..c8f3325 --- /dev/null +++ b/build.bat @@ -0,0 +1,12 @@ +@echo off +chcp 65001 +echo 开始打包流程... + +:: 更新版本号 +python update_version.py + +:: 使用新的spec文件进行打包 +pyinstaller --noconfirm build_nezha.spec + +echo 打包完成! +pause \ No newline at end of file diff --git a/build_nezha.spec b/build_nezha.spec new file mode 100644 index 0000000..9d8c045 --- /dev/null +++ b/build_nezha.spec @@ -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'], +) \ No newline at end of file diff --git a/update_version.py b/update_version.py new file mode 100644 index 0000000..008eebc --- /dev/null +++ b/update_version.py @@ -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() \ No newline at end of file diff --git a/version.txt b/version.txt index c373657..13d683c 100644 --- a/version.txt +++ b/version.txt @@ -1,8 +1 @@ -当前版本: 2.0.6 - -打包规则说明: -1. 每次打包时小版本号增加1 -2. 版本号格式: 主版本.次版本.小版本 -3. 示例: 2.0.5 -> 2.0.6 -> 2.0.7 - -下次打包版本: 2.0.7 \ No newline at end of file +3.0.1 \ No newline at end of file