Feature CICD for MacOS and Windows (#263)
* Separate CICD into multi platform * Update yarn script to build multi-platform and arch --------- Co-authored-by: Hien To <tominhhien97@gmail.com> Co-authored-by: Hien To <>
This commit is contained in:
parent
4275da972e
commit
517d651871
151
.github/workflows/build-app.yml
vendored
Normal file
151
.github/workflows/build-app.yml
vendored
Normal file
@ -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 }}
|
||||
50
.github/workflows/macos-build-app.yml
vendored
50
.github/workflows/macos-build-app.yml
vendored
@ -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 }}
|
||||
|
||||
@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@ -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 });
|
||||
|
||||
BIN
electron/core/plugins/inference-plugin/nitro/nitro_linux
Executable file
BIN
electron/core/plugins/inference-plugin/nitro/nitro_linux
Executable file
Binary file not shown.
BIN
electron/core/plugins/inference-plugin/nitro/nitro_mac_intel
Executable file
BIN
electron/core/plugins/inference-plugin/nitro/nitro_mac_intel
Executable file
Binary file not shown.
@ -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": {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
{
|
||||
"name": "jan-electron",
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.3",
|
||||
"main": "./build/main.js",
|
||||
"author": "Jan",
|
||||
"author": "Jan <service@jan.ai>",
|
||||
"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",
|
||||
|
||||
13
package.json
13
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"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user