From cc12becdaed2b4096de90648c97b0ba74a93a19b Mon Sep 17 00:00:00 2001 From: Tom JEANNESSON Date: Thu, 14 Mar 2024 16:27:59 +0100 Subject: [PATCH 1/6] feat(electron): build --- .github/workflows/deploy.yml | 38 +++++++++++++++++++ desktop-app/electron-builder.yml | 4 ++ desktop-app/main/background.ts | 31 ++++++++++++++- desktop-app/main/helpers/aws/deployToAWS.ts | 1 - desktop-app/package.json | 5 +-- .../custom/selectedObject/inputs.tsx | 6 +-- .../custom/selectedObject/selectedObject.tsx | 1 + desktop-app/renderer/lib/localStorage.ts | 2 + .../renderer/pages/servers/[slug]/index.tsx | 9 ++++- desktop-app/renderer/pages/settings/index.tsx | 2 +- makefile | 2 +- package.json | 2 +- 12 files changed, 88 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..dd28c173 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,38 @@ +name: Deploy to Github Releases + +on: + release: + types: [published] + + + +jobs: + release: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [macos-latest, ubuntu-latest, windows-latest] + + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.x + + + - name: Build/release Electron app + uses: samuelmeuli/action-electron-builder@v1 + with: + # GitHub token, automatically provided to the action + # (No need to define this secret in the repo settings) + github_token: ${{ secrets.github_token }} + + # If the commit is tagged with a version (e.g. "v1.0.0"), + # release the app after building + release: ${{ startsWith(github.ref, 'refs/tags/v') }} \ No newline at end of file diff --git a/desktop-app/electron-builder.yml b/desktop-app/electron-builder.yml index 87c1822f..bc0caf0e 100644 --- a/desktop-app/electron-builder.yml +++ b/desktop-app/electron-builder.yml @@ -10,4 +10,8 @@ files: - package.json - app +linux: + target: deb + + publish: null diff --git a/desktop-app/main/background.ts b/desktop-app/main/background.ts index 649aba87..a39ab4f0 100644 --- a/desktop-app/main/background.ts +++ b/desktop-app/main/background.ts @@ -1,5 +1,5 @@ import { EnvironmentStatus } from '@aws-sdk/client-elastic-beanstalk' -import { BrowserWindow, app, ipcMain } from 'electron' +import { BrowserWindow, app, autoUpdater, dialog, ipcMain } from 'electron' import serve from 'electron-serve' import { EB_APP_NAME, @@ -25,6 +25,35 @@ if (isProd) { ;(async () => { await app.whenReady() + if (isProd) { + const server = 'https://hazel-c8oqh794d-napse-investment.vercel.app/' + const url = `${server}/update/${process.platform}/${app.getVersion()}` + + autoUpdater.setFeedURL({ url }) + setInterval(() => { + autoUpdater.checkForUpdates() + }, 60000) + autoUpdater.on('update-downloaded', (event, releaseNotes, releaseName) => { + const dialogOpts = { + type: 'info', + buttons: ['Restart', 'Later'], + title: 'Application Update', + message: process.platform === 'win32' ? releaseNotes : releaseName, + detail: + 'A new version has been downloaded. Restart the application to apply the updates.' + } + + dialog.showMessageBox(dialogOpts).then((returnValue) => { + if (returnValue.response === 0) autoUpdater.quitAndInstall() + }) + console.log('update-downloaded') + }) + autoUpdater.on('error', (message) => { + console.error('There was a problem updating the application') + console.error(message) + }) + } + const mainWindow = createWindow('main', { width: 1000, height: 600 diff --git a/desktop-app/main/helpers/aws/deployToAWS.ts b/desktop-app/main/helpers/aws/deployToAWS.ts index 73f0516e..66000647 100644 --- a/desktop-app/main/helpers/aws/deployToAWS.ts +++ b/desktop-app/main/helpers/aws/deployToAWS.ts @@ -40,7 +40,6 @@ export const IAM_INSTANCE_PROFILE_NAME = `napse-iam-instance-profile${ process.env.NODE_ENV === 'production' ? '' : '-dev' }` -console.log('EB_BUCKET_NAME', EB_BUCKET_NAME) export default async function Main( secrets: { AWS__API_TOKEN: string diff --git a/desktop-app/package.json b/desktop-app/package.json index 0f682ef7..48fc4201 100644 --- a/desktop-app/package.json +++ b/desktop-app/package.json @@ -3,18 +3,17 @@ "name": "napse", "description": "Napse Desktop App", "homepage": "https://napse-invest.com", - "version": "1.4.0", + "version": "1.5.0", "author": "Napse Invest ", "main": "app/background.js", "scripts": { "start": "nextron", - "build": "nextron build", + "build": "nextron build --mac --linux --win --x64", "build:mac": "nextron build --mac", "build:mac:universal": "nextron build --mac --universal", "build:linux": "nextron build --linux", "build:win32": "nextron build --win --ia32", "build:win64": "nextron build --win --x64", - "build:all": "nextron build --mac --linux --win --x64", "postinstall": "electron-builder install-app-deps", "lint": "next lint" }, diff --git a/desktop-app/renderer/components/custom/selectedObject/inputs.tsx b/desktop-app/renderer/components/custom/selectedObject/inputs.tsx index c10151d1..c01a11bd 100644 --- a/desktop-app/renderer/components/custom/selectedObject/inputs.tsx +++ b/desktop-app/renderer/components/custom/selectedObject/inputs.tsx @@ -112,8 +112,7 @@ export default function CustomForm({ return (
- {/* */} - + {inputs.map((input, index) => { return ( ({ ) : (