This is an experimental starter kit for a React Electron app.
electron-reload
for the main process (in dev)- HMR for the renderer process (in dev)
- TypeScript
- React Router, routes automatically generated and localized
- Redux
- Polyglot
- Styled Components
- Jest config
- ESLint config
# Install dependencies
$ npm install
# Run in dev
$ npm run dev
See scripts
in package.json
for additional commands.
Note that you can only build for the same host platform you are currently on. It is best to utilize the included GitHub actions script to build for multiple platforms during CI/CD.
$ npm run make
To publish a release, simply run:
$ npm run publish
You can configure where the release should be published (defaults to GitHub) in /config/forge.conf.js
.
If you are hosting the releases in a private GitHub repo, you will need a dedicated server for fetching and redistributing the releases publicly. You can use a Nuts server to stage these releases. Click the button below to automatically create one on Heroku.
To set up Nuts:
- Provide an app name, i.e.
<repo_name>-nuts
- Select your region, i.e.
US
- Provide the GitHub repo of your project in the format
<user>/<repo_name>
- Provide GitHub access token, either look for an existing one or create your own
- Provide API username and password—these can be anything as long as you remember them, they are only used if you need to access the API of the Nuts server
- Select Deploy app and make note of your Nuts server's URL, i.e.
https://<repo_name>-nuts.herokuapp.com
Next, set up a GitHub webhook for the private releases repo so that whenever a release is published, the Nuts server is notified and will pull the latest release:
- Go to project settings in GitHub > Webhooks > Add webhook
- Set Payload URL to
<nuts_server_url>/refresh
- Select
application/json
for Content type - Set Secret to
secret
- Select Let me select individual events. and only check Release
Finally, assign the Nuts server URL to the autoUpdateFeedUrl
field in /config/app.conf.ts
, i.e. <nuts_server_url>/download/latest
.
For more details see https://www.electronjs.org/docs/latest/tutorial/code-signing and https://github.com/electron/electron-osx-sign/wiki/1.-Getting-Started#certificates
When distributing an Electron app for macOS, you need to code-sign and notarize it in order for it to clear macOS security. To do so, you need to prepare the following:
- Enroll in the Apple Developer Program
- Make note of your team ID
- Log in to Member Center
- Go to Membership
- You will see it under Team ID
- Create a Certificate Signing Request (CSR), which will be required for generating code-signing certificates in the next step:
- On your Mac, open Keychain Access app
- Go to Keychain Access > Certificate Assitant > Request a Certificate From a Certificate Authority
- A dialog will appear, enter the email address registered with your Apple Developer Program account under User Email Address
- Under Request is, select Saved to disk
- Leave everything else blank
- Click Continue
- Save the
.certSigningRequest
file somewhere
- Generate code-signing certificates:
- Log in to Member Center
- Go to Certificates, Identifiers & Profiles
- Under Certificates, click the plus button
- Select one of the following:
- Developer ID Application (
Developer ID Application: * (*)
) or Developer ID Installer (Developer ID Installer: * (*)
) for distribution outside the Mac App Store - Mac App Distribution (
3rd Party Mac Developer Application: * (*)
) or Mac Installer Distribution (3rd Party Mac Developer Installer: * (*)
) for distribution inside the Mac App Store
- Developer ID Application (
- Upon clicking Continue, you will be prompted to upload a CSR file, so select the
.certSigningRequest
file you just created - Once the certificate is created, download it and open it with the Keychain Access app on your Mac
- When you have both certificates in Keychain Access, select both, then right click and export both items to a
.p12
file - Provide a secure password, make note of this password
- Encode the
.p12
file to base-64 string:base64 -i certificate.p12
- Prepare the following environment variables for later use (i.e. in the CI environment):
# Apple ID (email) with a registered developer account MAC_CODE_SIGN_APPLE_ID # Apple ID password (recommend generating and using an app-specific password) MAC_CODE_SIGN_APPLE_ID_PASSWORD # The identity name of the Developer ID Application or Mac App Distribution certificate (i.e. # "Developer ID Application: <your_name> (<your_team_id>)") MAC_CODE_SIGN_IDENTITY # The base-64 encoded string of the .p12 file MAC_CODE_SIGN_CERTIFICATE # The password provided while exporting the .p12 file MAC_CODE_SIGN_CERTIFICATE_PASSWORD
For more details see https://www.electronjs.org/docs/latest/tutorial/code-signing
Code signing for Windows involves acquiring a code signing certificate from a 3rd party reseller, such as DigiCert.
- Obtain the certificate file and ensure that it is in
.pfx
format - Provide a secure password to unlock the
.pfx
file - Encode the
.pfx
file to a base-64 string:base64 -i certificate.pfx
- Provide the following environment variables for later use (i.e. in the CI environment):
# The base-64 encoded string of the .pfx file WIN_CODE_SIGN_CERTIFICATE # The password provided while exporting the .pfx file WIN_CODE_SIGN_CERTIFICATE_PASSWORD
By default, logs are written to the following locations:
- on Linux:
~/.config/{app name}/logs/{process type}.log
- on OS X:
~/Library/Logs/{app name}/{process type}.log
- on Windows:
%USERPROFILE%\AppData\Roaming\{app name}\logs\{process type}.log