npm install electron-updater
"build": {
"appId": "com.ttj.typingtool",
"publish": { "provider": "github", "owner": "내깃허브ID", "repo": "typing-tool" },
"win": { "target": "nsis" },
"mac": { "target": ["dmg", "zip"] }
}
※ electron-updater는 실행 중에 쓰이므로 devDependencies가 아닌 dependencies에 설치
const { app, BrowserWindow, dialog } = require('electron');
const { autoUpdater } = require('electron-updater');
app.whenReady().then(() => {
createWindow();
autoUpdater.checkForUpdatesAndNotify(); // 실행 시 확인
});
autoUpdater.on('update-downloaded', async () => {
const { response } = await dialog.showMessageBox({
type: 'info',
buttons: ['지금 재시작', '나중에'],
message: '새 버전이 준비되었습니다. 재시작할까요?',
});
if (response === 0) autoUpdater.quitAndInstall();
});
"version": "1.0.1" 처럼 버전 올리기npx electron-builder --publish alwaysnpm start(개발 모드)에서는 업데이트가 동작하지 않습니다. 반드시 설치한 앱으로 테스트.
| 항목 | 🪟 Windows (NSIS) | 🍎 Mac |
|---|---|---|
| 코드 서명 | 없어도 업데이트 동작 | 필수 — 없으면 업데이트 실패 |
| 필요 비용 | 없음 | Apple Developer Program (유료) |
| 추가 작업 | — | 인증서 등록 + 공증(notarize) |
| 업데이트 파일 | .exe + latest.yml | .zip + latest-mac.yml |
4-4 — 코드 난독화로
프로그램 로직 보호하기