Skip to content

Commit

Permalink
[hopefully] add an auto-updater
Browse files Browse the repository at this point in the history
  • Loading branch information
ThaUnknown committed Mar 15, 2022
1 parent c7cb3c4 commit be3cffa
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 3 deletions.
14 changes: 14 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
30 changes: 30 additions & 0 deletions build/notarize.js
Original file line number Diff line number Diff line change
@@ -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
})
}
24 changes: 21 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
{
"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",
"builtin-modules": "^3.2.0",
"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"
Expand All @@ -27,26 +29,42 @@
"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"
}
},
"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"
}
}
}
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -22,6 +28,8 @@ function UpsertKeyValue (obj, keyToChange, value) {
}

function createWindow () {
autoUpdater.checkForUpdatesAndNotify()

// Create the browser window.
mainWindow = new BrowserWindow({
width: 1600,
Expand Down

0 comments on commit be3cffa

Please sign in to comment.