Skip to content

Commit 01c7a04

Browse files
committed
feat: add support for multiple build configurations and improve package handling
1 parent 4380562 commit 01c7a04

File tree

5 files changed

+81
-12
lines changed

5 files changed

+81
-12
lines changed

.github/workflows/release.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,17 @@ jobs:
2626

2727
- name: Build package
2828
run: |
29-
pdm run release
29+
pdm run release_d
30+
pdm run release_f
3031
3132
- name: Generate package name
3233
run: |
3334
echo "file-name=${{ env.PROJECT_NAME }}_${{ github.ref_name }}" >> $env:GITHUB_ENV
34-
35+
36+
- name: Move and rename exe
37+
run: |
38+
Move-Item -Path .\dist\${{ env.PROJECT_NAME }}.exe -Destination .\${{ env.file-name }}.exe
39+
3540
- name: Archive folder
3641
run: |
3742
Compress-Archive -Path .\dist\${{ env.PROJECT_NAME }} -DestinationPath .\${{ env.file-name }}.zip
@@ -45,4 +50,5 @@ jobs:
4550
tag_name: ${{ github.ref_name }}
4651
files: |
4752
${{ env.file-name }}.zip
53+
${{ env.file-name }}.exe
4854
fail_on_unmatched_files: true

build.spec renamed to build_d.spec

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- mode: python ; coding: utf-8 -*-
22

3-
4-
block_cipher = None
3+
# Create a one-folder bundle containing an executable
54

65
exe_name = "StarRailTools"
76

@@ -23,12 +22,12 @@ src_list = find_files(src_root_dir, '.py')
2322
# ui file
2423
tcss_path = os.path.join(src_root_dir, "tui")
2524
tcss_file = find_files(tcss_path, ".tcss")
26-
ui_tuple_list = [(file, tcss_path) for file in tcss_file]
25+
ui_res_list = [(file, tcss_path) for file in tcss_file]
2726

2827

2928
icon_path = "resource/hsr.ico"
3029

31-
data_list = ui_tuple_list
30+
data_list = ui_res_list
3231

3332
a = Analysis(
3433
src_list,
@@ -40,12 +39,10 @@ a = Analysis(
4039
hooksconfig={},
4140
runtime_hooks=[],
4241
excludes=[],
43-
win_no_prefer_redirects=False,
44-
win_private_assemblies=False,
45-
cipher=block_cipher,
4642
noarchive=False,
43+
optimize=0,
4744
)
48-
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
45+
pyz = PYZ(a.pure)
4946

5047
exe = EXE(
5148
pyz,
@@ -68,7 +65,6 @@ exe = EXE(
6865
coll = COLLECT(
6966
exe,
7067
a.binaries,
71-
a.zipfiles,
7268
a.datas,
7369
strip=False,
7470
upx=True,

build_f.spec

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
# Create a one-file bundled executable
4+
5+
exe_name = "StarRailTools"
6+
7+
src_root_dir = "star_rail"
8+
9+
def find_files(folder_path, ext_type:str):
10+
file_list = []
11+
for root, dirs, files in os.walk(folder_path):
12+
for file in files:
13+
if file.endswith(ext_type):
14+
file_list.append(os.path.join(root, file))
15+
return file_list
16+
17+
18+
src_list = find_files(src_root_dir, '.py')
19+
20+
21+
tcss_path = os.path.join(src_root_dir, "tui")
22+
tcss_file = find_files(tcss_path, ".tcss")
23+
ui_res_list = [(file, tcss_path) for file in tcss_file]
24+
25+
icon_path = "resource/hsr.ico"
26+
27+
data_list = ui_res_list
28+
29+
a = Analysis(
30+
src_list,
31+
pathex=[],
32+
binaries=[],
33+
datas=data_list,
34+
hiddenimports=["textual.widgets._tab_pane"],
35+
hookspath=[],
36+
hooksconfig={},
37+
runtime_hooks=[],
38+
excludes=[],
39+
noarchive=False,
40+
optimize=0,
41+
)
42+
pyz = PYZ(a.pure)
43+
44+
exe = EXE(
45+
pyz,
46+
a.scripts,
47+
a.binaries,
48+
a.datas,
49+
[],
50+
name=exe_name,
51+
debug=False,
52+
bootloader_ignore_signals=False,
53+
strip=False,
54+
upx=True,
55+
upx_exclude=[],
56+
runtime_tmpdir=None,
57+
console=True,
58+
disable_windowed_traceback=False,
59+
argv_emulation=False,
60+
target_arch=None,
61+
codesign_identity=None,
62+
entitlements_file=None,
63+
icon=icon_path,
64+
)

pyproject.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ release = ["pyinstaller>=6.12.0"]
4040

4141
[tool.pdm.scripts]
4242
lint = "pre-commit run --all-files"
43-
release = "pyinstaller --clean ./build.spec --noconfirm"
43+
release_d = "pyinstaller --clean ./build_d.spec --noconfirm"
44+
release_f = "pyinstaller --clean ./build_f.spec --noconfirm"
4445

4546

4647
# Ruff ================================================================================

star_rail/module/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ async def _init_db(self):
4747
return
4848

4949
async with DbClient() as db:
50+
# 有新增表时需要创建
51+
await db.create_all_table()
5052
local_db_version = await db.get_user_version()
5153
logger.debug(
5254
"Local db version: {}, current db version: {}", local_db_version, DB_VERSION

0 commit comments

Comments
 (0)