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

[No QA] Simplify electron-builder configs #7684

Merged
merged 16 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
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 .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=PROD
ENVIRONMENT=production
2 changes: 1 addition & 1 deletion .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ EXPENSIFY_PARTNER_NAME=chat-expensify-com
EXPENSIFY_PARTNER_PASSWORD=e21965746fd75f82bb66
PUSHER_APP_KEY=268df511a204fbb60884
USE_WEB_PROXY=false
ENVIRONMENT=STG
ENVIRONMENT=staging
4 changes: 2 additions & 2 deletions .github/workflows/platformDeploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ jobs:

- name: Build production desktop app
if: ${{ fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
run: npm run desktop-build -- --publish always -c.afterSign=desktop/notarize.js
run: npm run desktop-build -- --publish always
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
Expand All @@ -154,7 +154,7 @@ jobs:

- name: Build staging desktop app
if: ${{ !fromJSON(env.SHOULD_DEPLOY_PRODUCTION) }}
run: npm run desktop-build-staging -- --publish always -c.afterSign=desktop/notarize.js
run: npm run desktop-build-staging -- --publish always
env:
CSC_LINK: ${{ secrets.CSC_LINK }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
Expand Down
13 changes: 13 additions & 0 deletions config/electronBuilder/electronBuilder.ghactions.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const baseElectronBuilderConfig = require('./electronBuilder.local.config');

const isStagingBuild = process.env.NODE_ENV === 'staging';

module.exports = {
...baseElectronBuilderConfig,
publish: [{
provider: 's3',
bucket: isStagingBuild ? 'staging-expensify-cash' : 'expensify-cash',
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
channel: 'latest',
}],
afterSign: './desktop/notarize.js',
};
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
const ENVIRONMENT = require('../src/CONST/ENVIRONMENT');
const ENVIRONMENT = require('../../src/CONST/ENVIRONMENT');

const isStagingBuild = process.env.NODE_ENV === 'staging';
roryabraham marked this conversation as resolved.
Show resolved Hide resolved

/**
* The basic app configurations for the production and staging Electron builds,
* without the pieces that require code signing, notarizing, and publishing.
*
* This has been separated from main electronBuilder.ghactions.config.js file to make it easier to run local production or staging builds.
*/
module.exports = {
appId: 'com.expensifyreactnative.chat',
productName: 'New Expensify',
extraMetadata: {
main: './desktop/main.js',
electronEnvironment: process.env.SHOULD_DEPLOY_PRODUCTION ? ENVIRONMENT.PRODUCTION : ENVIRONMENT.STAGING,
electronEnvironment: isStagingBuild ? ENVIRONMENT.STAGING : ENVIRONMENT.PRODUCTION,
},
mac: {
category: 'public.app-category.finance',
icon: process.env.SHOULD_DEPLOY_PRODUCTION === 'true' ? './desktop/icon.png' : './desktop/icon-stg.png',
icon: isStagingBuild ? './desktop/icon-stg.png' : './desktop/icon.png',
hardenedRuntime: true,
entitlements: 'desktop/entitlements.mac.plist',
entitlementsInherit: 'desktop/entitlements.mac.plist',
Expand All @@ -20,11 +28,6 @@ module.exports = {
artifactName: 'NewExpensify.dmg',
internetEnabled: true,
},
publish: [{
provider: 's3',
bucket: process.env.SHOULD_DEPLOY_PRODUCTION === 'true' ? 'expensify-cash' : 'staging-expensify-cash',
channel: 'latest',
}],
files: [
'./dist/**/*',
'./desktop/*.js',
Expand Down
2 changes: 1 addition & 1 deletion desktop/ELECTRON_ENVIRONMENT.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// This variable is injected into package.json by electron-builder via the extraMetadata field (specified in electron.config.js)
// This variable is injected into package.json by electron-builder via the extraMetadata field (specified in electronBuilder.ghactions.config.js)
// It will be `PROD` on production, `STG` on staging, and `undefined` on dev (because dev doesn't use electron-builder)
const {electronEnvironment} = require('../package.json');
const ENVIRONMENT = require('../src/CONST/ENVIRONMENT');
Expand Down
3 changes: 1 addition & 2 deletions desktop/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ mc policy set public electron-builder/electron-builder
Once you have Min.IO setup and running, the next step is to temporarily revert some changes from https://github.com/Expensify/App/commit/b640b3010fd7a40783d1c04faf4489836e98038d, specifically

1. Update the `desktop-build` command in package.json to add `--publish always` at the end
2. Update electron.config.js to re-add `afterSign: 'desktop/notarize.js',`
3. Update electron.config.js to replace the `publish` value with the following:
2. Update electronBuilder.ghactions.config.js to replace the `publish` value with the following:
```
publish: [{
provider: 's3',
Expand Down
2 changes: 1 addition & 1 deletion desktop/notarize.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const {notarize} = require('electron-notarize');
const electron = require('../config/electron.config');
const electron = require('../config/electronBuilder/electronBuilder.ghactions.config');

exports.default = function notarizing(context) {
const {electronPlatformName, appOutDir} = context;
Expand Down
3 changes: 1 addition & 2 deletions desktop/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ portfinder.getPortPromise({

},
{
command: `wait-port localhost:${port} && export NODE_ENV=development PORT=${port} \
&& electron desktop/main.js`,
command: `wait-port localhost:${port} && export PORT=${port} && electron desktop/main.js`,
name: 'Main',
prefixColor: 'cyan.dim',
},
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
"ios": "npm run check-metro-bundler-port && react-native run-ios",
"ipad": "npm run check-metro-bundler-port && react-native run-ios --simulator=\"iPad Pro (12.9-inch) (4th generation)\"",
"ipad-sm": "npm run check-metro-bundler-port && react-native run-ios --simulator=\"iPad Pro (9.7-inch)\"",
"desktop": "node desktop/start.js",
"desktop": "export NODE_ENV=development && node desktop/start.js",
roryabraham marked this conversation as resolved.
Show resolved Hide resolved
"start": "react-native start",
"web": "node web/proxy.js & webpack-dev-server --open --config config/webpack/webpack.dev.js",
"build": "webpack --config config/webpack/webpack.prod.js",
"build-staging": "webpack --config config/webpack/webpack.staging.js",
"desktop-build": "webpack --config config/webpack/webpack.prod.js --platform desktop && electron-builder --config config/electron.config.js",
"desktop-build-staging": "webpack --config config/webpack/webpack.staging.js --platform desktop && electron-builder --config config/electron.config.js",
"desktop-build": "export NODE_ENV=production && webpack --config config/webpack/webpack.prod.js --platform desktop && electron-builder --config config/electronBuilder/electronBuilder.ghactions.config.js",
"desktop-build-staging": "export NODE_ENV=staging && webpack --config config/webpack/webpack.staging.js --platform desktop && electron-builder --config config/electronBuilder/electronBuilder.ghactions.config.js",
"desktop-build-local": "export NODE_ENV=production && webpack --config config/webpack/webpack.prod.js --platform desktop && electron-builder --config config/electronBuilder/electronBuilder.local.config.js",
"desktop-build-staging-local": "export NODE_ENV=staging && webpack --config config/webpack/webpack.staging.js --platform desktop && electron-builder --config config/electronBuilder/electronBuilder.local.config.js",
"ios-build": "fastlane ios build",
"android-build": "fastlane android build",
"test": "jest",
Expand Down
6 changes: 3 additions & 3 deletions src/CONST/ENVIRONMENT.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
DEV: 'DEV',
STAGING: 'STG',
PRODUCTION: 'PROD',
DEV: 'development',
STAGING: 'staging',
PRODUCTION: 'production',
};
8 changes: 7 additions & 1 deletion src/components/EnvironmentBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ import CONST from '../CONST';
import withEnvironment, {environmentPropTypes} from './withEnvironment';
import Badge from './Badge';

const ENVIRONMENT_SHORT_FORM = {
[CONST.ENVIRONMENT.DEV]: 'DEV',
[CONST.ENVIRONMENT.STAGING]: 'STG',
[CONST.ENVIRONMENT.PRODUCTION]: 'PROD',
};

const EnvironmentBadge = (props) => {
// If we are on production, don't show any badge
if (props.environment === CONST.ENVIRONMENT.PRODUCTION) {
Expand All @@ -13,7 +19,7 @@ const EnvironmentBadge = (props) => {
<Badge
success={props.environment === CONST.ENVIRONMENT.STAGING}
error={props.environment !== CONST.ENVIRONMENT.STAGING}
text={props.environment}
text={ENVIRONMENT_SHORT_FORM[props.environment]}
/>
);
};
Expand Down