From 689ad882268c3185a8c17a83c0b6d210e55407f0 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 20:46:12 +0800 Subject: [PATCH 01/12] Update build.yml --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be4ab26..118079c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -108,6 +108,7 @@ jobs: name: Release needs: [build-for-macos, build-for-windows] runs-on: ubuntu-latest + permissions: write-all steps: - uses: actions/checkout@v4 From bdc6e4cf526a4f544335f8d8943f58c08bf17d18 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 21:02:02 +0800 Subject: [PATCH 02/12] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b307509..3bbdd2b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "imagenie", "private": true, - "version": "0.2.0", + "version": "0.2.2", "type": "module", "scripts": { "dev": "vite", From 3c1475583b304b72c397848f5fb27a03bdda6d04 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 21:26:09 +0800 Subject: [PATCH 03/12] Update tauri.conf.json nsis --- src-tauri/tauri.conf.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index b9e7009..62b951a 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -54,6 +54,10 @@ "windows": { "webviewInstallMode": { "type": "embedBootstrapper" + }, + "nsis": { + "installerIcon": "icons/icon.ico", + "languages": ["English", "SimpChinese"] } } } From b792a7136617a7e4ab74a708932e2d9c2b930b36 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 21:44:54 +0800 Subject: [PATCH 04/12] Enhance build process and error handling for Windows - Improve error handling and logging in the build script for better resilience and debugging. - Update Tauri configuration for enhanced Windows installation options and settings. - Modify GitHub Actions workflow to ensure proper NSIS installation and build failure feedback. --- .github/workflows/build.yml | 12 ++++++- scripts/dist.js | 68 +++++++++++++++++++++++-------------- src-tauri/tauri.conf.json | 11 ++++++ 3 files changed, 65 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be4ab26..e7bc83d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,12 +90,22 @@ jobs: uses: swatinem/rust-cache@v2 with: workspaces: './src-tauri -> target' + - name: Install NSIS + run: | + iwr -useb get.scoop.sh -outfile 'install.ps1' + .\install.ps1 -RunAsAdmin + scoop install nsis + shell: pwsh - name: Build APP shell: pwsh run: | yarn install $VERSION = node -p "require('./package.json').version" - yarn tauri build -c "{\`"version\`":\`"$VERSION\`"}" -t ${{ matrix.target }} --bundles nsis + $env:TAURI_BUNDLE_NSI = "true" + yarn tauri build -c '{\"version\":\"'$VERSION'\"}' -t ${{ matrix.target }} --bundles nsis + if ($LASTEXITCODE -ne 0) { + throw "Tauri build failed with exit code $LASTEXITCODE" + } $APP_NAME = "Imagenie_${VERSION}_${{ matrix.build }}_${{ matrix.arch }}" node scripts/dist.js ${{ matrix.target }} $APP_NAME - name: Upload App diff --git a/scripts/dist.js b/scripts/dist.js index 5c5d14c..488c87a 100644 --- a/scripts/dist.js +++ b/scripts/dist.js @@ -24,33 +24,51 @@ const copyFile = async (from, to) => { await fs.copyFile(from, to).catch(() => null); }; async function main() { - const args = process.argv.slice(2); - const [target, appName] = args; - const bundleDir = path.resolve(`src-tauri/target/${target}/release/bundle`); - let outputs = {}; - switch (process.platform) { - case "darwin": - outputs = { - dmg: [".dmg"], - }; - break; - case "win32": - outputs = { - nsis: [".exe"], - }; - } - for (const dir in outputs) { - const files = await getFiles(path.join(bundleDir, dir)); - for (const filename of files) { - const suffix = outputs[dir].find((e) => filename.endsWith(e)); - if (suffix) { - await copyFile( - path.join(bundleDir, dir, filename), - path.join("dist", appName + suffix) - ); - console.log(`✅ ${appName + suffix}`); + try { + const args = process.argv.slice(2); + const [target, appName] = args; + const bundleDir = path.resolve(`src-tauri/target/${target}/release/bundle`); + + if (!existsSync(bundleDir)) { + console.error(`Build directory not found: ${bundleDir}`); + process.exit(1); + } + + let outputs = {}; + switch (process.platform) { + case "darwin": + outputs = { + dmg: [".dmg"], + }; + break; + case "win32": + const nsisDir = path.join(bundleDir, 'nsis'); + if (!existsSync(nsisDir)) { + console.error('NSIS bundle directory not found. Make sure NSIS is installed and the build completed successfully.'); + console.error(`Expected directory: ${nsisDir}`); + process.exit(1); + } + outputs = { + nsis: [".exe"], + }; + break; + } + for (const dir in outputs) { + const files = await getFiles(path.join(bundleDir, dir)); + for (const filename of files) { + const suffix = outputs[dir].find((e) => filename.endsWith(e)); + if (suffix) { + await copyFile( + path.join(bundleDir, dir, filename), + path.join("dist", appName + suffix) + ); + console.log(`✅ ${appName + suffix}`); + } } } + } catch (error) { + console.error('Error in dist script:', error); + process.exit(1); } } main(); diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index b9e7009..9b26747 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -54,6 +54,17 @@ "windows": { "webviewInstallMode": { "type": "embedBootstrapper" + }, + "nsis": { + "installMode": "perMachine", + "license": null, + "headerImage": null, + "sidebarImage": null, + "installerIcon": "icons/icon.ico", + "uninstallerIcon": "icons/icon.ico", + "installerHeader": null, + "installerBackground": null, + "uninstallerBackground": null } } } From d84e56f932df34feea8909a497f1d473f1e0cfdd Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 21:47:07 +0800 Subject: [PATCH 05/12] Refactor Windows installer configuration settings - Refactor Windows bundle settings to streamline configuration. - Remove unnecessary fields to simplify the `nsis` section. - Preserve the `installerIcon` configuration for improved clarity. --- src-tauri/tauri.conf.json | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 9b26747..b306da4 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -57,14 +57,9 @@ }, "nsis": { "installMode": "perMachine", - "license": null, "headerImage": null, "sidebarImage": null, - "installerIcon": "icons/icon.ico", - "uninstallerIcon": "icons/icon.ico", - "installerHeader": null, - "installerBackground": null, - "uninstallerBackground": null + "installerIcon": "icons/icon.ico" } } } From bb92a476fbada35a796347a94cc2fd55ea8e09a1 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 21:56:08 +0800 Subject: [PATCH 06/12] Enhance Windows installer and timize build workflow - Enhance Windows installer configuration to support multiple languages. - Refactor Windows build workflow to remove unnecessary NSIS installation step. - Optimize artifact download process in the release job for improved efficiency. --- .github/workflows/build.yml | 6 ------ src-tauri/tauri.conf.json | 6 +++++- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a604de0..c291c95 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -90,12 +90,6 @@ jobs: uses: swatinem/rust-cache@v2 with: workspaces: './src-tauri -> target' - - name: Install NSIS - run: | - iwr -useb get.scoop.sh -outfile 'install.ps1' - .\install.ps1 -RunAsAdmin - scoop install nsis - shell: pwsh - name: Build APP shell: pwsh run: | diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index b306da4..0063970 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -59,7 +59,11 @@ "installMode": "perMachine", "headerImage": null, "sidebarImage": null, - "installerIcon": "icons/icon.ico" + "installerIcon": "icons/icon.ico", + "languages": [ + "English", + "SimpChinese" + ] } } } From 4d8b81074142a238c9c349130d2ee32d6d4c1c18 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 22:00:44 +0800 Subject: [PATCH 07/12] Refactor Windows build process with structured config - Refactor Windows build step to utilize structured configuration for better maintainability. - Update Tauri build command syntax to align with new configuration standards. - Enhance release step to support merging of downloaded artifacts for streamlined deployments. --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c291c95..b7890e8 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -96,7 +96,8 @@ jobs: yarn install $VERSION = node -p "require('./package.json').version" $env:TAURI_BUNDLE_NSI = "true" - yarn tauri build -c '{\"version\":\"'$VERSION'\"}' -t ${{ matrix.target }} --bundles nsis + $CONFIG = @{version=$VERSION} | ConvertTo-Json -Compress + yarn tauri build --config $CONFIG -t ${{ matrix.target }} --bundles nsis if ($LASTEXITCODE -ne 0) { throw "Tauri build failed with exit code $LASTEXITCODE" } From c56d06ef0fc02dddef4cfd866013fdf23143b1d6 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 22:24:32 +0800 Subject: [PATCH 08/12] Enhance cross-platform build configurations and dependencies - Modify build configurations to improve cross-platform compatibility for Windows and macOS. - Implement structured release process with enhanced versioning and artifact management. - Integrate ARM64 support and necessary dependencies for Windows in the `ort` crate. --- .github/workflows/build.yml | 9 ++++--- src-tauri/Cargo.lock | 51 ++++++++++++++++++++++++++++++++++--- src-tauri/Cargo.toml | 17 +++++++++++++ 3 files changed, 70 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b7890e8..4b6a1b3 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -67,10 +67,11 @@ jobs: build: windows os: windows-latest arch: x86_64 - - target: aarch64-pc-windows-msvc - build: windows - os: windows-latest - arch: aarch64 + # Temporarily annotate the ARM64 build + # - target: aarch64-pc-windows-msvc + # build: windows + # os: windows-latest + # arch: aarch64 runs-on: ${{ matrix.os }} steps: diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index b7c4fba..5761265 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2291,9 +2291,10 @@ dependencies = [ "futures-util", "half", "image", - "ndarray", + "ndarray 0.16.1", "num-traits", - "ort", + "ort 1.16.3", + "ort 2.0.0-rc.8", "rayon", "reqwest", "serde", @@ -2816,6 +2817,19 @@ dependencies = [ "tempfile", ] +[[package]] +name = "ndarray" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" +dependencies = [ + "matrixmultiply", + "num-complex", + "num-integer", + "num-traits", + "rawpointer", +] + [[package]] name = "ndarray" version = "0.16.1" @@ -3344,6 +3358,25 @@ dependencies = [ "pin-project-lite", ] +[[package]] +name = "ort" +version = "1.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "889dca4c98efa21b1ba54ddb2bde44fd4920d910f492b618351f839d8428d79d" +dependencies = [ + "flate2", + "lazy_static", + "libc", + "ndarray 0.15.6", + "tar", + "thiserror 1.0.69", + "tracing", + "ureq", + "vswhom", + "winapi", + "zip", +] + [[package]] name = "ort" version = "2.0.0-rc.8" @@ -3351,7 +3384,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11826e6118cc42fea0cb2b102f7d006c1bb339cb167f8badb5fb568616438234" dependencies = [ "half", - "ndarray", + "ndarray 0.16.1", "ort-sys", "tracing", ] @@ -7026,6 +7059,18 @@ dependencies = [ "syn 2.0.87", ] +[[package]] +name = "zip" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" +dependencies = [ + "byteorder", + "crc32fast", + "crossbeam-utils", + "flate2", +] + [[package]] name = "zune-core" version = "0.4.12" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index e223046..75fc724 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -50,3 +50,20 @@ chrono = "0.4.38" [package.metadata.cargo-machete] ignored = ["serde_json", "serde", "num-traits", "tauri-plugin-http", "tauri-plugin-shell", "tokio"] + +[target.'cfg(target_os = "windows")'.dependencies] +ort = { version = "1.16.3", features = [ + "download-binaries", + "cuda", +], default-features = false } + +[target.'cfg(all(target_os = "windows", target_arch = "x86_64"))'.dependencies] +ort = { version = "1.16.3", features = [ + "download-binaries", + "cuda", +], default-features = false } + +[target.'cfg(all(target_os = "windows", target_arch = "aarch64"))'.dependencies] +ort = { version = "1.16.3", features = [ + "download-binaries", +], default-features = false } From 931de63d79b7c0a2c56f329dd2755f8621439ef9 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sat, 14 Dec 2024 22:42:39 +0800 Subject: [PATCH 09/12] Refactor platform dependencies in Cargo.toml - Refactor the Cargo.toml file to eliminate Windows-specific dependencies. - Streamline the project configuration for improved cross-platform compatibility. --- src-tauri/Cargo.lock | 51 +++----------------------------------------- src-tauri/Cargo.toml | 17 --------------- 2 files changed, 3 insertions(+), 65 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 5761265..b7c4fba 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2291,10 +2291,9 @@ dependencies = [ "futures-util", "half", "image", - "ndarray 0.16.1", + "ndarray", "num-traits", - "ort 1.16.3", - "ort 2.0.0-rc.8", + "ort", "rayon", "reqwest", "serde", @@ -2817,19 +2816,6 @@ dependencies = [ "tempfile", ] -[[package]] -name = "ndarray" -version = "0.15.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" -dependencies = [ - "matrixmultiply", - "num-complex", - "num-integer", - "num-traits", - "rawpointer", -] - [[package]] name = "ndarray" version = "0.16.1" @@ -3358,25 +3344,6 @@ dependencies = [ "pin-project-lite", ] -[[package]] -name = "ort" -version = "1.16.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "889dca4c98efa21b1ba54ddb2bde44fd4920d910f492b618351f839d8428d79d" -dependencies = [ - "flate2", - "lazy_static", - "libc", - "ndarray 0.15.6", - "tar", - "thiserror 1.0.69", - "tracing", - "ureq", - "vswhom", - "winapi", - "zip", -] - [[package]] name = "ort" version = "2.0.0-rc.8" @@ -3384,7 +3351,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11826e6118cc42fea0cb2b102f7d006c1bb339cb167f8badb5fb568616438234" dependencies = [ "half", - "ndarray 0.16.1", + "ndarray", "ort-sys", "tracing", ] @@ -7059,18 +7026,6 @@ dependencies = [ "syn 2.0.87", ] -[[package]] -name = "zip" -version = "0.6.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" -dependencies = [ - "byteorder", - "crc32fast", - "crossbeam-utils", - "flate2", -] - [[package]] name = "zune-core" version = "0.4.12" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 75fc724..e223046 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -50,20 +50,3 @@ chrono = "0.4.38" [package.metadata.cargo-machete] ignored = ["serde_json", "serde", "num-traits", "tauri-plugin-http", "tauri-plugin-shell", "tokio"] - -[target.'cfg(target_os = "windows")'.dependencies] -ort = { version = "1.16.3", features = [ - "download-binaries", - "cuda", -], default-features = false } - -[target.'cfg(all(target_os = "windows", target_arch = "x86_64"))'.dependencies] -ort = { version = "1.16.3", features = [ - "download-binaries", - "cuda", -], default-features = false } - -[target.'cfg(all(target_os = "windows", target_arch = "aarch64"))'.dependencies] -ort = { version = "1.16.3", features = [ - "download-binaries", -], default-features = false } From 058d844d84cb28a141238fa672b1bb3220bdecf3 Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sun, 15 Dec 2024 13:32:31 +0800 Subject: [PATCH 10/12] Update ORT dependency and adjust image handling setup - Update `ort` dependencies and adjust related module imports to reflect new paths. - Refactor image processing session handling for better compatibility with `ort` changes. - Enhance security policies in the configuration to support new image sources and connection protocols. --- src-tauri/Cargo.lock | 8 ++++---- src-tauri/Cargo.toml | 2 +- src-tauri/src/image/model.rs | 2 +- src-tauri/src/image/processor.rs | 2 +- src-tauri/src/image/types.rs | 4 ++-- src-tauri/tauri.conf.json | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index b7c4fba..474f0bf 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3346,9 +3346,9 @@ dependencies = [ [[package]] name = "ort" -version = "2.0.0-rc.8" +version = "2.0.0-rc.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11826e6118cc42fea0cb2b102f7d006c1bb339cb167f8badb5fb568616438234" +checksum = "52afb44b6b0cffa9bf45e4d37e5a4935b0334a51570658e279e9e3e6cf324aa5" dependencies = [ "half", "ndarray", @@ -3358,9 +3358,9 @@ dependencies = [ [[package]] name = "ort-sys" -version = "2.0.0-rc.8" +version = "2.0.0-rc.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4780a8b8681e653b2bed85c7f0e2c6e8547224c3e983e5ad27bf0457e012407" +checksum = "c41d7757331aef2d04b9cb09b45583a59217628beaf91895b7e76187b6e8c088" dependencies = [ "flate2", "pkg-config", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index e223046..2b904d9 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -35,7 +35,7 @@ tauri-plugin-process = "2" tauri-plugin-shell = "2" tauri-plugin-window-state = "2.0.1" tracing = { version = "0.1.40", features = ["log"] } -ort = { version = "2.0.0-rc.8" } +ort = { version = "2.0.0-rc.9" } image = "0.25.4" ndarray = "0.16.1" half = "2.3" diff --git a/src-tauri/src/image/model.rs b/src-tauri/src/image/model.rs index 229ecd3..2605e3d 100644 --- a/src-tauri/src/image/model.rs +++ b/src-tauri/src/image/model.rs @@ -1,5 +1,5 @@ use image::DynamicImage; -use ort::{inputs, GraphOptimizationLevel, Session, Value}; +use ort::{inputs, session::builder::GraphOptimizationLevel, session::Session, value::Value}; use std::marker::PhantomData; use crate::image::error::ImageProcessingError; diff --git a/src-tauri/src/image/processor.rs b/src-tauri/src/image/processor.rs index 00dfbb1..2314937 100644 --- a/src-tauri/src/image/processor.rs +++ b/src-tauri/src/image/processor.rs @@ -5,7 +5,7 @@ use std::marker::PhantomData; use super::{ImageModel, ImageProcessingError}; pub struct ModelProcessor { - session: ort::Session, + session: ort::session::Session, _phantom: PhantomData, } diff --git a/src-tauri/src/image/types.rs b/src-tauri/src/image/types.rs index b0205ea..1b44596 100644 --- a/src-tauri/src/image/types.rs +++ b/src-tauri/src/image/types.rs @@ -42,8 +42,8 @@ pub trait NumericType: + Send + Sync + std::fmt::Debug - + ort::IntoTensorElementType - + ort::PrimitiveTensorElementType + // + ort::IntoTensorElementType + // + ort::PrimitiveTensorElementType + 'static { fn from_f32(v: f32) -> Self; diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 0063970..c6e3f1c 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -24,10 +24,10 @@ "windows": [], "security": { "csp": { - "default-src": "'self'", "style-src": "'self' 'unsafe-inline'", - "img-src": "'self' asset: https://raw.githubusercontent.com data:", - "connect-src": "'self' ipc: https://api.github.com", + "img-src": "'self' asset: http://asset.localhost https://raw.githubusercontent.com blob: data:", + "default-src": "'self' asset:", + "connect-src": "'self' tauri: http://tauri.localhost ipc: http://ipc.localhost http://localhost:8023 ipc: https://api.github.com", "script-src": "'self'" }, "assetProtocol": { From 44e5807bb2c54094740acca5bcc035f311992b3f Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sun, 15 Dec 2024 15:47:01 +0800 Subject: [PATCH 11/12] Improve app initialization and version updates - Bump application version to 0.2.2 for both Cargo and Tauri configuration. - Enhance security by adding additional source URLs to the connect-src settings. - Improve code clarity and initialization logic in the App.vue component. --- src-tauri/Cargo.lock | 2 +- src-tauri/Cargo.toml | 2 +- src-tauri/tauri.conf.json | 4 ++-- src/App.vue | 30 ++++++++++++++++++++++++++---- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 474f0bf..459b44f 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -2282,7 +2282,7 @@ dependencies = [ [[package]] name = "imagenie" -version = "0.2.0" +version = "0.2.2" dependencies = [ "anyhow", "chrono", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2b904d9..c74c674 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "imagenie" -version = "0.2.0" +version = "0.2.2" description = "A Tauri App" authors = ["zhongwei"] edition = "2021" diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index c6e3f1c..5f47321 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "imagenie", - "version": "0.2.0", + "version": "0.2.2", "identifier": "com.imagenie.app", "build": { "beforeDevCommand": "yarn dev", @@ -27,7 +27,7 @@ "style-src": "'self' 'unsafe-inline'", "img-src": "'self' asset: http://asset.localhost https://raw.githubusercontent.com blob: data:", "default-src": "'self' asset:", - "connect-src": "'self' tauri: http://tauri.localhost ipc: http://ipc.localhost http://localhost:8023 ipc: https://api.github.com", + "connect-src": "'self' tauri: http://tauri.localhost ipc: http://ipc.localhost http://localhost:8023 ipc: https://api.github.com https://api.iconify.design https://api.unisvg.com https://api.simplesvg.com", "script-src": "'self'" }, "assetProtocol": { diff --git a/src/App.vue b/src/App.vue index 4544e00..5dc16c5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,20 +1,42 @@ From a9d16a8d1bad84cc3606cead76e55850ce298a8e Mon Sep 17 00:00:00 2001 From: zhongweili Date: Sun, 15 Dec 2024 16:14:07 +0800 Subject: [PATCH 12/12] Remove obsolete build scripts and workflows - Remove the obsolete `dist.js` script to streamline the build process. - Eliminate the GitHub Actions workflow for cross-platform builds to simplify CI/CD configuration. --- .github/workflows/build.yml | 148 ------------------------------------ scripts/dist.js | 74 ------------------ 2 files changed, 222 deletions(-) delete mode 100644 .github/workflows/build.yml delete mode 100644 scripts/dist.js diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 4b6a1b3..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,148 +0,0 @@ -name: Build APP -on: - workflow_dispatch: - -jobs: - build-for-macos: - name: macOS - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - - target: universal-apple-darwin - build: macos - os: macos-latest - arch: universal - - target: aarch64-apple-darwin - build: macos - os: macos-latest - arch: aarch64 - - target: x86_64-apple-darwin - build: macos - os: macos-latest - arch: x86_64 - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Setup Yarn - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "yarn" - cache-dependency-path: "yarn.lock" - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: ${{ matrix.arch == 'universal' && 'aarch64-apple-darwin,x86_64-apple-darwin' || matrix.target }} - - name: Setup Rust Cache - uses: swatinem/rust-cache@v2 - with: - workspaces: './src-tauri -> target' - - name: Build APP - run: | - yarn install - VERSION=$(node -p "require('./package.json').version") - CI=false yarn tauri build -c "{\"version\":\"$VERSION\"}" -t ${{ matrix.target }} - APP_NAME="Imagenie_${VERSION}_${{ matrix.build }}_${{ matrix.arch }}" - node scripts/dist.js ${{ matrix.target }} $APP_NAME - - name: Upload App - uses: actions/upload-artifact@v4 - with: - name: app_${{ matrix.build }}_${{ matrix.arch }} - path: dist/Imagenie_* - - build-for-windows: - name: Windows - permissions: - contents: write - strategy: - fail-fast: false - matrix: - include: - - target: x86_64-pc-windows-msvc - build: windows - os: windows-latest - arch: x86_64 - # Temporarily annotate the ARM64 build - # - target: aarch64-pc-windows-msvc - # build: windows - # os: windows-latest - # arch: aarch64 - - runs-on: ${{ matrix.os }} - steps: - - uses: actions/checkout@v4 - - name: Setup Yarn - uses: actions/setup-node@v4 - with: - node-version: 20 - cache: "yarn" - cache-dependency-path: "yarn.lock" - - name: Setup Rust - uses: dtolnay/rust-toolchain@stable - with: - toolchain: stable - targets: ${{ matrix.target }} - - name: Setup Rust Cache - uses: swatinem/rust-cache@v2 - with: - workspaces: './src-tauri -> target' - - name: Build APP - shell: pwsh - run: | - yarn install - $VERSION = node -p "require('./package.json').version" - $env:TAURI_BUNDLE_NSI = "true" - $CONFIG = @{version=$VERSION} | ConvertTo-Json -Compress - yarn tauri build --config $CONFIG -t ${{ matrix.target }} --bundles nsis - if ($LASTEXITCODE -ne 0) { - throw "Tauri build failed with exit code $LASTEXITCODE" - } - $APP_NAME = "Imagenie_${VERSION}_${{ matrix.build }}_${{ matrix.arch }}" - node scripts/dist.js ${{ matrix.target }} $APP_NAME - - name: Upload App - uses: actions/upload-artifact@v4 - with: - name: app_${{ matrix.build }}_${{ matrix.arch }} - path: dist/Imagenie_* - - release: - name: Release - needs: [build-for-macos, build-for-windows] - runs-on: ubuntu-latest - permissions: write-all - - steps: - - uses: actions/checkout@v4 - - name: Download Artifacts - uses: actions/download-artifact@v4 - with: - pattern: app_* - path: dist - merge-multiple: true - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Check Version - id: version - run: | - VERSION=$(node -p "require('./package.json').version") - echo "version=$VERSION" >> $GITHUB_OUTPUT - - name: Release Imagenie v${{ steps.version.outputs.version }} - uses: ncipollo/release-action@v1 - with: - allowUpdates: true - token: ${{ secrets.GITHUB_TOKEN }} - tag: app-v${{ steps.version.outputs.version }} - name: Imagenie v${{ steps.version.outputs.version }} - body: Imagenie APP v${{ steps.version.outputs.version }} - draft: true - prerelease: false - makeLatest: latest - removeArtifacts: true - artifacts: dist/* diff --git a/scripts/dist.js b/scripts/dist.js deleted file mode 100644 index 488c87a..0000000 --- a/scripts/dist.js +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env node - -import fs from "fs/promises"; -import { existsSync, mkdirSync } from "fs"; -import path from "path"; -const getFiles = async (dir) => { - try { - const files = await fs.readdir(dir); - return files; - } catch (err) { - console.error(`Error reading directory ${dir}:`, err); - return []; - } -}; -const copyFile = async (from, to) => { - if (!existsSync(from)) { - console.error(`Source file does not exist: ${from}`); - return false; - } - const dirname = path.dirname(to); - if (!existsSync(dirname)) { - mkdirSync(dirname, { recursive: true }); - } - await fs.copyFile(from, to).catch(() => null); -}; -async function main() { - try { - const args = process.argv.slice(2); - const [target, appName] = args; - const bundleDir = path.resolve(`src-tauri/target/${target}/release/bundle`); - - if (!existsSync(bundleDir)) { - console.error(`Build directory not found: ${bundleDir}`); - process.exit(1); - } - - let outputs = {}; - switch (process.platform) { - case "darwin": - outputs = { - dmg: [".dmg"], - }; - break; - case "win32": - const nsisDir = path.join(bundleDir, 'nsis'); - if (!existsSync(nsisDir)) { - console.error('NSIS bundle directory not found. Make sure NSIS is installed and the build completed successfully.'); - console.error(`Expected directory: ${nsisDir}`); - process.exit(1); - } - outputs = { - nsis: [".exe"], - }; - break; - } - for (const dir in outputs) { - const files = await getFiles(path.join(bundleDir, dir)); - for (const filename of files) { - const suffix = outputs[dir].find((e) => filename.endsWith(e)); - if (suffix) { - await copyFile( - path.join(bundleDir, dir, filename), - path.join("dist", appName + suffix) - ); - console.log(`✅ ${appName + suffix}`); - } - } - } - } catch (error) { - console.error('Error in dist script:', error); - process.exit(1); - } -} -main();