Electron Production Build & Release Guide
This skill provides enterprise-grade best practices for building, signing, releasing, and distributing Electron applications with emphasis on security, reliability, performance, and user trust.
Quick Reference
- Build Configuration: For electron-vite production config, bundle optimization, and pre-build checks.
- Code Signing: Platform-specific signing for Windows (EV certificates), macOS (Developer ID + notarization), and Linux (GPG).
- Auto-Updates: electron-updater configuration, staged rollouts, and update testing.
- Release Workflows: GitHub Actions CI/CD pipelines for multi-platform builds.
- Distribution: GitHub Releases, Cloudflare R2, or private server hosting.
Core Principles
- Security First: All production builds must be code-signed; macOS builds must be notarized.
- Pre-Build Verification: Always run , , , and before builds.
- Semantic Versioning: Follow SemVer strictly (MAJOR.MINOR.PATCH).
- Staged Rollouts: Release to a percentage of users first, then expand gradually.
Build Strategy
Pre-Build Checklist
Before every production build:
- Check dependencies for vulnerabilities:
- Verify code quality:
pnpm run typecheck && pnpm run lint
- Run test suite:
pnpm run test && pnpm run test:e2e
- Check bundle size:
- Verify environment configuration
Production Build Optimization
- Remove all and statements
- Tree-shake unused dependencies
- Split vendor chunks (React, UI libraries)
- Compress images and assets
- Lazy load non-critical modules
- Disable source maps for distribution (ship separately if needed)
- Use production-mode build flags
Target Bundle Sizes
| Component | Target |
|---|
| Main process | < 2 MB |
| Renderer | < 5 MB |
| Total package | < 150 MB |
| Install size | < 250 MB |
Code Signing
Windows (EV Certificate Required)
Microsoft requires Extended Validation (EV) certificates since June 2023.
Recommended: Use cloud-based signing (DigiCert KeyLocker or Azure Trusted Signing).
Never use self-signed certificates for distribution.
macOS (Developer ID + Notarization)
Two-step process:
- Code Signing: Uses Developer ID Certificate
- Notarization: Apple scans for malware (required for distribution)
Key requirements:
- in electron-builder config
- Valid entitlements.mac.plist
- APPLE_TEAM_ID, APPLE_ID, and APPLE_APP_SPECIFIC_PASSWORD environment variables
Linux (GPG)
Sign release artifacts with GPG:
bash
gpg --detach-sign -u YOUR_KEY_ID dist/packages/*.AppImage
gpg --detach-sign -u YOUR_KEY_ID dist/packages/*.deb
Auto-Update Implementation
electron-updater Configuration
Configure publish provider in electron-builder.yml:
yaml
publish:
provider: github
owner: your-username
repo: your-repo
releaseType: release
Staged Rollout Strategy
Reduce risk by gradually rolling out updates:
- Day 1: 10% of users
- Day 2: 25% of users
- Day 3: 50% of users
- Day 4: 100% of users
If issues detected:
- Do NOT release same version again (users will ignore update)
- Release a higher version (e.g., 1.0.1 -> 1.0.2)
- Consider reverting to previous version if critical bug
Testing Auto-Update Locally
Use
for local testing. Test the full update cycle before releasing.
Release Workflow
Manual Release Checklist
Before creating release tag:
Creating a Release
bash
git tag -a v1.2.3 -m "Release v1.2.3"
git push origin v1.2.3
GitHub Actions automatically handles:
- Building for Windows, macOS, Linux
- Code signing
- Notarization (macOS)
- Creating GitHub Release
- Publishing artifacts
Distribution Options
GitHub Releases (Recommended)
- Free and reliable
- Built-in auto-update support
- Version management
- Release notes
Cloudflare R2
S3-compatible storage with R2 endpoint. Configure environment variables:
- R2_BUCKET_NAME
- R2_ACCOUNT_ID
- R2_ACCESS_KEY_ID
- R2_SECRET_ACCESS_KEY
- UPDATE_FEED_URL
Private Server (Generic HTTP)
Requires serving
,
, and all artifacts via HTTPS.
Security Checklist
Before release, verify:
Troubleshooting
| Issue | Solution |
|---|
| Auto-update not triggering | Verify exists, check GitHub releases config |
| Code signing fails | Renew certificate, verify fingerprint |
| Windows SmartScreen warning | Distribute widely, file with Microsoft for reputation |
| macOS "cannot verify developer" | Re-notarize, check team ID and certificate |
| Large app download | Analyze with ANALYZE=true pnpm run build
, enable compression |
| Blank screen in production | Use relative paths (), verify build output |
Validation Checklist
Before finishing a task involving Electron releases:
For detailed configuration examples, code samples, and GitHub Actions workflows, refer to
.