electrobun-build
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseElectrobun Build
Electrobun 构建
Builds a distributable app bundle and installer for the current platform using .
electrobun build使用 为当前平台构建可分发的应用包和安装程序。
electrobun buildBuild Environments
构建环境
| Environment | Command | Codesign | Updates | Patch gen |
|---|---|---|---|---|
| | No | Disabled | No |
| | Yes (if configured) | Enabled | Yes |
| | Yes (if configured) | Enabled | Yes |
ELECTROBUN_BUILD_ENVpostBuild| 环境 | 命令 | 代码签名 | 自动更新 | 生成补丁 |
|---|---|---|---|---|
| | 否 | 禁用 | 否 |
| | 是(已配置时) | 启用 | 是 |
| | 是(已配置时) | 启用 | 是 |
ELECTROBUN_BUILD_ENVpostBuildPlatform Prerequisites
平台前置条件
macOS (Intel + Apple Silicon)
macOS(Intel + Apple Silicon)
bash
xcode-select --install # Xcode Command Line Tools
brew install cmakeProduces: installer + update tarball
Toolchain: + + (all from Xcode CLT)
Architectures: (Apple Silicon), (Intel) — build runs on matching host
.dmg.app.tar.zstclang++makeinstall_name_toolarm64x64bash
xcode-select --install # Xcode Command Line Tools
brew install cmake产物: 安装包 + 更新 tar 包
工具链: + + (均来自 Xcode CLT)
架构: (Apple Silicon)、(Intel)—— 构建在匹配的宿主机上运行
.dmg.app.tar.zstclang++makeinstall_name_toolarm64x64Windows
Windows
- Visual Studio 2022 with component
Microsoft.VisualStudio.Component.VC.Tools.x86.x64 - cmake (available via VS installer or standalone)
The CLI uses to find VS and to configure the environment automatically.
vswhere.exevcvarsall.batProduces: self-extracting installer (in a ) + update tarball
Toolchain: + via MSVC
Architecture: only
.exe.zip.tar.zstcl.exelink.exex64- Visual Studio 2022,包含组件
Microsoft.VisualStudio.Component.VC.Tools.x86.x64 - cmake(可通过 VS 安装器或独立安装获得)
CLI 使用 查找 VS,并通过 自动配置环境。
vswhere.exevcvarsall.bat产物: 自解压安装程序(打包在 中)+ 更新 tar 包
工具链: 通过 MSVC 使用 +
架构: 仅
.exe.zip.tar.zstcl.exelink.exex64Linux
Linux
bash
sudo apt-get install -y \
build-essential \
cmake \
pkg-config \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
fuse \
libfuse2libfuse2Produces: + update tarball
Toolchain: + +
Architectures: ,
.AppImage.tar.zstg++makepkg-configx64arm64bash
sudo apt-get install -y \
build-essential \
cmake \
pkg-config \
libgtk-3-dev \
libwebkit2gtk-4.1-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
fuse \
libfuse2创建 AppImage 需要 。
libfuse2产物: + 更新 tar 包
工具链: + +
架构: 、
.AppImage.tar.zstg++makepkg-configx64arm64electrobun.config.ts — Build Options
electrobun.config.ts —— 构建选项
General (build.*
)
build.*通用配置(build.*
)
build.*typescript
build: {
bun: {
entrypoint: "src/bun/index.ts", // default
// + any Bun.build() options (splitting, minify, target, etc.)
},
views: {
// Each key becomes the view's URL scheme: mainview://index.html
mainview: {
entrypoint: "src/mainview/index.ts",
// + any Bun.build() options per view
},
},
copy: {
// Record<sourcePath, destPathInBuildOutput>
"src/assets/icon.png": "resources/icon.png",
},
buildFolder: "build", // default: "build"
artifactFolder: "artifacts", // default: "artifacts"
targets: "current", // default: build for host platform
useAsar: false, // default: false — pack assets into ASAR archive
asarUnpack: ["*.node", "*.dll", "*.dylib", "*.so"], // always unpacked from ASAR
cefVersion: undefined, // override bundled CEF version
bunVersion: undefined, // override bundled Bun runtime version
wgpuVersion: undefined, // override latest electrobun-dawn release
locales: "*", // ICU locales to include ("*" = all); Linux/Windows only
}typescript
build: {
bun: {
entrypoint: "src/bun/index.ts", // 默认值
// + 任意 Bun.build() 选项(splitting、minify、target 等)
},
views: {
// 每个键都会成为该 view 的 URL scheme:mainview://index.html
mainview: {
entrypoint: "src/mainview/index.ts",
// + 每个 view 可单独配置任意 Bun.build() 选项
},
},
copy: {
// Record<sourcePath, destPathInBuildOutput>
"src/assets/icon.png": "resources/icon.png",
},
buildFolder: "build", // 默认值:"build"
artifactFolder: "artifacts", // 默认值:"artifacts"
targets: "current", // 默认值:为宿主平台构建
useAsar: false, // 默认值:false —— 将资源打包进 ASAR 归档
asarUnpack: ["*.node", "*.dll", "*.dylib", "*.so"], // 始终从 ASAR 中解包
cefVersion: undefined, // 覆盖内置的 CEF 版本
bunVersion: undefined, // 覆盖内置的 Bun 运行时版本
wgpuVersion: undefined, // 覆盖最新版 electrobun-dawn 发布版本
locales: "*", // 需要包含的 ICU locale("*" = 全部);仅限 Linux/Windows
}macOS (build.mac
)
build.macmacOS(build.mac
)
build.mactypescript
build: {
mac: {
bundleCEF: false, // bundle CEF instead of WKWebView (~120MB)
bundleWGPU: false, // bundle Dawn for native GPU rendering
defaultRenderer: "native", // "native" | "cef"
codesign: false, // enable Apple code signing
notarize: false, // enable notarization (requires codesign: true)
icons: undefined, // path to .iconset folder or .icns file
chromiumFlags: {}, // Record<string, string|true> — CEF-only flags
entitlements: undefined, // path to custom entitlements.plist
}
}typescript
build: {
mac: {
bundleCEF: false, // 打包 CEF 而非使用 WKWebView(约 120MB)
bundleWGPU: false, // 打包 Dawn 以启用原生 GPU 渲染
defaultRenderer: "native", // "native" | "cef"
codesign: false, // 启用 Apple 代码签名
notarize: false, // 启用公证(需要 codesign: true)
icons: undefined, // .iconset 文件夹或 .icns 文件路径
chromiumFlags: {}, // Record<string, string|true> —— 仅 CEF 可用
entitlements: undefined, // 自定义 entitlements.plist 路径
}
}Windows (build.win
)
build.winWindows(build.win
)
build.wintypescript
build: {
win: {
bundleCEF: false, // CEF is always needed on Windows (no OS webview)
bundleWGPU: false, // bundle Dawn
icons: undefined, // path to .ico file
chromiumFlags: {}, // CEF Chromium flags
}
}typescript
build: {
win: {
bundleCEF: false, // Windows 上始终需要 CEF(没有系统 webview)
bundleWGPU: false, // 打包 Dawn
icons: undefined, // .ico 文件路径
chromiumFlags: {}, // CEF Chromium 标志
}
}Linux (build.linux
)
build.linuxLinux(build.linux
)
build.linuxtypescript
build: {
linux: {
bundleCEF: false, // bundle CEF instead of GTKWebKit
bundleWGPU: false, // bundle Dawn
icons: undefined, // icon file path
chromiumFlags: {}, // CEF Chromium flags
}
}Linux multi-view note: GTKWebKit is the default system webview. For apps with multiple views or needing consistent rendering,is strongly recommended.bundleCEF: true
typescript
build: {
linux: {
bundleCEF: false, // 打包 CEF 而非使用 GTKWebKit
bundleWGPU: false, // 打包 Dawn
icons: undefined, // 图标文件路径
chromiumFlags: {}, // CEF Chromium 标志
}
}Linux 多 view 说明: GTKWebKit 是默认的系统 webview。对于包含多个 view 或需要一致渲染表现的应用,强烈建议设置。bundleCEF: true
Code Signing (macOS)
代码签名(macOS)
Code signing runs automatically when and is set. It only runs when , host OS is macOS, and target OS is macOS.
build.mac.codesign: trueELECTROBUN_DEVELOPER_IDbuildEnvironment !== "dev"当 且设置了 时会自动执行代码签名。仅在 、宿主系统为 macOS 且目标系统为 macOS 时运行。
build.mac.codesign: trueELECTROBUN_DEVELOPER_IDbuildEnvironment !== "dev"Signing Order
签名顺序
- CEF framework internals (if )
bundleCEF: true - CEF helper applications
- All files and executables inside
.dylibrecursivelyMacOS/ - The executable
launcher - The entire bundle
.app - The installer
.dmg
- CEF framework 内部文件(当 时)
bundleCEF: true - CEF helper 应用
- 目录下递归的所有
MacOS/文件和可执行文件.dylib - 可执行文件
launcher - 整个 应用包
.app - 安装包
.dmg
Required Environment Variables
必需的环境变量
bash
export ELECTROBUN_DEVELOPER_ID="Developer ID Application: Your Name (TEAMID)"bash
export ELECTROBUN_DEVELOPER_ID="Developer ID Application: Your Name (TEAMID)"Notarization (requires codesign: true)
公证(需要 codesign: true)
export ELECTROBUN_APPLEID="you@example.com"
export ELECTROBUN_APPLEIDPASS="xxxx-xxxx-xxxx-xxxx" # app-specific password
export ELECTROBUN_TEAMID="ABCDE12345"
undefinedexport ELECTROBUN_APPLEID="you@example.com"
export ELECTROBUN_APPLEIDPASS="xxxx-xxxx-xxxx-xxxx" # 应用专用密码
export ELECTROBUN_TEAMID="ABCDE12345"
undefinedNotarization Sequence
公证流程
- bundle zipped
.app - — blocks until Apple responds
xcrun notarytool submit --wait - On success: attaches ticket to bundle
xcrun stapler staple - created, then also code-signed and notarized
.dmg
- 应用包压缩
.app - —— 阻塞直到 Apple 返回结果
xcrun notarytool submit --wait - 成功后:将票据附加到应用包
xcrun stapler staple - 生成 ,随后同样进行代码签名和公证
.dmg
Artifact Output
产物输出
All artifacts land in (or ).
artifacts/build.artifactFolder所有产物都会落在 (或 )目录中。
artifacts/build.artifactFolderNaming Convention: {channel}-{os}-{arch}-{filename}
{channel}-{os}-{arch}-{filename}命名约定:{channel}-{os}-{arch}-{filename}
{channel}-{os}-{arch}-{filename}| Platform | Installer | Update Tarball | Manifest |
|---|---|---|---|
| macOS stable arm64 | | | |
| macOS canary arm64 | | | |
| macOS stable x64 | | | |
| Windows stable x64 | | | |
| Windows canary x64 | | | |
| Linux stable x64 | | | |
| Linux canary arm64 | | | |
Patch files: (generated if previous tarball available)
{channel}-{os}-{arch}-{fromHash}.patch| 平台 | 安装包 | 更新 tar 包 | Manifest |
|---|---|---|---|
| macOS stable arm64 | | | |
| macOS canary arm64 | | | |
| macOS stable x64 | | | |
| Windows stable x64 | | | |
| Windows canary x64 | | | |
| Linux stable x64 | | | |
| Linux canary arm64 | | | |
补丁文件: (在存在上一个 tar 包时生成)
{channel}-{os}-{arch}-{fromHash}.patchupdate.json
Contents
update.jsonupdate.json
内容
update.jsonjson
{
"version": "1.0.0",
"hash": "<sha256-of-uncompressed-tarball>",
"platform": "macos",
"arch": "arm64"
}json
{
"version": "1.0.0",
"hash": "<sha256-of-uncompressed-tarball>",
"platform": "macos",
"arch": "arm64"
}version.json
Inside the App Bundle
version.json应用包内的 version.json
version.jsonmacOS: MyApp.app/Contents/Resources/version.json
Windows: MyApp/Resources/version.json
Linux: MyApp/Resources/version.jsonjson
{
"version": "1.0.0",
"hash": "<content-hash>",
"channel": "stable",
"baseUrl": "https://updates.example.com/",
"name": "MyApp",
"identifier": "com.example.myapp"
}macOS: MyApp.app/Contents/Resources/version.json
Windows: MyApp/Resources/version.json
Linux: MyApp/Resources/version.jsonjson
{
"version": "1.0.0",
"hash": "<content-hash>",
"channel": "stable",
"baseUrl": "https://updates.example.com/",
"name": "MyApp",
"identifier": "com.example.myapp"
}Environment Variables Reference
环境变量参考
Set by Electrobun CLI — passed to postBuild
scripts
postBuild由 Electrobun CLI 设置 —— 传递给 postBuild
脚本
postBuild| Variable | Example |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
| 变量 | 示例 |
|---|---|
| |
| |
| |
| |
| |
| |
| |
| |
Set by you — version and runtime overrides
由你设置 —— 版本与运行时覆盖
| Variable | Purpose |
|---|---|
| Override CEF version without editing config |
| Override Bun runtime version |
| Force console output on Windows in production |
does not exist. Code signing is controlled byELECTROBUN_SKIP_CODESIGNandconfig.build.mac.codesign.buildEnvironment
| 变量 | 用途 |
|---|---|
| 无需修改配置即可覆盖 CEF 版本 |
| 覆盖 Bun 运行时版本 |
| 在生产环境的 Windows 上强制开启控制台输出 |
并不存在。 代码签名由ELECTROBUN_SKIP_CODESIGN和config.build.mac.codesign控制。buildEnvironment
GitHub Actions CI/CD Matrix
GitHub Actions CI/CD 矩阵
Official runners used by Electrobun's own release workflow:
yaml
strategy:
matrix:
include:
- runner: macos-14 # Apple Silicon
arch: arm64
- runner: macos-15-intel # Intel
arch: x64
- runner: ubuntu-24.04 # Linux x64
arch: x64
- runner: ubuntu-24.04-arm # Linux ARM64
arch: arm64
- runner: windows-2025 # Windows x64
arch: x64Electrobun 自身发布工作流所使用的官方 runner:
yaml
strategy:
matrix:
include:
- runner: macos-14 # Apple Silicon
arch: arm64
- runner: macos-15-intel # Intel
arch: x64
- runner: ubuntu-24.04 # Linux x64
arch: x64
- runner: ubuntu-24.04-arm # Linux ARM64
arch: arm64
- runner: windows-2025 # Windows x64
arch: x64Required GitHub Secrets
必需的 GitHub Secrets
| Secret | Purpose |
|---|---|
| Base64-encoded .p12 certificate |
| Certificate password |
| Apple Developer ID string |
| Apple ID email |
| App-specific password |
| Apple Team ID |
| Cloudflare R2 endpoint URL |
| R2 access key |
| R2 secret key |
| R2 bucket name |
| npm publish token |
| Secret | 用途 |
|---|---|
| Base64 编码的 .p12 证书 |
| 证书密码 |
| Apple Developer ID 字符串 |
| Apple ID 邮箱 |
| 应用专用密码 |
| Apple Team ID |
| Cloudflare R2 endpoint URL |
| R2 access key |
| R2 secret key |
| R2 bucket 名称 |
| npm publish token |
macOS Certificate Import Step
macOS 证书导入步骤
yaml
- name: Install Apple Certificate
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p "" build.keychain
security import certificate.p12 -k build.keychain \
-P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
security list-keychains -d user -s build.keychain
security set-keychain-settings -t 3600 -u build.keychain
security unlock-keychain -p "" build.keychainyaml
- name: Install Apple Certificate
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p "" build.keychain
security import certificate.p12 -k build.keychain \
-P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
security list-keychains -d user -s build.keychain
security set-keychain-settings -t 3600 -u build.keychain
security unlock-keychain -p "" build.keychainCommon Build Failures
常见构建失败
| Error | Cause | Fix |
|---|---|---|
| View URL not found | Config key doesn't match | |
| Blank window | Script tag points to | Use |
| Codesign fails locally | Certificate not in keychain | Run |
| Notarization fails | Hardened runtime without JIT entitlement | Add |
| Linux AppImage won't run | FUSE missing | |
| Windows MSVC not found | VS component missing | Install |
| CEF build fails | cmake not installed | Install cmake for the platform |
| | Set |
| WGPU GC crash after frames | FFI objects not pinned | Push all GPU objects to |
| 错误 | 原因 | 修复方式 |
|---|---|---|
| View URL 未找到 | 配置键与 | |
| 窗口空白 | script 标签指向 | 在 HTML 中使用 |
| 本地代码签名失败 | 证书不在 keychain 中 | 运行 |
| 公证失败 | 启用了 hardened runtime 但缺少 JIT entitlement | 在 entitlements.plist 中添加 |
| Linux AppImage 无法运行 | 缺少 FUSE | |
| 找不到 Windows MSVC | 缺少 VS 组件 | 通过 VS Installer 安装 |
| CEF 构建失败 | 未安装 cmake | 为该平台安装 cmake |
找不到 | 未设置 | 在配置中设置 |
| 渲染若干帧后 WGPU GC 崩溃 | FFI 对象未被固定 | 将所有 GPU 对象放入 |