From 3ed98ea156d487aee3eb6d07f8ae2c171e70e3d7 Mon Sep 17 00:00:00 2001 From: zanllp Date: Sat, 24 Aug 2024 04:53:58 +0800 Subject: [PATCH 1/3] releases/iib_app_cli --- .github/workflows/tauri_app_build.yml | 20 ++++++++++++++++++++ scripts/iib/api.py | 7 ++++--- scripts/iib/plugin.py | 2 ++ scripts/iib/tool.py | 12 +++++++++++- vue/src-tauri/tauri.conf.json | 2 +- 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tauri_app_build.yml b/.github/workflows/tauri_app_build.yml index 806d9169..aabe1c86 100644 --- a/.github/workflows/tauri_app_build.yml +++ b/.github/workflows/tauri_app_build.yml @@ -43,7 +43,22 @@ jobs: script-name: app.py output-file: iib_api_server output-dir: out + include-data-dir: | + vue/dist=vue/dist + - run: cp out/iib_api_server out/iib_app_cli_${{ env.VERSION }}_${{ runner.os }} + if: matrix.os == 'ubuntu-20.04' + - run: cp out/iib_api_server.exe out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }}.exe + if: matrix.os == 'windows-latest' + + - name: Upload Server Artifacts + uses: actions/upload-artifact@v3 + with: + name: iib_app_cli + path: | + out/iib_app_cli-${{ env.VERSION }}_${{ runner.os }} + out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }}.exe + - name: Upload Server Artifacts uses: actions/upload-artifact@v3 with: @@ -195,6 +210,11 @@ jobs: with: name: bundle-${{ env.VERSION }}-Linux path: artifacts + + - uses: actions/download-artifact@v3 + with: + name: iib_app_cli + path: artifacts - name: Release uses: softprops/action-gh-release@v1 diff --git a/scripts/iib/api.py b/scripts/iib/api.py index e909ae4f..0b74ca0c 100644 --- a/scripts/iib/api.py +++ b/scripts/iib/api.py @@ -36,7 +36,7 @@ get_current_commit_hash, get_current_tag, get_file_info_by_path, - get_frame_at_second + get_data_file_path ) from fastapi import FastAPI, HTTPException, Header, Response from fastapi.staticfiles import StaticFiles @@ -73,7 +73,8 @@ except Exception as e: logger.error(e) -index_html_path = os.path.join(cwd, "vue/dist/index.html") # 在app.py也被使用 + +index_html_path = get_data_file_path("vue/dist/index.html") if is_exe_ver else os.path.join(cwd, "vue/dist/index.html") # 在app.py也被使用 send_img_path = {"value": ""} @@ -746,7 +747,7 @@ def index_bd(): return Response(content=content, media_type="text/html") return FileResponse(index_html_path) - static_dir = f"{cwd}/vue/dist" + static_dir = get_data_file_path("vue/dist") if is_exe_ver else f"{cwd}/vue/dist" @app.get(api_base + "/fe-static/{file_path:path}") async def serve_static_file(file_path: str): file_full_path = f"{static_dir}/{file_path}" diff --git a/scripts/iib/plugin.py b/scripts/iib/plugin.py index f37ce548..fbcb7ce4 100644 --- a/scripts/iib/plugin.py +++ b/scripts/iib/plugin.py @@ -4,6 +4,8 @@ from scripts.iib.tool import cwd def load_plugins(plugin_dir): + if not os.path.exists(plugin_dir): + return [] plugins = [] for filename in os.listdir(plugin_dir): main_module_path = os.path.join(plugin_dir, filename, 'main.py') diff --git a/scripts/iib/tool.py b/scripts/iib/tool.py index c632e4e0..b90c80c2 100644 --- a/scripts/iib/tool.py +++ b/scripts/iib/tool.py @@ -723,4 +723,14 @@ def get_frame_at_second(video_path, second): container.seek(frame_container_pts, backward=True, stream=container.streams.video[0]) frame = next(container.decode(video=0)) - return frame \ No newline at end of file + return frame + +def get_data_file_path(filename): + if hasattr(sys, '_MEIPASS'): + # Running in a PyInstaller bundle + base_path = os.path.join(sys._MEIPASS) + else: + # Running in a normal Python environment + base_path = os.path.join(os.path.dirname(__file__)) + + return os.path.normpath(os.path.join(base_path, "../../", filename)) \ No newline at end of file diff --git a/vue/src-tauri/tauri.conf.json b/vue/src-tauri/tauri.conf.json index 0a7335ab..4576f5af 100644 --- a/vue/src-tauri/tauri.conf.json +++ b/vue/src-tauri/tauri.conf.json @@ -8,7 +8,7 @@ }, "package": { "productName": "Infinite Image Browsing", - "version": "1.0.0" + "version": "1.1.0" }, "tauri": { "allowlist": { From 01796689c9944c33d5720f1187b929bba41b2b8e Mon Sep 17 00:00:00 2001 From: zanllp Date: Sat, 24 Aug 2024 05:26:03 +0800 Subject: [PATCH 2/3] fix --- .github/workflows/tauri_app_build.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tauri_app_build.yml b/.github/workflows/tauri_app_build.yml index aabe1c86..142293d5 100644 --- a/.github/workflows/tauri_app_build.yml +++ b/.github/workflows/tauri_app_build.yml @@ -54,7 +54,7 @@ jobs: - name: Upload Server Artifacts uses: actions/upload-artifact@v3 with: - name: iib_app_cli + name: iib_app_cli_${{ runner.os }} path: | out/iib_app_cli-${{ env.VERSION }}_${{ runner.os }} out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }}.exe @@ -213,7 +213,12 @@ jobs: - uses: actions/download-artifact@v3 with: - name: iib_app_cli + name: iib_app_cli_Windows + path: artifacts + + - uses: actions/download-artifact@v3 + with: + name: iib_app_cli_Linux path: artifacts - name: Release From d64b617a658a17dbe2d4d00d5e81a5ed90ffc320 Mon Sep 17 00:00:00 2001 From: zanllp Date: Sat, 24 Aug 2024 05:50:57 +0800 Subject: [PATCH 3/3] fix --- .github/workflows/tauri_app_build.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tauri_app_build.yml b/.github/workflows/tauri_app_build.yml index 142293d5..1d2d9346 100644 --- a/.github/workflows/tauri_app_build.yml +++ b/.github/workflows/tauri_app_build.yml @@ -34,6 +34,7 @@ jobs: - name: Install Dependencies run: | + pip install -r requirements.txt - name: Build Executable @@ -46,7 +47,7 @@ jobs: include-data-dir: | vue/dist=vue/dist - - run: cp out/iib_api_server out/iib_app_cli_${{ env.VERSION }}_${{ runner.os }} + - run: cp out/iib_api_server out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }} if: matrix.os == 'ubuntu-20.04' - run: cp out/iib_api_server.exe out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }}.exe if: matrix.os == 'windows-latest' @@ -56,7 +57,7 @@ jobs: with: name: iib_app_cli_${{ runner.os }} path: | - out/iib_app_cli-${{ env.VERSION }}_${{ runner.os }} + out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }} out/iib_app_cli-${{ env.VERSION }}-${{ runner.os }}.exe - name: Upload Server Artifacts