Replace the manual "jump to GitHub Release" update flow with native in-app auto-update powered by electron-updater. The app now silently downloads updates in the background and prompts the user to restart when ready. Browser mode (`npm run dev`) retains the existing polling fallback via `/api/app/updates`. Main process (electron/updater.ts — new): - Wrap electron-updater's autoUpdater, forward lifecycle events (checking / available / downloading / downloaded / error) to the renderer via IPC channel `updater:status` - Register `updater:check` and `updater:quit-and-install` IPC handlers - Auto-check 10s after launch, then every 4 hours - Only initialized in packaged mode (!isDev) Preload bridge (electron/preload.ts): - Expose `updater` namespace with checkForUpdates, quitAndInstall, and onStatus callback (same pattern as install.onProgress) Type declarations (src/types/electron.d.ts): - Add UpdateStatusEvent, ElectronUpdaterAPI interfaces - Add optional `updater` field to ElectronAPI Update hook (src/hooks/useUpdate.ts): - Extend UpdateInfo with downloadProgress, readyToInstall, isNativeUpdate - Add quitAndInstall to UpdateContextValue Renderer — dual-mode logic (src/components/layout/AppShell.tsx): - Detect `window.electronAPI?.updater` to choose between native IPC subscription (Electron) and HTTP polling (browser) - Map IPC events to UpdateInfo state, including download progress UI components: - UpdateDialog: three footer states — View Release (browser), progress bar + disabled button (downloading), Restart to Update (ready) - UpdateBanner (new): persistent top banner when update is downloaded, shown even after dialog is dismissed - NavRail: settings dot turns green + pulse when readyToInstall - GeneralSection: UpdateCard shows download %, restart button, or View Release depending on mode Build & CI: - electron-builder.yml: add `publish` config (github provider) to generate latest-mac.yml / latest.yml metadata + blockmap files - build.yml: change --publish never to --publish always with GH_TOKEN; release job now uses `gh release edit` instead of create i18n: - Add 6 translation keys (en + zh) for update UI strings Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
185 lines
5.4 KiB
YAML
185 lines
5.4 KiB
YAML
name: Build & Package
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
platform:
|
|
description: "Target platform"
|
|
required: true
|
|
default: "all"
|
|
type: choice
|
|
options:
|
|
- all
|
|
- windows
|
|
- macos
|
|
- linux
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build-windows:
|
|
if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'windows' }}
|
|
runs-on: windows-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Electron app
|
|
run: npm run electron:build
|
|
|
|
- name: Package for Windows
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: npx electron-builder --win --config electron-builder.yml --publish always
|
|
|
|
build-macos:
|
|
if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'macos' }}
|
|
runs-on: macos-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x64, arm64]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Electron app
|
|
run: npm run electron:build
|
|
|
|
- name: Package for macOS (${{ matrix.arch }})
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: npx electron-builder --mac --${{ matrix.arch }} --config electron-builder.yml --publish always
|
|
|
|
build-linux:
|
|
if: ${{ github.event_name == 'push' || inputs.platform == 'all' || inputs.platform == 'linux' }}
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
arch: [x64, arm64]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: 20
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build Electron app
|
|
run: npm run electron:build
|
|
|
|
- name: Package for Linux (${{ matrix.arch }})
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: npx electron-builder --linux --${{ matrix.arch }} --config electron-builder.yml --publish always
|
|
|
|
release:
|
|
if: ${{ always() && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') && !contains(needs.*.result, 'cancelled') }}
|
|
needs: [build-windows, build-macos, build-linux]
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get version and previous tag
|
|
id: meta
|
|
run: |
|
|
VERSION=${GITHUB_REF_NAME#v}
|
|
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
|
|
PREV_TAG=$(git tag --sort=-creatordate | grep '^v' | sed -n '2p' || echo "")
|
|
echo "prev_tag=$PREV_TAG" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
run: |
|
|
PREV_TAG="${{ steps.meta.outputs.prev_tag }}"
|
|
if [ -n "$PREV_TAG" ]; then
|
|
RANGE="${PREV_TAG}..HEAD"
|
|
else
|
|
RANGE="HEAD"
|
|
fi
|
|
{
|
|
echo "changelog<<CHANGELOG_EOF"
|
|
git log "$RANGE" --pretty=format:'| `%h` | %s |'
|
|
echo ""
|
|
echo "CHANGELOG_EOF"
|
|
} >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Update release notes
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
VERSION="${{ steps.meta.outputs.version }}"
|
|
PREV_TAG="${{ steps.meta.outputs.prev_tag }}"
|
|
|
|
cat > release-notes.md << 'NOTES_EOF'
|
|
## Downloads
|
|
|
|
**Windows**
|
|
- **CodePilot Setup ${{ steps.meta.outputs.version }}.exe** — Windows installer (x64 + arm64)
|
|
|
|
**macOS**
|
|
- **CodePilot-${{ steps.meta.outputs.version }}-arm64.dmg** — macOS Apple Silicon (M1/M2/M3/M4)
|
|
- **CodePilot-${{ steps.meta.outputs.version }}-x64.dmg** — macOS Intel
|
|
|
|
**Linux**
|
|
- **AppImage / deb / rpm** — x64 and arm64
|
|
|
|
## Installation
|
|
|
|
**Windows**: Download the exe installer, double-click to install.
|
|
|
|
**macOS**:
|
|
1. Download the DMG for your chip architecture
|
|
2. Open the DMG, drag CodePilot into Applications
|
|
3. If you see a security prompt on first launch, go to **System Settings > Privacy & Security** and click "Open Anyway"
|
|
4. Configure your Anthropic API Key in Settings
|
|
|
|
**Linux**: Run the AppImage directly, or install via deb/rpm package.
|
|
|
|
## Requirements
|
|
|
|
- Windows 10+ / macOS 12.0+ / Linux (glibc 2.31+)
|
|
- Anthropic API Key or `ANTHROPIC_API_KEY` environment variable
|
|
- Claude Code CLI recommended for code features
|
|
|
|
## Changelog
|
|
NOTES_EOF
|
|
|
|
if [ -n "$PREV_TAG" ]; then
|
|
echo "" >> release-notes.md
|
|
echo "| Commit | Description |" >> release-notes.md
|
|
echo "|--------|-------------|" >> release-notes.md
|
|
cat >> release-notes.md << 'CHANGELOG_INLINE_EOF'
|
|
${{ steps.changelog.outputs.changelog }}
|
|
CHANGELOG_INLINE_EOF
|
|
fi
|
|
|
|
# Update the draft release created by electron-builder with full notes
|
|
gh release edit "${GITHUB_REF_NAME}" \
|
|
--title "CodePilot v${VERSION}" \
|
|
--notes-file release-notes.md \
|
|
--latest \
|
|
--draft=false
|