Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add electron auto updating #359

Merged
merged 44 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from 42 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
bbc9c13
Auto update desktop app
AndrewGable Aug 31, 2020
cfe8da8
Testing...!
AndrewGable Aug 31, 2020
cd1e0b5
Set name before version
AndrewGable Aug 31, 2020
0dfe73f
Update version to 1.0.1-5
Aug 31, 2020
9b12707
Tweaking on event
AndrewGable Aug 31, 2020
78d6345
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Aug 31, 2020
7a329a1
Update version to 1.0.1-6
Aug 31, 2020
35ee77b
Test via push
AndrewGable Aug 31, 2020
685ef27
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Aug 31, 2020
c479497
Update version to 1.0.1-7
Aug 31, 2020
964ea71
Tweak logging
AndrewGable Aug 31, 2020
6fc510a
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Aug 31, 2020
89198f9
Update version to 1.0.1-8
Aug 31, 2020
1ed1c6a
Add lots of logs
AndrewGable Aug 31, 2020
f7aabbd
Update version to 1.0.1-9
Aug 31, 2020
f849edd
Continue to debug auto-update
AndrewGable Aug 31, 2020
b67a27f
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Aug 31, 2020
e17a8c0
Update version to 1.0.1-10
Aug 31, 2020
0e43e36
Merge branch 'master' into andrew-auto-update
AndrewGable Aug 31, 2020
7108851
Tweak config
AndrewGable Aug 31, 2020
cc2a289
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Aug 31, 2020
b53e7ac
Update version to 1.0.1-11
Aug 31, 2020
be69c15
Fix auto update bugs
AndrewGable Aug 31, 2020
6525c40
1.0.1-11
AndrewGable Aug 31, 2020
a1f3462
Tweak configs more
AndrewGable Aug 31, 2020
992e052
1.0.1-12
AndrewGable Aug 31, 2020
f19fa3c
Fix s3 region
AndrewGable Aug 31, 2020
a09b0d6
1.0.1-13
AndrewGable Aug 31, 2020
77de4cf
Move publish to root
AndrewGable Aug 31, 2020
09d06b3
1.0.1-14
AndrewGable Sep 1, 2020
af2059a
Move to promises away from await
AndrewGable Sep 1, 2020
8fd6751
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Sep 1, 2020
8fee1f6
Update version to 1.0.1-15
Sep 1, 2020
f0a9a10
Remove s3 from desktop as build does it now
AndrewGable Sep 1, 2020
e99bf58
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Sep 1, 2020
5def1d6
Update version to 1.0.1-16
Sep 1, 2020
2d9e0d6
Update link with new install link and revert testing
AndrewGable Sep 1, 2020
fa631f7
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Sep 1, 2020
31b3c2a
Update version to 1.0.1-17
Sep 1, 2020
2fab683
Change version to happen on push to master only
AndrewGable Sep 1, 2020
f7f7af8
Merge branch 'andrew-auto-update' of github.com:AndrewGable/ReactNati…
AndrewGable Sep 1, 2020
91431a8
Tweak style
AndrewGable Sep 1, 2020
b314d0b
Add logs back, they are helpful
AndrewGable Sep 1, 2020
4de9d8f
Set an hour timer to check for new app updates
AndrewGable Sep 1, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy Android

on:
push:
branches: [ master ]
tags: ['**']

jobs:
build:
Expand Down
17 changes: 3 additions & 14 deletions .github/workflows/desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build and Deploy Desktop

on:
push:
branches: [ master ]
tags: ['**']

jobs:
build:
Expand All @@ -18,13 +18,6 @@ jobs:
- name: Install node packages
run: npm install

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

- name: Decrypt Developer ID Certificate
run: cd desktop && gpg --quiet --batch --yes --decrypt --passphrase="$DEVELOPER_ID_SECRET_PASSPHRASE" --output developer_id.p12 developer_id.p12.gpg
env:
Expand All @@ -37,9 +30,5 @@ jobs:
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_ID_PASSWORD: ${{ secrets.APPLE_ID_PASSWORD }}

- name: Zip desktop build
run: 7z a $GITHUB_WORKSPACE/dist/mac/Chat.app.zip $GITHUB_WORKSPACE/dist/mac/Chat.app

- name: Deploy to S3
run: aws s3 cp --acl public-read $GITHUB_WORKSPACE/dist/mac/Chat.app.zip s3://chat-test-expensify-com/Chat.app.zip
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: eslint

on: [push]
on: push

jobs:
build:
Expand Down
60 changes: 0 additions & 60 deletions .github/workflows/main.yml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Create a new version

on:
push:
branches: [master]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this is a slight tweak on our deploy process.

Before

  1. Push to master kicks off deploy actions for web, mobile, and android

After

  1. Generate a new version on every push to master
  2. Push a new tag with that version
  3. All the deploy scripts will start when a new tag is pushed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in the future when we're using react-native for our full app, would we basically just change this to production?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question, I don't think we've really discussed how we will merge the deploy processes of the two repos quite yet.. The deploy process for ReactNative web app is quite simple.. Just throw it on an s3 bucket, refresh cloudflare cache and we are good. The deploy process for our existing front end is a bit more complicated.. I think that will be a larger discussion that probably warrants a design doc

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 👍


jobs:
build:
runs-on: ubuntu-16.04

steps:
- uses: actions/checkout@v2

- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '14.x'

- name: Install dependenices
run: npm install

- name: Set git user
run: git config user.name github-action

- name: Generate version
run: npm version prerelease -m "Update version to %s"

- name: Push new version
run: git push && git push --tags
51 changes: 51 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Build and Deploy Web

on:
push:
tags: ['**']

jobs:
build:
runs-on: ubuntu-16.04

steps:
- uses: actions/checkout@v2

# Installs node
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: '14.x'

# Install python pre-reqs
- name: Setup python
run: sudo apt-get install python3-setuptools

# Installs Cloudflare CLI, after installing/upgrading dependencies
- name: Setup Cloudflare CLI
run: |
pip3 install --upgrade pip
pip3 install wheel # need wheel before cloudflare, this is the only way to ensure order.
pip3 install cloudflare

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1

# Install node modules
- name: Install dependenices
run: npm install

- name: Build web
run: npm run build

- name: Deploy to S3
run: aws s3 cp --recursive --acl public-read $GITHUB_WORKSPACE/dist s3://chat-test-expensify-com/

- name: Purge Cloudflare cache
run: /home/runner/.local/bin/cli4 --delete hosts=["chat.expensify.com"] /zones/:9ee042e6cfc7fd45e74aa7d2f78d617b/purge_cache
env:
CF_API_KEY: ${{ secrets.CLOUDFLARE_TOKEN }}
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ android {
applicationId "com.expensifyreactnative.chat"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 5
versionName "1.0.1-4"
versionCode 18
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bugs me that these are off, once this is merged I will try to align them

versionName "1.0.1-17"
}
splits {
abi {
Expand Down
10 changes: 10 additions & 0 deletions desktop/electron.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ module.exports = {
entitlementsInherit: 'desktop/entitlements.mac.plist',
type: 'distribution'
},
dmg: {
title: 'Chat',
artifactName: 'Chat.dmg',
internetEnabled: true
},
publish: [{
provider: 's3',
bucket: 'chat-test-expensify-com',
channel: 'latest'
}],
files: [
'./dist/**/*',
'./main.js'
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactNativeChat/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>18</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false />
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/ReactNativeChatTests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>5</string>
<string>18</string>
</dict>
</plist>
68 changes: 36 additions & 32 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
const {app, BrowserWindow, shell} = require('electron');
const serve = require('electron-serve');
const contextMenu = require('electron-context-menu');
const {autoUpdater} = require('electron-updater');

/**
* Electron main process that handles wrapping the web application.
*
* @see: https://www.electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
*/

// TODO: Turn this off, use web-security after alpha launch, currently we recieve a CORS issue preventing
// TODO: Turn this off, use web-security after alpha launch, currently we receive a CORS issue preventing
// the electron app from making any API requests.
app.commandLine.appendSwitch('disable-web-security');

const mainWindow = (async () => {
// Initialize the right click menu
// See https://github.com/sindresorhus/electron-context-menu
contextMenu();

const mainWindow = (() => {
const loadURL = serve({directory: 'dist'});

await app.whenReady();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed awaits in this file, I think everything works but let me know if you spot any bugs.


// Initialize the right click menu
// See https://github.com/sindresorhus/electron-context-menu
contextMenu();

const browserWindow = new BrowserWindow({
backgroundColor: '#FAFAFA',
width: 1200,
height: 900,
webPreferences: {
nodeIntegration: true,
},
});

await loadURL(browserWindow);

// When the user clicks a link that has target="_blank" (which is all external links)
// open the default browser instead of a new electron window
browserWindow.webContents.on('new-window', (e, url) => {
// make sure local urls stay in electron perimeter
if (url.substr(0, 'file://'.length) === 'file://') {
return;
}

// and open every other protocol in the browser
e.preventDefault();
shell.openExternal(url);
});
return app.whenReady()
.then(() => {
const browserWindow = new BrowserWindow({
backgroundColor: '#FAFAFA',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAB: You should use the colors object from the global stylesheet (I actually really think that colors deserve their own file under styles/, but that's beside the point)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I will add that in a future PR.

width: 1200,
height: 900,
webPreferences: {
nodeIntegration: true,
},
});

// When the user clicks a link that has target="_blank" (which is all external links)
// open the default browser instead of a new electron window
browserWindow.webContents.on('new-window', (e, url) => {
// make sure local urls stay in electron perimeter
if (url.substr(0, 'file://'.length) === 'file://') {
return;
}

// and open every other protocol in the browser
e.preventDefault();
return shell.openExternal(url);
});

return browserWindow;
})
.then(browserWindow => loadURL(browserWindow))
.then(() => autoUpdater.checkForUpdatesAndNotify());
});

mainWindow();
mainWindow().then(window => window);
Loading