問題描述
如何使用電子/電子生成器創建發布通道? (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"