如何使用電子/電子生成器創建發布通道? (How to create release channels with electron/electron-builder?)


問題描述

如何使用電子/電子生成器創建發布通道? (How to create release channels with electron/electron‑builder?)

釋放所有用戶並獲得更新。</p>

我希望應用程序是獨立的 ‑ 用戶可以安裝兩個頻道並同時運行這兩個頻道。它們會有不同的名稱和不同的圖標。

我可以在分支中手動設置它們,但我真的想盡可能地自動化 ‑ 從 next 分支應該使用正確的名稱、圖標、ID 和更新程序,而不會有進入錯誤通道的風險。

有沒有辦法使用電子或電子生成器來做到這一點?


參考解法

方法 1:

It's possible with electron‑builder. I would have several build configurations and tell electron‑builder which to use when building.

For example, create file config/beta.json with the following setup:

{
  "appId": "com.company.beta",
  "productName": "App Beta",
  "directories": {
    "buildResources": "build/beta" // directory containing your build‑specific assets (e.g., beta icons ‑ icon.icns, icon.ico & background.png)
  },
  "mac": {
    "category": "public.app‑category.finance"
  },
  "win": {
    "target": [
      "nsis"
    ]
  },
  "nsis": {
    "perMachine": false
  },
  "publish": [
    {
      "provider": "s3",
      "bucket": "com‑app‑beta" // dedicated S3 bucket for each build
    }
  ],
}

And duplicate config/beta.json for next.json and current.json (make sure to edit settings accordingly).

In package.json, add the following build scripts (note ‑‑em.name=app‑beta to overwrite package.json's "name" value):

{
    "scripts": {
        "build": "build ‑owl ‑‑x64 ‑‑config ./config/current.json ‑p always ‑‑em.name=app",
        "build‑beta": "build ‑owl ‑‑x64 ‑‑config ./config/beta.json ‑p always ‑‑em.name=app‑beta",
        "build‑next": "build ‑owl ‑‑x64 ‑‑config ./config/next.json ‑p always ‑‑em.name=app‑next"
    }
}

Run build script when ready to deploy:

npm run build‑beta

方法 2:

Using electron‑builder version 20.15.1 and MacOS, @Jon Saw's solution needs a minor change because em option is not valid:

"build‑beta": "build ‑owl ‑‑x64 ‑‑config ./config/beta.json ‑p always ‑c.extraMetadata.name=app‑beta"

(by KeithJon Sawcaperonce)

參考文件

  1. How to create release channels with electron/electron‑builder? (CC BY‑SA 2.5/3.0/4.0)

#electron-builder #electron






相關問題

Electron Builder 代碼簽名下載證書錯誤 (Electron Builder Code Signing Download Certificate Error)

Electron 使用 electron-builder 創建 MSI 安裝程序 (Electron create MSI installer using electron-builder)

如何使用電子/電子生成器創建發布通道? (How to create release channels with electron/electron-builder?)

electron-builder,如何設置節點環境變量 (electron-builder, how to set node environmental variables)

電子應用Mac應用商店圖標問題->“缺少必需的圖標” (electron app Mac app store icon issue -> "missing required icon")

帶有 Vue 和 vue-cli-plugin-electron-builder 的電子應用程序無法與 Tesseract.js 一起使用 (Electron App with Vue and vue-cli-plugin-electron-builder can't working with Tesseract.js)

使用 Electron-builder 自定義 NSIS 安裝程序 (Customize NSIS installer with Electron-builder)

在 Mac 中打開 Electron 應用程序時出錯:“file:///Applications/../Contents/Resources/app.asar/dist/index.html” (Error in Opening Electron App in Mac:"file:///Applications/../Contents/Resources/app.asar/dist/index.html")

Mac Os 10.11.6 中 Windows 的 Electron Pakaging 問題 (Electron Pakaging issue for Windows in Mac Os 10.11.6)

對於 Mac,是否有關於基於電子的應用程序卸載的事件?還是一種區分安裝和更新的方法? (Is there an event on electron based app's uninstall, for Mac? Or a way to distinguish between an install and an update?)

Electron 應用架構 - IPC 與 API (Electron application architecture - IPC vs API)

公證問題:altool 不在 PATH 中? (Notarize issue: altool not in PATH?)







留言討論