The Electron application distribution system provides application compilation (Windows, Linux, and MacOS), automatic upgrade, and distribution services. Making Electron application distribution very easy.

Open source: github.com/yi-ge/elect…

Note that one Git repository corresponds to one Electron application, and one Electron application corresponds to one application distribution system.

The Electron application distribution server runs on 64-bit Linux (required) and MacOS (optional) and compiles X64 applications by default. Other platforms and architectures require code modifications (although this is easy to implement).

Quick start

Linux Server (X64) Server Deployment Guide

Command Execution Example

docker run -itd --name electron-distribution --restart always \
 -e NAME=your-app-name \
 -e SCHEME=https \
 -e DOMAIN=www.example.com \
 -e TOKEN=123456 \
 -e [email protected]:abc/def.git \
 -e BUILD_TYPE=win,linux,mac \
 -e WORKPATH=/data \
 -e OBJECT_STORAGE_TYPE=cos
 -v /data:/data \
 -p 80:80 \
 -v /var/run/docker.sock:/var/run/docker.sock \
 -v /root/.ssh:/root/.ssh \
 -v /data/icon.ico:/project/public/icon.ico \
 wy373226722/electron-distributionCopy the code

Domestic Users: docker pull registry.cn-shenzhen.aliyuncs.com/yi-ge/electron-distribution:latest or docker pull ccr.ccs.tencentyun.com/yi-ge/electron-distribution:latest

You will need to install Nginx yourself and configure it to support SSL, which is a must, otherwise automatic application updates may fail. SCHEME is just an identifier.

The environment variable

The variable name The default value describe
NAME "APP" Your app name. Numbers, letters and "-".
SCHEME "https" Production environment only work with SSL.
DOMAIN "www.example.com" Your Electron Distribution server-side domain.
TOKEN "1jH27dJf9s852" Your Electron Distribution API TOKEN.
REPOPATH "[email protected]:yi-ge/electron-distribution.git" Your electron app repository.
BUILD_TYPE "win,linux" win,linux,mac
WORKPATH "/data" -v /data:/data, The two path must be consistent.
DOCKER_SOCKET "/var/run/docker.sock" Docker socket path.
MAC_SERVER_HOST "127.0.0.1" Your macOS server host.
MAC_SERVER_PORT "22" Your macOS server ssh port.
MAC_SERVER_USERNAME "guest" Your macOS server ssh username.
LINUX_SERVER_HOST "127.0.0.1" Only require build mac application. Your linux server host.
LINUX_SERVER_PORT "22" Only require build mac application. Your linux server ssh port.
LINUX_SERVER_USERNAME "root" Only require build mac application. Your linux server ssh username.
GH_TOKEN "" If you set publish option.
CSC_LINK "" https://www.electron.build/code-signing
CSC_KEY_PASSWORD "" https://www.electron.build/code-signing
CSC_NAME. "" https://www.electron.build/code-signing
BUILD_CPU_LIMIT "0" Linux and Windows build cpu limit. CPUs in which to allow execution (e.g., 0-3, 0,1)
BUILD_MEMORY_LIMIT 0 Linux and Windows memory limit in bytes. 1024 * 1024 * 1024 bytes = 1073741824 bytes = 1GB
OBJECT_STORAGE_TYPE "cos" cos: Tencent Cloud Object Storage; oss: Aliyun Object Storage; qiniu: Qiniu Object Storage.
QINIU_ACCESS_KEY "" Qiniu Object Storage, accessKey.
QINIU_SECRET_KEY "" Qiniu Object Storage, secretKey.
QINIU_BUCKET_KEY "" Qiniu Object Storage, bucket.
QINIU_ZONE "Zone_z0" East China Zone_z0, North China Zone_z1, South China Zone_z2, North America Zone_na0
QINIU_URL "https://cdn.xxx.com" Qiniu Object Storage CDN url.
OSS_ACCESS_KEY_ID "id" Aliyun accessKeyId.
OSS_ACCESS_SECRET "secret" Aliyun accessKeySecret.
OSS_REGION "oss-cn-qingdao" Aliyun Object Storage, Region.
OSS_BUCKET "bucket" Aliyun Object Storage, Bucket.
OSS_URL "https://cdn.xxx.com" Aliyun Object Storage CDN url.
OSS_INTERNAL false Access aliyun OSS with aliyun internal network or not, default is false. If your servers are running on aliyun too, you can set "true" to save lot of money.
COS_SECRE_ID "" Tencent Cloud Object Storage SecretId.
COS_SECRE_KEY "" SecretKey.
COS_BUCKET "bucketname-12345678" Bucket.
COS_REGION "ap-chengdu" Region.
COS_URL "https://cdn.xxx.com" Object Storage CDN url.

Seven cattle object storage: developer.qiniu.com/kodo/sdk/12… Ali Cloud Object Storage: github.com/ali-sdk/ali… Tencent Cloud Object Storage: github.com/tencentyun/…

The API documentation

Swagger: https://yourdomain/documentation

The tokens in the API need to be sha-512 encrypted.

Github webhooks: https://yourdomain/build/webhooks

Content type: application/json

Secret: your Token

Electron Application Configuration Guide

yarn add electron-builder electron-simple-updater -DCopy the code

About electron – builder electron – simple – updater

Add build configuration information to your package.json file (www.electron.build):

"scripts": {
  "build": "node config/build.js && electron-builder",
  "build:dir": "node config/build.js && electron-builder --dir",
  ...
},
"build": {
  "productName": "Your App Name",
  "appId": "com.appid.abc",
  "directories": {
    "output": "build"
  },
  "files": [
    "dist/electron/**/*"
  ],
  "dmg": {
    "contents": [
      {
        "x": 410,
        "y": 150,
        "type": "link",
        "path": "/Applications"
      },
      {
        "x": 130,
        "y": 150,
        "type": "file"
      }
    ]
  },
  "mac": {
    "icon": "build/icons/icon.icns"
  },
  "win": {
    "icon": "build/icons/icon.ico",
    "target": "squirrel"
  },
  "linux": {
    "artifactName": "${productName}-${version}-${arch}.${ext}",
    "icon": "build/icons"
  },
  "squirrelWindows": {
    "iconUrl": "https://yourServer/app/icon.ico"
  }
},Copy the code

Mac APP compilation and code signing

Install Xcode 10.2 \ BREW (YARN 1.15.2) \ NVM (Node 11.13.0) in macOS Majave (10.14.4) and run Xcode at least once.

Git and rsync are installed on the operating system by default.

Open the SSHD:

sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plistCopy the code

Add your server public key to Mac ~/.ssh/authorized_keys. Add your Mac public key to the server ~/.ssh/authorized_keys.

Install rsync on your Linux server and start the SSH service.