mirror of
https://github.com/kopia/kopia.git
synced 2026-10-23 06:38:42 -04:00
kopia-ui: support for auto-update and publishing prerelease binaries from Travis to kopia/kopia-ui-release
This commit is contained in:
1 parent
995b1cef40
commit
98f1b26f39
5 files changed
+702
-412
No files matched your search
@@ -60,22 +60,8 @@ html-ui-bindata: html-ui $(go_bindata)
|
||||
html-ui-bindata-fallback: $(go_bindata)
|
||||
(cd internal/server && $(go_bindata) -fs -tags !embedhtml -o "$(CURDIR)/internal/server/htmlui_fallback.go" -pkg server index.html)
|
||||
|
||||
# by default build unpacked Kopia UI for current OS only
|
||||
KOPIA_UI_BUILD_TARGET=build-electron-dir
|
||||
|
||||
ifneq ($(TRAVIS_OS_NAME),)
|
||||
# on Travis, also build the setup package.
|
||||
KOPIA_UI_BUILD_TARGET=build-electron
|
||||
endif
|
||||
|
||||
ifeq ($(TRAVIS_OS_NAME),windows)
|
||||
# disable Kopia UI code siging.
|
||||
undefine CSC_LINK
|
||||
undefine CSC_KEY_PASSWORD
|
||||
endif
|
||||
|
||||
kopia-ui: goreleaser
|
||||
$(MAKE) -C app $(KOPIA_UI_BUILD_TARGET)
|
||||
$(MAKE) -C app build-electron
|
||||
|
||||
ifeq ($(TRAVIS_OS_NAME),windows)
|
||||
travis-release: install kopia-ui
|
||||
|
||||
+36
-4
@@ -1,4 +1,39 @@
|
||||
SHELL:=/bin/bash
|
||||
REPO_OWNER=kopia
|
||||
|
||||
electron_builder_flags:=
|
||||
|
||||
ifeq ($(TRAVIS_PULL_REQUEST),false)
|
||||
|
||||
electron_builder_flags+=-p always
|
||||
|
||||
ifneq ($(TRAVIS_TAG),)
|
||||
# tagged release - create draft release, but don't publish
|
||||
electron_builder_flags+=-c.extraMetadata.version=$(TRAVIS_TAG:v%=%)
|
||||
electron_builder_flags+=-c.publish.releaseType=draft
|
||||
electron_builder_flags+=-c.publish.owner=$(REPO_OWNER)
|
||||
electron_builder_flags+=-c.publish.repo=kopia
|
||||
else
|
||||
# post-submit run, create a release in another repo
|
||||
electron_builder_flags+=-c.extraMetadata.version=$(shell date +%y%m%d.%H.%M)-pre-$(shell echo $(TRAVIS_COMMIT) | cut -b 1-8)
|
||||
electron_builder_flags+=-c.publish.owner=$(REPO_OWNER)
|
||||
electron_builder_flags+=-c.publish.repo=kopia-ui-release
|
||||
electron_builder_flags+=-c.publish.releaseType=release
|
||||
endif
|
||||
|
||||
else
|
||||
|
||||
# not running on Travis, or Travis in PR mode, don't build installer and don't publish
|
||||
electron_builder_flags+=--dir
|
||||
electron_builder_flags+=-p never
|
||||
|
||||
endif
|
||||
|
||||
ifeq ($(TRAVIS_OS_NAME),windows)
|
||||
# disable Kopia UI code signing on Windows.
|
||||
undefine CSC_LINK
|
||||
undefine CSC_KEY_PASSWORD
|
||||
endif
|
||||
|
||||
dev: node_modules
|
||||
$(npm) $(npm_flags) run dev
|
||||
@@ -9,11 +44,8 @@ run: build-html
|
||||
build-html: node_modules
|
||||
$(npm) $(npm_flags) run build-html
|
||||
|
||||
build-electron-dir: node_modules build-html
|
||||
$(npm) $(npm_flags) run build-electron-dir
|
||||
|
||||
build-electron: node_modules build-html
|
||||
$(npm) $(npm_flags) run build-electron
|
||||
$(npm) $(npm_flags) run build-electron -- $(electron_builder_flags)
|
||||
|
||||
include ../tools/tools.mk
|
||||
|
||||
|
||||
Generated
+625
-388
File diff suppressed because it is too large.
Load diff
+4
-2
@@ -8,6 +8,8 @@
|
||||
"bootstrap": "^4.3.1",
|
||||
"electron-is-dev": "^1.1.0",
|
||||
"electron-json-config": "^1.5.3",
|
||||
"electron-log": "^4.0.6",
|
||||
"electron-updater": "^4.2.2",
|
||||
"react": "^16.12.0",
|
||||
"react-bootstrap": "^1.0.0-beta.14",
|
||||
"react-dom": "^16.12.0",
|
||||
@@ -79,8 +81,8 @@
|
||||
"devDependencies": {
|
||||
"asar": "^2.0.3",
|
||||
"concurrently": "^5.0.0",
|
||||
"electron": "^7.1.2",
|
||||
"electron-builder": "^21.2.0"
|
||||
"electron": "^7.1.12",
|
||||
"electron-builder": "^22.2.0"
|
||||
},
|
||||
"homepage": "./",
|
||||
"main": "public/electron.js",
|
||||
|
||||
+36
-3
@@ -1,12 +1,12 @@
|
||||
const { app, BrowserWindow, Menu, Tray, ipcMain } = require('electron')
|
||||
const { app, BrowserWindow, Menu, Tray, ipcMain, dialog } = require('electron')
|
||||
const path = require('path');
|
||||
const isDev = require('electron-is-dev');
|
||||
const config = require('electron-json-config');
|
||||
|
||||
const { autoUpdater } = require("electron-updater");
|
||||
const { resourcesPath, selectByOS } = require('./utils');
|
||||
const { toggleLaunchAtStartup, willLaunchAtStartup, refreshWillLaunchAtStartup } = require('./auto-launch');
|
||||
const { stopServer, actuateServer, getServerAddress, getServerCertSHA256, getServerPassword } = require('./server');
|
||||
|
||||
const log = require("electron-log")
|
||||
|
||||
ipcMain.on('fetch-config', (event, arg) => {
|
||||
event.sender.send('config-updated', config.all());
|
||||
@@ -118,7 +118,39 @@ app.on('window-all-closed', function () {})
|
||||
ipcMain.on('server-status-updated', updateTrayContextMenu);
|
||||
ipcMain.on('launch-at-startup-updated', updateTrayContextMenu);
|
||||
|
||||
function checkForUpdates() {
|
||||
autoUpdater.checkForUpdatesAndNotify();
|
||||
}
|
||||
|
||||
function maybeMoveToApplicationsFolder() {
|
||||
try {
|
||||
if (!app.isInApplicationsFolder()) {
|
||||
let result = dialog.showMessageBoxSync({
|
||||
buttons: ["Yes","No"],
|
||||
message: "For best experience, Kopia needs to be installed in Applications folder.\n\nDo you want to move it now?"
|
||||
});
|
||||
if (result == 0) {
|
||||
return app.moveToApplicationsFolder();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
log.error('error' + e);
|
||||
// ignore
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
app.on('ready', () => {
|
||||
log.transports.file.level = "debug"
|
||||
autoUpdater.logger = log
|
||||
|
||||
if (maybeMoveToApplicationsFolder()) {
|
||||
return
|
||||
}
|
||||
|
||||
checkForUpdates();
|
||||
|
||||
tray = new Tray(
|
||||
path.join(
|
||||
resourcesPath(), 'icons',
|
||||
@@ -135,6 +167,7 @@ function updateTrayContextMenu() {
|
||||
const contextMenu = Menu.buildFromTemplate([
|
||||
{ label: 'Show Main Window', click: showMainWindow },
|
||||
{ label: 'Advanced Configuration...', click: advancedConfiguration },
|
||||
{ label: 'Check For Updates Now', click: checkForUpdates },
|
||||
{ type: 'separator' },
|
||||
{ label: 'Launch At Startup', type: 'checkbox', click: toggleLaunchAtStartup, checked: willLaunchAtStartup() },
|
||||
{ label: 'Quit', role: 'quit' },
|
||||
|
||||
Reference in new issue
Block a user