Chore: refactor to makefile (#691)
* Add makefile for jan * CICD switchs to use make * Update README.md to use Makefile --------- Co-authored-by: Hien To <hien@jan.ai>
This commit is contained in:
parent
7222ea553f
commit
df163a85e5
74
.github/workflows/jan-electron-build.yml
vendored
74
.github/workflows/jan-electron-build.yml
vendored
@ -28,12 +28,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Update app version base on tag
|
- name: Update app version base on tag
|
||||||
run: |
|
run: |
|
||||||
if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
make update-app-version
|
||||||
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:
|
env:
|
||||||
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
||||||
|
|
||||||
@ -49,25 +44,9 @@ jobs:
|
|||||||
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
|
p12-file-base64: ${{ secrets.CODE_SIGN_P12_BASE64 }}
|
||||||
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
|
p12-password: ${{ secrets.CODE_SIGN_P12_PASSWORD }}
|
||||||
|
|
||||||
|
|
||||||
- name: Build uikit
|
|
||||||
run: |
|
|
||||||
cd uikit
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
- name: Install yarn dependencies
|
|
||||||
run: |
|
|
||||||
yarn build:core
|
|
||||||
yarn install
|
|
||||||
yarn build:plugins
|
|
||||||
env:
|
|
||||||
APP_PATH: "."
|
|
||||||
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
|
|
||||||
|
|
||||||
- name: Build and publish app
|
- name: Build and publish app
|
||||||
run: |
|
run: |
|
||||||
yarn build:publish
|
make build-and-publish
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
CSC_LINK: "/tmp/codesign.p12"
|
CSC_LINK: "/tmp/codesign.p12"
|
||||||
@ -75,6 +54,8 @@ jobs:
|
|||||||
CSC_IDENTITY_AUTO_DISCOVERY: "true"
|
CSC_IDENTITY_AUTO_DISCOVERY: "true"
|
||||||
APPLE_ID: ${{ secrets.APPLE_ID }}
|
APPLE_ID: ${{ secrets.APPLE_ID }}
|
||||||
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
|
APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.APPLE_APP_SPECIFIC_PASSWORD }}
|
||||||
|
APP_PATH: "."
|
||||||
|
DEVELOPER_ID: ${{ secrets.DEVELOPER_ID }}
|
||||||
|
|
||||||
build-windows-x64:
|
build-windows-x64:
|
||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
@ -99,34 +80,13 @@ jobs:
|
|||||||
- name: Update app version base on tag
|
- name: Update app version base on tag
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
make update-app-version
|
||||||
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:
|
env:
|
||||||
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
||||||
|
|
||||||
- name: Build uikit
|
|
||||||
run: |
|
|
||||||
cd uikit
|
|
||||||
yarn config set network-timeout 300000
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
- name: Install yarn dependencies
|
|
||||||
shell: powershell
|
|
||||||
run: |
|
|
||||||
yarn config set network-timeout 300000
|
|
||||||
yarn build:core
|
|
||||||
yarn install
|
|
||||||
$env:NITRO_VERSION = Get-Content .\plugins\inference-plugin\nitro\version.txt; echo $env:NITRO_VERSION
|
|
||||||
yarn build:plugins
|
|
||||||
|
|
||||||
- name: Build and publish app
|
- name: Build and publish app
|
||||||
run: |
|
run: |
|
||||||
yarn build:publish
|
make build-and-publish
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
@ -158,31 +118,13 @@ jobs:
|
|||||||
|
|
||||||
- name: Update app version base on tag
|
- name: Update app version base on tag
|
||||||
run: |
|
run: |
|
||||||
if [[ ! "${VERSION_TAG}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
make update-app-version
|
||||||
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:
|
env:
|
||||||
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
VERSION_TAG: ${{ steps.tag.outputs.tag }}
|
||||||
|
|
||||||
- name: Build uikit
|
|
||||||
run: |
|
|
||||||
cd uikit
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
- name: Install yarn dependencies
|
|
||||||
run: |
|
|
||||||
yarn config set network-timeout 300000
|
|
||||||
yarn build:core
|
|
||||||
yarn install
|
|
||||||
yarn build:plugins
|
|
||||||
|
|
||||||
- name: Build and publish app
|
- name: Build and publish app
|
||||||
run: |
|
run: |
|
||||||
yarn build:publish
|
make build-and-publish
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
|||||||
@ -43,21 +43,9 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
|
|
||||||
- name: Build uikit
|
|
||||||
run: |
|
|
||||||
cd uikit
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
- name: Linter and test
|
- name: Linter and test
|
||||||
run: |
|
run: |
|
||||||
yarn config set network-timeout 300000
|
make test
|
||||||
yarn build:core
|
|
||||||
yarn install
|
|
||||||
yarn lint
|
|
||||||
yarn build:plugins
|
|
||||||
yarn build:test
|
|
||||||
yarn test
|
|
||||||
env:
|
env:
|
||||||
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
CSC_IDENTITY_AUTO_DISCOVERY: "false"
|
||||||
|
|
||||||
@ -81,24 +69,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
|
|
||||||
- name: Build uikit
|
|
||||||
run: |
|
|
||||||
yarn config set network-timeout 300000
|
|
||||||
cd uikit
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
- name: Linter and test
|
- name: Linter and test
|
||||||
shell: powershell
|
shell: powershell
|
||||||
run: |
|
run: |
|
||||||
yarn config set network-timeout 300000
|
make test
|
||||||
yarn build:core
|
|
||||||
yarn install
|
|
||||||
$env:NITRO_VERSION = Get-Content .\plugins\inference-plugin\nitro\version.txt; echo $env:NITRO_VERSION
|
|
||||||
yarn build:plugins
|
|
||||||
yarn build:test
|
|
||||||
$env:CI="e2e"
|
|
||||||
yarn test
|
|
||||||
|
|
||||||
test-on-ubuntu:
|
test-on-ubuntu:
|
||||||
runs-on: [self-hosted, Linux, ubuntu-desktop]
|
runs-on: [self-hosted, Linux, ubuntu-desktop]
|
||||||
@ -118,19 +92,8 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
node-version: 20
|
node-version: 20
|
||||||
|
|
||||||
- name: Build uikit
|
|
||||||
run: |
|
|
||||||
cd uikit
|
|
||||||
yarn install
|
|
||||||
yarn build
|
|
||||||
|
|
||||||
- name: Linter and test
|
- name: Linter and test
|
||||||
run: |
|
run: |
|
||||||
export DISPLAY=$(w -h | awk 'NR==1 {print $2}')
|
export DISPLAY=$(w -h | awk 'NR==1 {print $2}')
|
||||||
echo -e "Display ID: $DISPLAY"
|
echo -e "Display ID: $DISPLAY"
|
||||||
yarn config set network-timeout 300000
|
make test
|
||||||
yarn build:core
|
|
||||||
yarn install
|
|
||||||
yarn build:plugins
|
|
||||||
yarn build:test
|
|
||||||
yarn test
|
|
||||||
|
|||||||
62
Makefile
Normal file
62
Makefile
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
# Makefile for Jan Electron App - Build, Lint, Test, and Clean
|
||||||
|
|
||||||
|
# Default target, does nothing
|
||||||
|
all:
|
||||||
|
@echo "Specify a target to run"
|
||||||
|
|
||||||
|
# Builds the UI kit
|
||||||
|
build-uikit:
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
cd uikit && yarn config set network-timeout 300000 && yarn install && yarn build
|
||||||
|
else
|
||||||
|
cd uikit && yarn install && yarn build
|
||||||
|
endif
|
||||||
|
# Updates the app version based on the tag
|
||||||
|
update-app-version:
|
||||||
|
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
|
||||||
|
|
||||||
|
# Installs yarn dependencies and builds core and plugins
|
||||||
|
install-and-build: build-uikit
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
powershell -Command "yarn config set network-timeout 300000; \
|
||||||
|
$$env:NITRO_VERSION = Get-Content .\\plugins\\inference-plugin\\nitro\\version.txt; \
|
||||||
|
Write-Output \"Nitro version: $$env:NITRO_VERSION\"; yarn build:core; yarn install; yarn build:plugins"
|
||||||
|
else
|
||||||
|
yarn build:core
|
||||||
|
yarn install
|
||||||
|
yarn build:plugins
|
||||||
|
endif
|
||||||
|
|
||||||
|
dev: install-and-build
|
||||||
|
yarn dev
|
||||||
|
|
||||||
|
# Linting
|
||||||
|
lint: install-and-build
|
||||||
|
yarn lint
|
||||||
|
|
||||||
|
# Testing
|
||||||
|
test: lint
|
||||||
|
yarn build:test
|
||||||
|
yarn test
|
||||||
|
|
||||||
|
# Builds and publishes the app
|
||||||
|
build-and-publish: install-and-build
|
||||||
|
yarn build:publish
|
||||||
|
|
||||||
|
# Build
|
||||||
|
build: install-and-build
|
||||||
|
yarn build
|
||||||
|
|
||||||
|
clean:
|
||||||
|
ifeq ($(OS),Windows_NT)
|
||||||
|
powershell -Command "Get-ChildItem -Path . -Include node_modules, .next, dist -Recurse -Directory | Remove-Item -Recurse -Force"
|
||||||
|
else
|
||||||
|
find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
|
||||||
|
find . -name ".next" -type d -exec rm -rf '{}' +
|
||||||
|
find . -name "dist" -type d -exec rm -rf '{}' +
|
||||||
|
endif
|
||||||
34
README.md
34
README.md
@ -91,11 +91,10 @@ Contributions are welcome! Please read the [CONTRIBUTING.md](CONTRIBUTING.md) fi
|
|||||||
|
|
||||||
- node >= 20.0.0
|
- node >= 20.0.0
|
||||||
- yarn >= 1.22.0
|
- yarn >= 1.22.0
|
||||||
|
- make >= 3.81
|
||||||
|
|
||||||
### Instructions
|
### Instructions
|
||||||
|
|
||||||
Note: This instruction is tested on MacOS only.
|
|
||||||
|
|
||||||
1. **Clone the Repository:**
|
1. **Clone the Repository:**
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@ -104,25 +103,10 @@ Note: This instruction is tested on MacOS only.
|
|||||||
cd jan
|
cd jan
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **Install dependencies:**
|
2. **Run development and Using Jan Desktop**
|
||||||
|
|
||||||
```bash
|
|
||||||
yarn install
|
|
||||||
|
|
||||||
# Build core module
|
|
||||||
yarn build:core
|
|
||||||
|
|
||||||
# Packing base plugins
|
|
||||||
yarn build:plugins
|
|
||||||
|
|
||||||
# Packing uikit
|
|
||||||
yarn build:uikit
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Run development and Using Jan Desktop**
|
|
||||||
|
|
||||||
```
|
```
|
||||||
yarn dev
|
make dev
|
||||||
```
|
```
|
||||||
|
|
||||||
This will start the development server and open the desktop app.
|
This will start the development server and open the desktop app.
|
||||||
@ -134,19 +118,9 @@ Note: This instruction is tested on MacOS only.
|
|||||||
# Do step 1 and 2 in previous section
|
# Do step 1 and 2 in previous section
|
||||||
git clone https://github.com/janhq/jan
|
git clone https://github.com/janhq/jan
|
||||||
cd jan
|
cd jan
|
||||||
yarn install
|
|
||||||
|
|
||||||
# Build core module
|
|
||||||
yarn build:core
|
|
||||||
|
|
||||||
# Package base plugins
|
|
||||||
yarn build:plugins
|
|
||||||
|
|
||||||
# Packing uikit
|
|
||||||
yarn build:uikit
|
|
||||||
|
|
||||||
# Build the app
|
# Build the app
|
||||||
yarn build
|
make build
|
||||||
```
|
```
|
||||||
|
|
||||||
This will build the app MacOS m1/m2 for production (with code signing already done) and put the result in `dist` folder.
|
This will build the app MacOS m1/m2 for production (with code signing already done) and put the result in `dist` folder.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user