diff --git a/.github/workflows/release-dev.yml b/.github/workflows/release-dev.yml new file mode 100644 index 000000000..167afc71c --- /dev/null +++ b/.github/workflows/release-dev.yml @@ -0,0 +1,47 @@ +name: Release dev + +on: + push: + branches: [ main ] + +defaults: + run: + working-directory: ./ + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use nx set shas + uses: nrwl/nx-set-shas@v3 + + - name: Setup Node version + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: false + registry-url: https://registry.npmjs.org + cache: "npm" + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: | + npm cache verify + npm ci --no-audit --prefer-offline + + - name: Run NX build on shinkai-visor + run: npx nx build shinkai-visor --skip-nx-cache --verbose + env: + VERSION: 0.0.0.${{github.run_number}} + + - uses: actions/upload-artifact@v3 + with: + name: shinkai-visor + path: dist/apps/shinkai-visor + if-no-files-found: error + retention-days: 5 diff --git a/.vscode/settings.json b/.vscode/settings.json index 075360698..31acfd016 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -2,5 +2,11 @@ "editor.codeActionsOnSave": { "source.fixAll.eslint": true }, - "editor.tabSize": 2 + "editor.tabSize": 2, + "json.schemas": [ + { + "fileMatch": ["manifest.json"], + "url": "https://json.schemastore.org/chrome-manifest.json" + } + ] } diff --git a/apps/shinkai-visor/dynamic-manifest.ts b/apps/shinkai-visor/dynamic-manifest.ts new file mode 100644 index 000000000..6f3ad7fb1 --- /dev/null +++ b/apps/shinkai-visor/dynamic-manifest.ts @@ -0,0 +1,19 @@ +import { defineManifest } from '@crxjs/vite-plugin' + +import baseManifestJson from './public/manifest.json'; + + +const getVersion = () => { + const version = process.env.VERSION || baseManifestJson.version || '0.0.0.0'; + const [major, minor, patch, label = '0'] = version + .replace(/[^\d.-]+/g, '') + .split(/[.-]/); + return `${major}.${minor}.${patch}.${label}`; +}; + +export const dynamicManifest = defineManifest((env) => { + return { + ...baseManifestJson, + version: getVersion(), + }; +}); diff --git a/apps/shinkai-visor/vite.config.ts b/apps/shinkai-visor/vite.config.ts index bd5619a77..5ffb60074 100644 --- a/apps/shinkai-visor/vite.config.ts +++ b/apps/shinkai-visor/vite.config.ts @@ -1,14 +1,12 @@ /// -import { crx,ManifestV3Export } from "@crxjs/vite-plugin"; +import { crx } from "@crxjs/vite-plugin"; import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; import topLevelAwait from "vite-plugin-top-level-await"; import wasm from 'vite-plugin-wasm'; -import manifestJson from './public/manifest.json'; - -const manifest = manifestJson as ManifestV3Export; +import { dynamicManifest } from './dynamic-manifest'; export default defineConfig({ cacheDir: '../../node_modules/.vite/shinkai-visor', @@ -27,7 +25,13 @@ export default defineConfig({ host: 'localhost', }, - plugins: [react(), nxViteTsPaths(), wasm({ bundle: true }), topLevelAwait(), crx({ manifest })], + plugins: [ + react(), + nxViteTsPaths(), + wasm({ bundle: true }), + topLevelAwait(), + crx({ manifest: dynamicManifest }), + ], test: { globals: true,