Skip to content

Commit eb947ba

Browse files
authored
Support for Windows (#393)
* Autostart only for macOS (temp) * Build for windows * Correct icon for windows & improved logging in notarization * Setup github workflows * Fix github workflow config * Fix windows build name * Run workflow on windows * Remove dist dir * Correct artifact name * Replace autolaunch with electron's builtin functionality Supports both macOS & Windows * Fix tests * Sign windows build * Revert "Sign windows build" This reverts commit 3494b24.
1 parent 5154172 commit eb947ba

File tree

11 files changed

+109
-57
lines changed

11 files changed

+109
-57
lines changed

.github/workflows/build-app.yml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,39 @@ jobs:
3737

3838
- uses: actions/upload-artifact@v1
3939
with:
40-
name: Gitify-dist
40+
name: Gitify-dist-mac
41+
path: dist
42+
43+
build-windows:
44+
runs-on: windows-2019
45+
46+
steps:
47+
- uses: actions/checkout@v2
48+
49+
- name: Get yarn cache
50+
id: yarn-cache
51+
run: echo "::set-output name=dir::$(yarn cache dir)"
52+
53+
- uses: actions/cache@v1
54+
with:
55+
path: ${{ steps.yarn-cache.outputs.dir }}
56+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
57+
restore-keys: |
58+
${{ runner.os }}-yarn-
59+
60+
- name: Install Dependencies
61+
run: yarn install
62+
63+
- name: Build
64+
run: yarn build
65+
66+
- name: Make Windows (electron-builder)
67+
run: yarn make:win
68+
69+
- name: Clean up builds
70+
run: Remove-Item dist/win-unpacked -Recurse
71+
72+
- uses: actions/upload-artifact@v1
73+
with:
74+
name: Gitify-dist-win
4175
path: dist

.github/workflows/release.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,35 @@ jobs:
4040
CSC_KEY_PASSWORD: ${{ secrets.mac_certs_password }}
4141
GH_TOKEN: ${{ secrets.gh_token }}
4242
NOTARIZE: true
43-
run: yarn electron-builder --publish onTagOrDraft
43+
run: yarn make:mac --publish onTagOrDraft
44+
45+
release-windows:
46+
runs-on: windows-2019
47+
48+
steps:
49+
- uses: actions/checkout@v2
50+
51+
- name: Get yarn cache
52+
id: yarn-cache
53+
run: echo "::set-output name=dir::$(yarn cache dir)"
54+
55+
- uses: actions/cache@v1
56+
with:
57+
path: ${{ steps.yarn-cache.outputs.dir }}
58+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
59+
restore-keys: |
60+
${{ runner.os }}-yarn-
61+
62+
- name: Install Dependencies
63+
run: yarn install
64+
65+
- name: Build
66+
env:
67+
OAUTH_CLIENT_ID: ${{ secrets.oauth_client_id }}
68+
OAUTH_CLIENT_SECRET: ${{ secrets.oauth_client_secret }}
69+
run: yarn build
70+
71+
- name: Publish Windows (electron-builder)
72+
env:
73+
GH_TOKEN: ${{ secrets.gh_token }}
74+
run: yarn make:win --publish onTagOrDraft

assets/images/app-icon.ico

14.8 KB
Binary file not shown.

main.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,11 @@
11
const { ipcMain } = require('electron');
22
const { menubar } = require('menubar');
3-
const { autoUpdater } = require("electron-updater")
3+
const { autoUpdater } = require('electron-updater');
44
const path = require('path');
5-
const AutoLaunch = require('auto-launch');
65

76
const iconIdle = path.join(__dirname, 'assets', 'images', 'tray-idleTemplate.png');
87
const iconActive = path.join(__dirname, 'assets', 'images', 'tray-active.png');
9-
10-
const autoStart = new AutoLaunch({
11-
name: 'Gitify',
12-
path: process.execPath.match(/.*?\.app/)[0],
13-
isHidden: true,
14-
});
8+
const isDarwin = process.platform === 'darwin';
159

1610
const browserWindowOpts = {
1711
width: 500,
@@ -38,8 +32,6 @@ menubarApp.on('ready', () => {
3832
autoUpdater.checkForUpdatesAndNotify();
3933

4034
ipcMain.on('reopen-window', () => menubarApp.showWindow());
41-
ipcMain.on('startup-enable', () => autoStart.enable());
42-
ipcMain.on('startup-disable', () => autoStart.disable());
4335
ipcMain.on('app-quit', () => menubarApp.app.quit());
4436
ipcMain.on('update-icon', (_, arg) => {
4537
if (!menubarApp.tray.isDestroyed()) {

package.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"scripts": {
77
"build": "webpack --config webpack.prod.js",
88
"watch": "webpack --config webpack.common.js --watch",
9+
"make:win": "electron-builder --win",
910
"make:macos": "electron-builder --mac",
1011
"prettier-check": "prettier --check 'src/**/*.{js,ts,tsx}'",
1112
"prettier": "prettier --single-quote --trailing-comma es5 --write 'src/**/*.{js,ts,tsx}'",
@@ -85,11 +86,17 @@
8586
"icon": "assets/images/app-icon.icns",
8687
"sign": false
8788
},
89+
"win": {
90+
"target": "nsis",
91+
"icon": "assets/images/app-icon.ico"
92+
},
93+
"nsis": {
94+
"oneClick": false
95+
},
8896
"afterSign": "scripts/notarize.js"
8997
},
9098
"dependencies": {
9199
"@primer/octicons-react": "^9.6.0",
92-
"auto-launch": "=5.0.5",
93100
"axios": "=0.19.2",
94101
"date-fns": "^2.11.1",
95102
"electron-updater": "^4.2.5",

scripts/notarize.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,14 @@ const notarizeApp = async (context) => {
1010
const shouldNotarize = process.env.NOTARIZE === 'true';
1111

1212
if (!shouldNotarize || !isMacOS) {
13-
console.log('Either should not notarize or not building for macOS.');
13+
console.log(
14+
' • notarizing either should not notarize or not building for macOS'
15+
);
1416
return;
1517
}
1618

19+
console.log(' • notarizing started');
20+
1721
return await notarize({
1822
appBundleId,
1923
appPath: `${appOutDir}/${appName}.app`,

src/js/__mocks__/electron.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ module.exports = {
5151
dialog: dialog,
5252
app: {
5353
getVersion: () => '0.0.1',
54+
getLoginItemSettings: jest.fn(),
55+
setLoginItemSettings: () => {},
5456
},
5557
getCurrentWindow: jest.fn(() => browserWindow),
5658
},

src/js/middleware/settings.test.ts

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { ipcRenderer } = require('electron');
1+
const { remote } = require('electron');
22

33
import * as actions from '../actions';
44
import settingsMiddleware from './settings';
@@ -13,11 +13,9 @@ const dispatchWithStoreOf = (_, action) => {
1313
};
1414

1515
describe('middleware/settings.js', () => {
16-
beforeEach(function () {
17-
spyOn(ipcRenderer, 'send');
18-
});
19-
2016
it('should toggle the openAtStartup setting', () => {
17+
spyOn(remote.app, 'setLoginItemSettings');
18+
2119
const action = {
2220
type: actions.UPDATE_SETTING,
2321
setting: 'openAtStartup',
@@ -26,7 +24,6 @@ describe('middleware/settings.js', () => {
2624

2725
expect(dispatchWithStoreOf({}, action)).toEqual(action);
2826

29-
expect(ipcRenderer.send).toHaveBeenCalledTimes(1);
30-
expect(ipcRenderer.send).toHaveBeenCalledWith('startup-enable');
27+
expect(remote.app.setLoginItemSettings).toHaveBeenCalledTimes(1);
3128
});
3229
});

src/js/utils/comms.test.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
setAutoLaunch,
66
} from './comms';
77

8-
const { ipcRenderer, shell } = require('electron');
8+
const { ipcRenderer, remote, shell } = require('electron');
99

1010
describe('utils/comms.ts', () => {
1111
beforeEach(function () {
@@ -39,14 +39,24 @@ describe('utils/comms.ts', () => {
3939
});
4040

4141
it('should setAutoLaunch (true)', () => {
42+
spyOn(remote.app, 'setLoginItemSettings');
43+
4244
setAutoLaunch(true);
43-
expect(ipcRenderer.send).toHaveBeenCalledTimes(1);
44-
expect(ipcRenderer.send).toHaveBeenCalledWith('startup-enable');
45+
expect(remote.app.setLoginItemSettings).toHaveBeenCalledTimes(1);
46+
expect(remote.app.setLoginItemSettings).toHaveBeenCalledWith({
47+
openAtLogin: true,
48+
openAsHidden: true,
49+
});
4550
});
4651

4752
it('should setAutoLaunch (false)', () => {
53+
spyOn(remote.app, 'setLoginItemSettings');
54+
4855
setAutoLaunch(false);
49-
expect(ipcRenderer.send).toHaveBeenCalledTimes(1);
50-
expect(ipcRenderer.send).toHaveBeenCalledWith('startup-disable');
56+
expect(remote.app.setLoginItemSettings).toHaveBeenCalledTimes(1);
57+
expect(remote.app.setLoginItemSettings).toHaveBeenCalledWith({
58+
openAtLogin: false,
59+
openAsHidden: false,
60+
});
5161
});
5262
});

src/js/utils/comms.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
import { SettingsState } from '../../types/reducers';
1+
const { ipcRenderer, remote, shell } = require('electron');
22

3-
const { ipcRenderer, shell } = require('electron');
3+
import { SettingsState } from '../../types/reducers';
44

55
export function openExternalLink(url) {
66
shell.openExternal(url);
77
}
88

99
export function setAutoLaunch(value) {
10-
if (value) {
11-
ipcRenderer.send('startup-enable');
12-
} else {
13-
ipcRenderer.send('startup-disable');
14-
}
10+
remote.app.setLoginItemSettings({
11+
openAtLogin: value,
12+
openAsHidden: value,
13+
});
1514
}
1615

1716
export function updateTrayIcon(notificationsLength = 0) {

0 commit comments

Comments
 (0)