From 943f52d9292c43d333b5e3752cc68a9a5bbe9f57 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Tue, 7 Jan 2025 05:16:11 -0500 Subject: [PATCH] Ci: fix desktop release CI (#50) --- .github/workflows/desktop-publish.yml | 36 ++++++++------ apps/desktop/package.json | 2 +- packages/ci/package.json | 5 +- packages/ci/scripts/ci-env-check.ts | 49 +++++++++++++++++++ .../tauri-plugins/jarvis/src/utils/icns.rs | 3 ++ pnpm-lock.yaml | 4 +- vendors/tauri-plugin-user-input | 2 +- 7 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 packages/ci/scripts/ci-env-check.ts diff --git a/.github/workflows/desktop-publish.yml b/.github/workflows/desktop-publish.yml index 7157c62..1e24daa 100644 --- a/.github/workflows/desktop-publish.yml +++ b/.github/workflows/desktop-publish.yml @@ -16,10 +16,11 @@ jobs: settings: - platform: "macos-14" # for Arm based macs (M1 and above). args: "--target aarch64-apple-darwin --verbose" - - platform: "macos-14" # for Intel based macs. + - platform: "macos-13" # for Intel based macs. args: "--target x86_64-apple-darwin --verbose" - - platform: "macos-14" # for Both Arm and Intel based macs. - args: "--target universal-apple-darwin --verbose" + # Universal Build no longer supported after adding openssl, which is not cross-compilable. + # - platform: "macos-14" # for Both Arm and Intel based macs. + # args: "--target universal-apple-darwin --verbose" - platform: "ubuntu-22.04" # for Tauri v1 you could replace this with ubuntu-20.04. args: "--verbose" - platform: "windows-latest" @@ -31,35 +32,36 @@ jobs: with: submodules: "true" - - name: install dependencies (ubuntu only) + - name: Install Dependencies (ubuntu only) if: matrix.settings.platform == 'ubuntu-22.04' # This must match the platform value defined above. run: | sudo apt-get update sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf libxdo-dev # You can remove the one that doesn't apply to your app to speed up the workflow a bit. - name: Install protobuf (Mac) - if: matrix.settings.platform == 'macos-14' + if: startsWith(matrix.settings.platform, 'macos') run: | brew install protobuf + brew install openssl - name: Install Protobuf (Ubuntu) if: matrix.settings.platform == 'ubuntu-22.04' run: | sudo apt install -y protobuf-compiler - - name: Install protoc and openssl for windows - if: matrix.settings.platform == 'windows-latest' - run: | - choco install protoc - choco install openssl - echo OPENSSL_DIR='"C:\\Program Files\\OpenSSL-Win64"' >> $env:GITHUB_ENV - echo OPENSSL_INCLUDE_DIR='"C:\\Program Files\\OpenSSL-Win64\\include"' >> $env:GITHUB_ENV - echo OPENSSL_LIB_DIR='"C:\\Program Files\\OpenSSL-Win64\\lib\\VC\\x64\\MDd"' >> $env:GITHUB_ENV - uses: pnpm/action-setup@v4 - - name: setup node + - name: Setup Node uses: actions/setup-node@v4 with: node-version: lts/* cache: "pnpm" # Set this to npm, yarn or pnpm. cache-dependency-path: ./pnpm-lock.yaml + - name: Install protoc and openssl for windows + if: matrix.settings.platform == 'windows-latest' + run: | + choco install protoc + choco install openssl + echo OPENSSL_DIR='C:\Program Files\OpenSSL' >> $env:GITHUB_ENV + echo OPENSSL_INCLUDE_DIR='C:\Program Files\OpenSSL\include' >> $env:GITHUB_ENV + echo OPENSSL_LIB_DIR='C:\Program Files\OpenSSL\lib\VC\x64\MDd' >> $env:GITHUB_ENV - name: Install Rust stable uses: dtolnay/rust-toolchain@stable @@ -71,7 +73,7 @@ jobs: run: | rustup target add aarch64-apple-darwin rustup target add x86_64-apple-darwin - - name: Rust cache + - name: Rust Cache uses: swatinem/rust-cache@v2 with: workspaces: ". -> target" @@ -80,6 +82,10 @@ jobs: bun-version: latest - name: Install Dependencies run: pnpm install + - name: Environment Check + run: | + # pnpm --filter=@kksh/ci run ci-env-check + bun packages/ci/scripts/ci-env-check.ts - name: Build Packages run: pnpm build - name: Get App Version diff --git a/apps/desktop/package.json b/apps/desktop/package.json index 65182bf..2bacc61 100644 --- a/apps/desktop/package.json +++ b/apps/desktop/package.json @@ -1,6 +1,6 @@ { "name": "@kksh/desktop", - "version": "0.1.11", + "version": "0.1.12", "description": "", "type": "module", "scripts": { diff --git a/packages/ci/package.json b/packages/ci/package.json index 3ad3c7d..fa53529 100644 --- a/packages/ci/package.json +++ b/packages/ci/package.json @@ -3,13 +3,14 @@ "module": "index.ts", "type": "module", "scripts": { - "prepare": "bun scripts/setup.ts" + "prepare": "bun scripts/setup.ts", + "ci-env-check": "bun scripts/ci-env-check.ts" }, "devDependencies": { "@types/bun": "latest", "@kksh/typescript-config": "workspace:*" }, "peerDependencies": { - "typescript": "^5.0.0" + "typescript": "^5.7.2" } } diff --git a/packages/ci/scripts/ci-env-check.ts b/packages/ci/scripts/ci-env-check.ts new file mode 100644 index 0000000..280e0c8 --- /dev/null +++ b/packages/ci/scripts/ci-env-check.ts @@ -0,0 +1,49 @@ +import fs from "fs" +import path from "path" + +const OPENSSL_DIR = process.env.OPENSSL_DIR +const OPENSSL_INCLUDE_DIR = process.env.OPENSSL_INCLUDE_DIR +const OPENSSL_LIB_DIR = process.env.OPENSSL_LIB_DIR + +console.log("OPENSSL_DIR", OPENSSL_DIR) +console.log("OPENSSL_INCLUDE_DIR", OPENSSL_INCLUDE_DIR) +console.log("OPENSSL_LIB_DIR", OPENSSL_LIB_DIR) + +if (process.platform === "win32") { + // check if each directory exists + if (!OPENSSL_DIR || !OPENSSL_INCLUDE_DIR || !OPENSSL_LIB_DIR) { + console.error("OPENSSL_DIR, OPENSSL_INCLUDE_DIR, or OPENSSL_LIB_DIR is not set") + process.exit(1) + } + const programFilesDir = "C:\\Program Files" + console.log( + `Program Files Directory (${programFilesDir}) Exists: ${fs.existsSync(programFilesDir)}` + ) + console.log("Program Files Directory Contents:") + for (const dir of fs.readdirSync(programFilesDir)) { + console.log(dir) + } + + console.log(`OPENSSL_DIR (${OPENSSL_DIR}) Exists: ${fs.existsSync(OPENSSL_DIR)}`) + console.log( + `OPENSSL_INCLUDE_DIR (${OPENSSL_INCLUDE_DIR}) Exists: ${fs.existsSync(OPENSSL_INCLUDE_DIR)}` + ) + console.log(`OPENSSL_LIB_DIR (${OPENSSL_LIB_DIR}) Exists: ${fs.existsSync(OPENSSL_LIB_DIR)}`) + if ( + !fs.existsSync(OPENSSL_DIR) || + !fs.existsSync(OPENSSL_INCLUDE_DIR) || + !fs.existsSync(OPENSSL_LIB_DIR) + ) { + console.error("OPENSSL_DIR, OPENSSL_INCLUDE_DIR, or OPENSSL_LIB_DIR is not set") + process.exit(1) + } +} else if (process.platform === "darwin") { + if (OPENSSL_DIR) { + if (fs.existsSync(OPENSSL_DIR)) { + console.log("OPENSSL_DIR exists", OPENSSL_DIR) + } else { + console.log("OPENSSL_DIR does not exist", OPENSSL_DIR) + } + } +} else if (process.platform === "linux") { +} diff --git a/packages/tauri-plugins/jarvis/src/utils/icns.rs b/packages/tauri-plugins/jarvis/src/utils/icns.rs index fcc54cb..cef887d 100644 --- a/packages/tauri-plugins/jarvis/src/utils/icns.rs +++ b/packages/tauri-plugins/jarvis/src/utils/icns.rs @@ -1,10 +1,13 @@ use applications::utils::image::{RustImage, RustImageData}; +use std::path::Path; use std::{ ffi::OsStr, fs::File, io::{BufReader, Cursor}, path::PathBuf, }; +use uuid::Uuid; + #[cfg(target_os = "macos")] use tauri_icns::{IconFamily, IconType}; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 374acf7..d7b65ea 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -547,8 +547,8 @@ importers: packages/ci: dependencies: typescript: - specifier: ^5.0.0 - version: 5.5.4 + specifier: ^5.7.2 + version: 5.7.2 devDependencies: '@kksh/typescript-config': specifier: workspace:* diff --git a/vendors/tauri-plugin-user-input b/vendors/tauri-plugin-user-input index 5766c04..890edc0 160000 --- a/vendors/tauri-plugin-user-input +++ b/vendors/tauri-plugin-user-input @@ -1 +1 @@ -Subproject commit 5766c04cb255b88fb569e6db2ae910ad237fef34 +Subproject commit 890edc0216f5d7d36de7dcdd1809b7551c342e06