diff --git a/.github/workflows/build-app.yml b/.github/workflows/build-app.yml new file mode 100644 index 000000000..a499add86 --- /dev/null +++ b/.github/workflows/build-app.yml @@ -0,0 +1,151 @@ +name: Jan Build MacOS App + +on: + push: + tags: ['v*.*.*'] + +jobs: + build-macos: + runs-on: macos-latest + environment: production + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + + - name: Installing node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + - name: Update app version base on tag + run: | + if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Tag is not valid!" + exit 1 + fi + jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json + env: + VERSION_TAG: ${{ steps.tag.outputs.tag }} + + - name: Install yarn dependencies + run: | + yarn install + yarn build:plugins + + - name: Get Cer for code signing + run: base64 -d <<< "$CODE_SIGN_P12_BASE64" > /tmp/codesign.p12 + shell: bash + env: + CODE_SIGN_P12_BASE64: ${{ secrets.CODE_SIGN_P12_BASE64 }} + + - name: Build and publish app + run: | + yarn build:publish-darwin + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CSC_LINK: "/tmp/codesign.p12" + CSC_KEY_PASSWORD: ${{ secrets.CODE_SIGN_P12_PASSWORD }} + CSC_IDENTITY_AUTO_DISCOVERY: "true" + + build-windows-x64: + runs-on: windows-latest + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + + - name: Installing node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + - name: Update app version base on tag + shell: bash + run: | + if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Tag is not valid!" + exit 1 + fi + jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json + env: + VERSION_TAG: ${{ steps.tag.outputs.tag }} + + - name: Install yarn dependencies + run: | + yarn config set network-timeout 300000 + yarn install + yarn build:plugins + + - name: Build and publish app + run: | + yarn build:publish-win32 + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + build-linux-x64: + runs-on: ubuntu-latest + environment: production + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} + permissions: + contents: write + steps: + - name: Getting the repo + uses: actions/checkout@v3 + + - name: Installing node + uses: actions/setup-node@v1 + with: + node-version: 20 + + - name: Install jq + uses: dcarbone/install-jq-action@v2.0.1 + + - name: Install Snapcraft + uses: samuelmeuli/action-snapcraft@v2 + + - name: Get tag + id: tag + uses: dawidd6/action-get-tag@v1 + + - name: Update app version base on tag + run: | + if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Error: Tag is not valid!" + exit 1 + fi + jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json + mv /tmp/package.json electron/package.json + env: + VERSION_TAG: ${{ steps.tag.outputs.tag }} + + - name: Install yarn dependencies + run: | + yarn config set network-timeout 300000 + yarn install + yarn build:plugins + + - name: Build and publish app + run: | + yarn build:publish-linux + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/macos-build-app.yml b/.github/workflows/macos-build-app.yml deleted file mode 100644 index 0977d1a6f..000000000 --- a/.github/workflows/macos-build-app.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Jan Build MacOS App - -on: - push: - tags: ['v*.*.*'] - -jobs: - build-macos-app: - runs-on: macos-latest - - permissions: - contents: write - steps: - - name: Getting the repo - uses: actions/checkout@v3 - - - name: Installing node - uses: actions/setup-node@v1 - with: - node-version: 20 - - - name: Install jq - uses: dcarbone/install-jq-action@v2.0.1 - - - name: Get tag - id: tag - uses: dawidd6/action-get-tag@v1 - - - name: Update app version base on tag - run: | - if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then - echo "Error: Tag is not valid!" - exit 1 - fi - jq --arg version "${VERSION_TAG#v}" '.version = $version' electron/package.json > /tmp/package.json - mv /tmp/package.json electron/package.json - env: - VERSION_TAG: ${{ steps.tag.outputs.tag }} - - - name: Install yarn dependencies - run: | - yarn install - yarn build:plugins - - - name: Build and publish app - run: | - yarn build:publish - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - diff --git a/electron/core/plugins/data-plugin/package.json b/electron/core/plugins/data-plugin/package.json index b0e87ce1e..11d1512bf 100644 --- a/electron/core/plugins/data-plugin/package.json +++ b/electron/core/plugins/data-plugin/package.json @@ -11,7 +11,7 @@ ], "scripts": { "build": "tsc -b . && webpack --config webpack.config.js", - "build:package": "rimraf ./data-plugin*.tgz && npm run build && npm pack", + "build:package": "rimraf ./data-plugin*.tgz && node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --target_libc=unknown --target_arch=x64 && node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=darwin --target_libc=unknown --target_arch=arm64 && node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --target_libc=glibc --target_arch=x64 && node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=linux --target_libc=musl --target_arch=x64 && node-pre-gyp install --directory=./node_modules/sqlite3 --target_platform=win32 --target_libc=unknown --target_arch=x64 && npm run build && npm pack", "build:publish": "npm run build:package && cpx *.tgz ../../pre-install" }, "exports": { @@ -37,6 +37,7 @@ "node_modules" ], "dependencies": { + "node-pre-gyp": "^0.17.0", "sqlite3": "^5.1.6" } } diff --git a/electron/core/plugins/inference-plugin/module.js b/electron/core/plugins/inference-plugin/module.js index c4da0f627..2d6b8ca5c 100644 --- a/electron/core/plugins/inference-plugin/module.js +++ b/electron/core/plugins/inference-plugin/module.js @@ -48,10 +48,19 @@ async function initModel(product) { // Write the updated config back to the file fs.writeFileSync(configFilePath, JSON.stringify(config, null, 4)); - const binaryPath = - process.platform === "win32" - ? path.join(binaryFolder, "nitro.exe") - : path.join(binaryFolder, "nitro"); + let binaryName; + + if (process.platform === "win32") { + binaryName = "nitro.exe"; + } else if (process.platform === "darwin") { // Mac OS platform + binaryName = process.arch === "arm64" ? "nitro" : "nitro_mac_intel"; + } else { + // Linux + binaryName = "nitro_linux"; // For other platforms + } + + const binaryPath = path.join(binaryFolder, binaryName); + // Execute the binary subprocess = spawn(binaryPath, [configFilePath], { cwd: binaryFolder }); diff --git a/electron/core/plugins/inference-plugin/nitro/nitro_linux b/electron/core/plugins/inference-plugin/nitro/nitro_linux new file mode 100755 index 000000000..380c8ab0d Binary files /dev/null and b/electron/core/plugins/inference-plugin/nitro/nitro_linux differ diff --git a/electron/core/plugins/inference-plugin/nitro/nitro_mac_intel b/electron/core/plugins/inference-plugin/nitro/nitro_mac_intel new file mode 100755 index 000000000..2f55b4c86 Binary files /dev/null and b/electron/core/plugins/inference-plugin/nitro/nitro_mac_intel differ diff --git a/electron/core/plugins/inference-plugin/package.json b/electron/core/plugins/inference-plugin/package.json index 3bf6cf614..f04990ed4 100644 --- a/electron/core/plugins/inference-plugin/package.json +++ b/electron/core/plugins/inference-plugin/package.json @@ -11,7 +11,7 @@ ], "scripts": { "build": "webpack --config webpack.config.js", - "build:package": "rimraf ./*.tgz && npm run build && cpx \"module.js\" \"dist\" && rm -rf dist/nitro && cp -r nitro dist/nitro && npm pack", + "build:package": "rimraf ./*.tgz && npm run build && cpx \"module.js\" \"dist\" && rimraf dist/nitro/* && cpx \"nitro/**\" \"dist/nitro\" && npm pack", "build:publish": "yarn build:package && cpx *.tgz ../../pre-install" }, "devDependencies": { diff --git a/electron/package.json b/electron/package.json index 53672388f..963be951d 100644 --- a/electron/package.json +++ b/electron/package.json @@ -1,8 +1,8 @@ { "name": "jan-electron", - "version": "0.1.1", + "version": "0.1.3", "main": "./build/main.js", - "author": "Jan", + "author": "Jan ", "license": "MIT", "homepage": "./", "build": { @@ -12,7 +12,8 @@ "renderer/**/*", "build/*.{js,map}", "build/**/*.{js,map}", - "core/pre-install" + "core/pre-install", + "core/plugin-manager/facade" ], "asarUnpack": [ "core/pre-install" @@ -32,9 +33,14 @@ "scripts": { "lint": "eslint . --ext \".js,.jsx,.ts,.tsx\"", "dev": "tsc -p . && electron .", - "build": "tsc -p . && electron-builder -p never -mw", - "build:publish": "tsc -p . && electron-builder -p onTagOrDraft -mw", - "postinstall": "electron-builder install-app-deps" + "build": "tsc -p . && electron-builder -p never -m", + "build:darwin": "tsc -p . && electron-builder -p never -m --x64 --arm64", + "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 " }, "dependencies": { "@npmcli/arborist": "^7.1.0", diff --git a/package.json b/package.json index 5b7c70571..836b6cfef 100644 --- a/package.json +++ b/package.json @@ -19,14 +19,21 @@ "dev": "concurrently --kill-others \"yarn dev:web\" \"wait-on http://localhost:3000 && yarn dev:electron\"", "build:web": "yarn workspace jan-web build && cpx \"web/out/**\" \"electron/renderer/\"", "build:electron": "yarn workspace jan-electron build", - "build:plugins": "rm -f ./electron/core/pre-install/*.tgz && concurrently \"cd ./electron/core/plugins/data-plugin && npm install && npm run build:publish\" \"cd ./electron/core/plugins/inference-plugin && npm install && npm run build:publish\" \"cd ./electron/core/plugins/model-management-plugin && npm install && npm run build:publish\" \"cd ./electron/core/plugins/monitoring-plugin && npm install && npm run build:publish\"", + "build:plugins": "rimraf ./electron/core/pre-install/*.tgz && concurrently \"cd ./electron/core/plugins/data-plugin && npm install && npm run build:publish\" \"cd ./electron/core/plugins/inference-plugin && npm install && npm run build:publish\" \"cd ./electron/core/plugins/model-management-plugin && npm install && npm run build:publish\" \"cd ./electron/core/plugins/monitoring-plugin && npm install && npm run build:publish\"", "build": "yarn build:web && yarn build:electron", - "build:publish": "yarn build:web && yarn workspace jan-electron build:publish" + "build:darwin": "yarn build:web && yarn workspace jan-electron build:darwin", + "build:win32": "yarn build:web && yarn workspace jan-electron build:win32", + "build:linux": "yarn build:web && yarn workspace jan-electron build:linux", + "build:publish": "yarn build:web && yarn workspace jan-electron build:publish", + "build:publish-darwin": "yarn build:web && yarn workspace jan-electron build:publish-darwin", + "build:publish-win32": "yarn build:web && yarn workspace jan-electron build:publish-win32", + "build:publish-linux": "yarn build:web && yarn workspace jan-electron build:publish-linux" }, "devDependencies": { "concurrently": "^8.2.1", "cpx": "^1.5.0", - "wait-on": "^7.0.1" + "wait-on": "^7.0.1", + "rimraf": "^3.0.2" }, "version": "0.0.0" }