From 82aca59dda5f9d61ef3b1b5eafb8eefee90f6894 Mon Sep 17 00:00:00 2001 From: Huakun Shen Date: Tue, 7 Jan 2025 00:41:28 -0500 Subject: [PATCH] ci: update desktop publish workflow and replace OpenSSL check script - Added macOS 14 support for universal builds in the CI workflow. - Introduced a new environment check script for OpenSSL configuration, replacing the previous openssl-check script. - Removed the old openssl-check script to streamline the CI process. - Updated package.json to reflect the new script name for environment checks. --- .github/workflows/desktop-publish.yml | 22 ++++++------ packages/ci/package.json | 2 +- packages/ci/scripts/ci-env-check.ts | 51 +++++++++++++++++++++++++++ packages/ci/scripts/openssl-check.ts | 29 --------------- 4 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 packages/ci/scripts/ci-env-check.ts delete mode 100644 packages/ci/scripts/openssl-check.ts diff --git a/.github/workflows/desktop-publish.yml b/.github/workflows/desktop-publish.yml index f0a53cc..a16db5f 100644 --- a/.github/workflows/desktop-publish.yml +++ b/.github/workflows/desktop-publish.yml @@ -20,8 +20,8 @@ jobs: # args: "--target aarch64-apple-darwin --verbose" # - 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" + - 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" @@ -49,6 +49,13 @@ jobs: if: matrix.settings.platform == 'ubuntu-22.04' run: | sudo apt install -y protobuf-compiler + - uses: pnpm/action-setup@v4 + - 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: | @@ -57,14 +64,6 @@ jobs: 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 - pnpm --filter=@kksh/ci openssl-check - - uses: pnpm/action-setup@v4 - - 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 Rust stable uses: dtolnay/rust-toolchain@stable @@ -85,6 +84,9 @@ jobs: bun-version: latest - name: Install Dependencies run: pnpm install + - name: Environment Check + run: | + pnpm --filter=@kksh/ci ci-env-check - name: Build Packages run: pnpm build - name: Get App Version diff --git a/packages/ci/package.json b/packages/ci/package.json index fdfcaff..a6b1d66 100644 --- a/packages/ci/package.json +++ b/packages/ci/package.json @@ -4,7 +4,7 @@ "type": "module", "scripts": { "prepare": "bun scripts/setup.ts", - "openssl-check": "bun scripts/openssl-check.ts" + "ci-env-check": "bun scripts/ci-env-check.ts" }, "devDependencies": { "@types/bun": "latest", diff --git a/packages/ci/scripts/ci-env-check.ts b/packages/ci/scripts/ci-env-check.ts new file mode 100644 index 0000000..b1135bd --- /dev/null +++ b/packages/ci/scripts/ci-env-check.ts @@ -0,0 +1,51 @@ +import fs from 'fs' +// run the following only on windows + +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); + } + + // check if each directory exists + if (!fs.existsSync(OPENSSL_DIR)) { + console.error("OPENSSL_DIR does not exist", OPENSSL_DIR); + process.exit(1); + } else { + console.log("OPENSSL_DIR exists", OPENSSL_DIR); + } + if (!fs.existsSync(OPENSSL_INCLUDE_DIR)) { + console.error("OPENSSL_INCLUDE_DIR does not exist", OPENSSL_INCLUDE_DIR); + process.exit(1); + } else { + console.log("OPENSSL_INCLUDE_DIR exists", OPENSSL_INCLUDE_DIR); + } + if (!fs.existsSync(OPENSSL_LIB_DIR)) { + console.error("OPENSSL_LIB_DIR does not exist", OPENSSL_LIB_DIR); + process.exit(1); + } else { + console.log("OPENSSL_LIB_DIR exists", OPENSSL_LIB_DIR); + } +} else if (process.platform === "darwin") { + if (OPENSSL_DIR) { + if (fs.existsSync(OPENSSL_DIR)) { + console.log("OPENSSL_DIR exists", OPENSSL_DIR); + } else { + console.error("OPENSSL_DIR does not exist", OPENSSL_DIR); + } + + } +} else if (process.platform === "linux") { + +} diff --git a/packages/ci/scripts/openssl-check.ts b/packages/ci/scripts/openssl-check.ts deleted file mode 100644 index 7caaa2f..0000000 --- a/packages/ci/scripts/openssl-check.ts +++ /dev/null @@ -1,29 +0,0 @@ -import fs from 'fs' - -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); - -// 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); -} - -// check if each directory exists -if (!fs.existsSync(OPENSSL_DIR)) { - console.error("OPENSSL_DIR does not exist", OPENSSL_DIR); - process.exit(1); -} -if (!fs.existsSync(OPENSSL_INCLUDE_DIR)) { - console.error("OPENSSL_INCLUDE_DIR does not exist", OPENSSL_INCLUDE_DIR); - process.exit(1); -} -if (!fs.existsSync(OPENSSL_LIB_DIR)) { - console.error("OPENSSL_LIB_DIR does not exist", OPENSSL_LIB_DIR); - process.exit(1); -}