diff --git a/.github/scripts/auto-sign.sh b/.github/scripts/auto-sign.sh index e1c7358602..5e6ef97508 100755 --- a/.github/scripts/auto-sign.sh +++ b/.github/scripts/auto-sign.sh @@ -1,5 +1,10 @@ #!/bin/bash -APP_PATH=${APP_PATH} -DEVELOPER_ID=${DEVELOPER_ID} -find $APP_PATH \( -type f -perm +111 -o -name "*.node" \) -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \; \ No newline at end of file +# Check if both APP_PATH and DEVELOPER_ID environment variables are set +if [[ -z "$APP_PATH" ]] || [[ -z "$DEVELOPER_ID" ]]; then + echo "Either APP_PATH or DEVELOPER_ID is not set. Skipping script execution." + exit 0 +fi + +# If both variables are set, execute the following commands +find "$APP_PATH" \( -type f -perm +111 -o -name "*.node" \) -exec codesign -s "$DEVELOPER_ID" --options=runtime {} \; diff --git a/.github/workflows/jan-electron-build.yml b/.github/workflows/jan-electron-build.yml index f1c0f5c1e7..34005e0682 100644 --- a/.github/workflows/jan-electron-build.yml +++ b/.github/workflows/jan-electron-build.yml @@ -60,14 +60,14 @@ jobs: run: | yarn build:core yarn install - yarn build:plugins-darwin + yarn build:plugins env: APP_PATH: "." DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }} - name: Build and publish app run: | - yarn build:publish-darwin + yarn build:publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} CSC_LINK: "/tmp/codesign.p12" @@ -122,11 +122,11 @@ jobs: yarn build:core yarn install $env:NITRO_VERSION = Get-Content .\plugins\inference-plugin\nitro\version.txt; echo $env:NITRO_VERSION - yarn build:plugins-win32 + yarn build:plugins - name: Build and publish app run: | - yarn build:publish-win32 + yarn build:publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -178,11 +178,11 @@ jobs: yarn config set network-timeout 300000 yarn build:core yarn install - yarn build:plugins-linux + yarn build:plugins - name: Build and publish app run: | - yarn build:publish-linux + yarn build:publish env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/jan-electron-linter-and-test.yml b/.github/workflows/jan-electron-linter-and-test.yml index 1938a40f53..92f29c368b 100644 --- a/.github/workflows/jan-electron-linter-and-test.yml +++ b/.github/workflows/jan-electron-linter-and-test.yml @@ -95,8 +95,8 @@ jobs: yarn build:core yarn install $env:NITRO_VERSION = Get-Content .\plugins\inference-plugin\nitro\version.txt; echo $env:NITRO_VERSION - yarn build:plugins-win32 - yarn build:test-win32 + yarn build:plugins + yarn build:test $env:CI="e2e" yarn test @@ -131,6 +131,6 @@ jobs: yarn config set network-timeout 300000 yarn build:core yarn install - yarn build:plugins-linux - yarn build:test-linux + yarn build:plugins + yarn build:test yarn test diff --git a/electron/package.json b/electron/package.json index 1072648054..0eed33b2e9 100644 --- a/electron/package.json +++ b/electron/package.json @@ -52,18 +52,18 @@ "lint": "eslint . --ext \".js,.jsx,.ts,.tsx\"", "test:e2e": "playwright test --workers=1", "dev": "tsc -p . && electron .", - "build": "tsc -p . && electron-builder -p never -m", - "build:test": "tsc -p . && electron-builder --dir -p never -m", - "build:test-darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64 --dir", - "build:test-win32": "tsc -p . && electron-builder -p never -w --dir", - "build:test-linux": "tsc -p . && electron-builder -p never -l --dir", - "build:darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64", + "build": "run-script-os", + "build:test": "run-script-os", + "build:test:darwin": "tsc -p . && electron-builder -p never -m --dir", + "build:test:win32": "tsc -p . && electron-builder -p never -w --dir", + "build:test:linux": "tsc -p . && electron-builder -p never -l --dir", + "build:darwin": "tsc -p . && electron-builder -p never -m", "build:win32": "tsc -p . && electron-builder -p never -w", "build:linux": "tsc -p . && electron-builder -p never --linux deb", - "build:publish": "tsc -p . && electron-builder -p onTagOrDraft -m", - "build:publish-darwin": "tsc -p . && electron-builder -p onTagOrDraft -m --x64 --arm64", - "build:publish-win32": "tsc -p . && electron-builder -p onTagOrDraft -w", - "build:publish-linux": "tsc -p . && electron-builder -p onTagOrDraft --linux deb " + "build:publish": "run-script-os", + "build:publish:darwin": "tsc -p . && electron-builder -p onTagOrDraft -m --x64 --arm64", + "build:publish:win32": "tsc -p . && electron-builder -p onTagOrDraft -w", + "build:publish:linux": "tsc -p . && electron-builder -p onTagOrDraft -l deb" }, "dependencies": { "@npmcli/arborist": "^7.1.0", @@ -86,7 +86,8 @@ "electron": "26.2.1", "electron-builder": "^24.6.4", "electron-playwright-helpers": "^1.6.0", - "eslint-plugin-react": "^7.33.2" + "eslint-plugin-react": "^7.33.2", + "run-script-os": "^1.1.6" }, "installConfig": { "hoistingLimits": "workspaces" diff --git a/package.json b/package.json index 32506ea80c..036542c38b 100644 --- a/package.json +++ b/package.json @@ -36,27 +36,16 @@ "build:electron": "yarn workspace jan build", "build:electron:test": "yarn workspace jan build:test", "build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/conversational-json && npm install && npm run build:publish\" \"cd ./plugins/inference-plugin && npm install && npm run build:publish\" \"cd ./plugins/model-plugin && npm install && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm install && npm run build:publish\"", - "build:plugins-win32": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/conversational-json && npm install && npm run build:publish\" \"cd ./plugins/inference-plugin && npm install && npm run build:publish-win32\" \"cd ./plugins/model-plugin && npm install && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm install && npm run build:publish\"", - "build:plugins-linux": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/conversational-json && npm install && npm run build:publish\" \"cd ./plugins/inference-plugin && npm install && npm run build:publish-linux\" \"cd ./plugins/model-plugin && npm install && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm install && npm run build:publish\"", - "build:plugins-darwin": "rimraf ./electron/core/pre-install/*.tgz && concurrently --kill-others-on-fail \"cd ./plugins/conversational-json && npm install && npm run build:publish\" \"cd ./plugins/inference-plugin && npm install && npm run build:publish-darwin\" \"cd ./plugins/model-plugin && npm install && npm run build:publish\" \"cd ./plugins/monitoring-plugin && npm install && npm run build:publish\"", - "build:test": "yarn build:web && yarn build:electron:test", - "build:test-darwin": "yarn build:web && yarn workspace jan build:test-darwin", - "build:test-win32": "yarn build:web && yarn workspace jan build:test-win32", - "build:test-linux": "yarn build:web && yarn workspace jan build:test-linux", - "build": "yarn build:web && yarn build:electron", - "build:darwin": "yarn build:web && yarn workspace jan build:darwin", - "build:win32": "yarn build:web && yarn workspace jan build:win32", - "build:linux": "yarn build:web && yarn workspace jan build:linux", - "build:publish": "yarn build:web && yarn workspace jan build:publish", - "build:publish-darwin": "yarn build:web && yarn workspace jan build:publish-darwin", - "build:publish-win32": "yarn build:web && yarn workspace jan build:publish-win32", - "build:publish-linux": "yarn build:web && yarn workspace jan build:publish-linux" + "build:test": "yarn build:web && yarn workspace jan build:test", + "build": "yarn build:web && yarn workspace jan build", + "build:publish": "yarn build:web && yarn workspace jan build:publish" }, "devDependencies": { "concurrently": "^8.2.1", "cpx": "^1.5.0", "rimraf": "^3.0.2", - "wait-on": "^7.0.1" + "wait-on": "^7.0.1", + "run-script-os": "^1.1.6" }, "version": "0.0.0" } diff --git a/plugins/inference-plugin/package.json b/plugins/inference-plugin/package.json index 5c52d13d0a..3b7159c3ce 100644 --- a/plugins/inference-plugin/package.json +++ b/plugins/inference-plugin/package.json @@ -13,18 +13,14 @@ ], "scripts": { "build": "tsc -b . && webpack --config webpack.config.js", - "downloadnitro:linux-cpu": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64.zip -e --strip 1 -o ./nitro/linux-cpu && chmod +x ./nitro/linux-cpu/nitro && chmod +x ./nitro/linux-start.sh ", - "downloadnitro:linux-cuda": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64-cuda.zip -e --strip 1 -o ./nitro/linux-cuda && chmod +x ./nitro/linux-cuda/nitro && chmod +x ./nitro/linux-start.sh", - "downloadnitro:darwin-arm64": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-arm64.zip -e --strip 1 -o ./nitro/mac-arm64 && chmod +x ./nitro/mac-arm64/nitro", - "downloadnitro:darwin-x64": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-amd64.zip -e --strip 1 -o ./nitro/mac-x64 && chmod +x ./nitro/mac-x64/nitro", - "downloadnitro:win32-cpu": "download https://github.com/janhq/nitro/releases/download/v%NITRO_VERSION%/nitro-%NITRO_VERSION%-win-amd64.zip -e --strip 1 -o ./nitro/win-cpu", - "downloadnitro:win32-cuda": "download https://github.com/janhq/nitro/releases/download/v%NITRO_VERSION%/nitro-%NITRO_VERSION%-win-amd64-cuda.zip -e --strip 1 -o ./nitro/win-cuda", - "downloadnitro:all": "npm run downloadnitro:darwin-arm64 && npm run downloadnitro:darwin-x64 && downloadnitro:win32-cpu && npm run downloadnitro:win32-cuda && npm run downloadnitro:linux-cpu && npm run downloadnitro:linux-cuda", - "build:publish": "rimraf *.tgz --glob && npm run build && npm run downloadnitro:darwin-arm64 && npm run downloadnitro:darwin-x64 && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", - "build:publish-darwin": "rimraf *.tgz --glob && npm run build && npm run downloadnitro:darwin-arm64 && npm run downloadnitro:darwin-x64 && ../../.github/scripts/auto-sign.sh && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", - "build:publish-win32": "rimraf *.tgz --glob && npm run build && npm run downloadnitro:win32-cpu && npm run downloadnitro:win32-cuda && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", - "build:publish-linux": "rimraf *.tgz --glob && npm run build && npm run downloadnitro:linux-cpu && npm run downloadnitro:linux-cuda && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", - "build:publish-all": "rimraf *.tgz --glob && npm run build && npm run downloadnitro:all && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install" + "downloadnitro:linux": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64.zip -e --strip 1 -o ./nitro/linux-cpu && chmod +x ./nitro/linux-cpu/nitro && chmod +x ./nitro/linux-start.sh && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-linux-amd64-cuda.zip -e --strip 1 -o ./nitro/linux-cuda && chmod +x ./nitro/linux-cuda/nitro && chmod +x ./nitro/linux-start.sh", + "downloadnitro:darwin": "NITRO_VERSION=$(cat ./nitro/version.txt) && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-arm64.zip -e --strip 1 -o ./nitro/mac-arm64 && chmod +x ./nitro/mac-arm64/nitro && download https://github.com/janhq/nitro/releases/download/v${NITRO_VERSION}/nitro-${NITRO_VERSION}-mac-amd64.zip -e --strip 1 -o ./nitro/mac-x64 && chmod +x ./nitro/mac-x64/nitro", + "downloadnitro:win32": "download https://github.com/janhq/nitro/releases/download/v%NITRO_VERSION%/nitro-%NITRO_VERSION%-win-amd64.zip -e --strip 1 -o ./nitro/win-cpu && download https://github.com/janhq/nitro/releases/download/v%NITRO_VERSION%/nitro-%NITRO_VERSION%-win-amd64-cuda.zip -e --strip 1 -o ./nitro/win-cuda", + "downloadnitro": "run-script-os", + "build:publish:darwin": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && ../../.github/scripts/auto-sign.sh && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", + "build:publish:win32": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", + "build:publish:linux": "rimraf *.tgz --glob && npm run build && npm run downloadnitro && cpx \"nitro/**\" \"dist/nitro\" && npm pack && cpx *.tgz ../../electron/core/pre-install", + "build:publish": "run-script-os" }, "exports": { ".": "./dist/index.js", @@ -33,6 +29,7 @@ "devDependencies": { "cpx": "^1.5.0", "rimraf": "^3.0.2", + "run-script-os": "^1.1.6", "webpack": "^5.88.2", "webpack-cli": "^5.1.4" },