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) {

yarn.lock

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,10 +1155,6 @@ [email protected], app-builder-lib@~22.4.1:
11551155
semver "^7.1.3"
11561156
temp-file "^3.3.7"
11571157

1158-
applescript@^1.0.0:
1159-
version "1.0.0"
1160-
resolved "https://registry.yarnpkg.com/applescript/-/applescript-1.0.0.tgz#bb87af568cad034a4e48c4bdaf6067a3a2701317"
1161-
11621158
aproba@^1.0.3, aproba@^1.1.1:
11631159
version "1.2.0"
11641160
resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a"
@@ -1269,17 +1265,6 @@ atob@^2.1.1:
12691265
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
12701266
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
12711267

1272-
auto-launch@=5.0.5:
1273-
version "5.0.5"
1274-
resolved "https://registry.yarnpkg.com/auto-launch/-/auto-launch-5.0.5.tgz#d14bd002b1ef642f85e991a6195ff5300c8ad3c0"
1275-
integrity sha512-ppdF4mihhYzMYLuCcx9H/c5TUOCev8uM7en53zWVQhyYAJrurd2bFZx3qQVeJKF2jrc7rsPRNN5cD+i23l6PdA==
1276-
dependencies:
1277-
applescript "^1.0.0"
1278-
mkdirp "^0.5.1"
1279-
path-is-absolute "^1.0.0"
1280-
untildify "^3.0.2"
1281-
winreg "1.2.4"
1282-
12831268
aws-sign2@~0.7.0:
12841269
version "0.7.0"
12851270
resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8"
@@ -6760,10 +6745,6 @@ unset-value@^1.0.0:
67606745
has-value "^0.3.1"
67616746
isobject "^3.0.0"
67626747

6763-
untildify@^3.0.2:
6764-
version "3.0.2"
6765-
resolved "https://registry.yarnpkg.com/untildify/-/untildify-3.0.2.tgz#7f1f302055b3fea0f3e81dc78eb36766cb65e3f1"
6766-
67676748
upath@^1.1.1:
67686749
version "1.2.0"
67696750
resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894"
@@ -7045,11 +7026,6 @@ widest-line@^3.1.0:
70457026
dependencies:
70467027
string-width "^4.0.0"
70477028

7048-
7049-
version "1.2.4"
7050-
resolved "https://registry.yarnpkg.com/winreg/-/winreg-1.2.4.tgz#ba065629b7a925130e15779108cf540990e98d1b"
7051-
integrity sha1-ugZWKbepJRMOFXeRCM9UCZDpjRs=
7052-
70537029
wordwrap@~1.0.0:
70547030
version "1.0.0"
70557031
resolved "https://registry.yarnpkg.com/wordwrap/-/wordwrap-1.0.0.tgz#27584810891456a4171c8d0226441ade90cbcaeb"

0 commit comments

Comments
 (0)