-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Changes from all commits
bbc9c13
cfe8da8
cd1e0b5
0dfe73f
9b12707
78d6345
7a329a1
35ee77b
685ef27
c479497
964ea71
6fc510a
89198f9
1ed1c6a
f7aabbd
f849edd
b67a27f
e17a8c0
0e43e36
7108851
cc2a289
b53e7ac
be69c15
6525c40
a1f3462
992e052
f19fa3c
a09b0d6
77de4cf
09d06b3
af2059a
8fd6751
8fee1f6
f0a9a10
e99bf58
5def1d6
2d9e0d6
fa631f7
31b3c2a
2fab683
f7f7af8
91431a8
b314d0b
4de9d8f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name: Build and Deploy Android | |
|
||
on: | ||
push: | ||
branches: [ master ] | ||
tags: ['**'] | ||
|
||
jobs: | ||
build: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
name: eslint | ||
|
||
on: [push] | ||
on: push | ||
|
||
jobs: | ||
build: | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
name: Create a new version | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
|
||
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 |
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 }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,73 @@ | ||
const {app, BrowserWindow, shell} = require('electron'); | ||
const serve = require('electron-serve'); | ||
const contextMenu = require('electron-context-menu'); | ||
const {autoUpdater} = require('electron-updater'); | ||
const log = require('electron-log'); | ||
|
||
/** | ||
* 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 | ||
// Interval that we check for new versions of the app | ||
const UPDATE_INTERVAL = 1000 * 60 * 60; | ||
|
||
// 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(); | ||
|
||
// Send all autoUpdater logs to a log file: ~/Library/Logs/react-native-chat/main.log | ||
// See https://www.npmjs.com/package/electron-log | ||
autoUpdater.logger = log; | ||
autoUpdater.logger.transports.file.level = 'info'; | ||
|
||
// Send all Console logs to a log file: ~/Library/Logs/react-native-chat/main.log | ||
// See https://www.npmjs.com/package/electron-log | ||
Object.assign(console, log.functions); | ||
|
||
const mainWindow = (() => { | ||
const loadURL = serve({directory: 'dist'}); | ||
|
||
await app.whenReady(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
}) | ||
|
||
// After initializing and configuring the browser window, load the compiled JavaScript | ||
.then(browserWindow => loadURL(browserWindow)) | ||
|
||
// Check for a new version of the app on launch | ||
.then(() => autoUpdater.checkForUpdatesAndNotify()) | ||
|
||
// Set a timer to check for new versions of the app | ||
.then(() => setInterval(() => autoUpdater.checkForUpdatesAndNotify(), UPDATE_INTERVAL)); | ||
}); | ||
|
||
mainWindow(); | ||
mainWindow().then(window => window); |
There was a problem hiding this comment.
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
After
There was a problem hiding this comment.
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
?There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 👍