From be3cffa53ffd7948cb902df7b9d1c0d576c01872 Mon Sep 17 00:00:00 2001 From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com> Date: Tue, 15 Mar 2022 19:25:47 +0100 Subject: [PATCH] [hopefully] add an auto-updater --- build/entitlements.mac.plist | 14 ++++++++++++++ build/notarize.js | 30 ++++++++++++++++++++++++++++++ package.json | 24 +++++++++++++++++++++--- src/index.js | 8 ++++++++ 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 build/entitlements.mac.plist create mode 100644 build/notarize.js diff --git a/build/entitlements.mac.plist b/build/entitlements.mac.plist new file mode 100644 index 0000000..ad77a2a --- /dev/null +++ b/build/entitlements.mac.plist @@ -0,0 +1,14 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.disable-library-validation + + + \ No newline at end of file diff --git a/build/notarize.js b/build/notarize.js new file mode 100644 index 0000000..c1f4d0d --- /dev/null +++ b/build/notarize.js @@ -0,0 +1,30 @@ +const { notarize } = require('electron-notarize') +const path = require('path') + +exports.default = async function notarizing (context) { + if (context.electronPlatformName !== 'darwin' || process.env.CSC_IDENTITY_AUTO_DISCOVERY === 'false') { + console.log('Skipping notarization') + return + } + console.log('Notarizing...') + + const appBundleId = context.packager.appInfo.info._configuration.appId + const appName = context.packager.appInfo.productFilename + const appPath = path.normalize(path.join(context.appOutDir, `${appName}.app`)) + const appleId = process.env.APPLE_ID + const appleIdPassword = process.env.APPLE_ID_PASSWORD + if (!appleId) { + console.warn('Not notarizing: Missing APPLE_ID environment variable') + return + } + if (!appleIdPassword) { + console.warn('Not notarizing: Missing APPLE_ID_PASSWORD environment variable') + return + } + return notarize({ + appBundleId, + appPath, + appleId, + appleIdPassword + }) +} diff --git a/package.json b/package.json index 3be5f6e..4ef4deb 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "name": "Miru", - "version": "0.5.3", + "version": "0.6.0", "author": "ThaUnknown_", "main": "src/index.js", "scripts": { "start": "SET NODE_ENV=development & concurrently \"npm run web:watch\" \"npm run electron:start\"", "web:watch": "vite", "electron:start": "electron src", - "build": "vite build && electron-builder" + "build": "vite build && electron-builder", + "publish": "vite build && electron-builder -p always" }, "devDependencies": { "@sveltejs/vite-plugin-svelte": "^1.0.0-next.30", @@ -15,6 +16,7 @@ "concurrently": "^7.0.0", "electron": "^16.0.10", "electron-builder": "^22.14.13", + "electron-notarize": "^1.1.1", "svelte": "^3.46.4", "vite": "^2.8.6", "vite-plugin-commonjs-externals": "^0.1.1" @@ -27,18 +29,32 @@ "env": "browser" }, "build": { + "publish": [ + { + "provider": "github", + "owner": "ThaUnknown", + "repo": "miru" + } + ], + "afterSign": "./build/notarize.js", + "appId": "com.github.thaunknown.miru", "productName": "Miru", "files": [ "src/**/*" ], + "mac": { + "category": "public.app-category.video" + }, "win": { "target": "nsis", "icon": "src/renderer/public/logo.ico" }, "linux": { + "category": "Video", "target": "AppImage" }, "nsis": { + "oneClick": false, "installerIcon": "src/renderer/public/logo.ico", "installerHeaderIcon": "src/renderer/public/logo.ico" } @@ -46,7 +62,9 @@ "dependencies": { "@electron/remote": "^2.0.7", "anitomyscript": "^2.0.4", + "electron-log": "^4.4.6", + "electron-updater": "^4.6.5", "matroska-subtitles": "^3.3.2", "webtorrent": "^1.5.0" } -} +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 9063dde..4cfb93b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,12 @@ const { app, BrowserWindow, protocol } = require('electron') const path = require('path') const remote = require('@electron/remote/main') +const log = require('electron-log') +const { autoUpdater } = require('electron-updater') + +autoUpdater.logger = log +autoUpdater.logger.transports.file.level = 'info' + remote.initialize() // Keep a global reference of the window object, if you don't, the window will @@ -22,6 +28,8 @@ function UpsertKeyValue (obj, keyToChange, value) { } function createWindow () { + autoUpdater.checkForUpdatesAndNotify() + // Create the browser window. mainWindow = new BrowserWindow({ width: 1600,