Skip to content

Conversation

@1jehuang
Copy link
Owner

Summary

Implements automatic update checking and installation for end users who install jcode from GitHub Releases.

Key design decisions:

  • Only binaries built by CI (with JCODE_RELEASE_BUILD=1) get auto-updated
  • Local developer builds (cargo build) never auto-update
  • Uses git commit hash comparison (not version numbers) to determine if update needed
  • Includes crash loop detection with automatic rollback to previous version

Features

  • Update checking: Checks GitHub Releases API on startup (with 24h cooldown)
  • Two modes:
    • Developer mode: git pull + cargo build (for repo checkouts)
    • Release mode: Download pre-built binary from GitHub Releases
  • Crash loop protection: If new version crashes on startup, automatically rolls back
  • Atomic install: Downloads to temp file, then atomic rename + symlink swap
  • CLI flags:
    • --no-update: Skip update check
    • --auto-update: Auto-install updates (default: just notify)
    • jcode update: Manual update command

Files changed

  • src/update.rs: New module with GitHub API client, download logic, crash detection
  • build.rs: Embeds JCODE_RELEASE_BUILD flag at compile time
  • src/main.rs: Integrates update check into startup flow
  • .github/workflows/release.yml: CI workflow for building release binaries

Test plan

  • Unit tests for update module pass
  • jcode update works in developer mode (git pull + build)
  • Release build auto-update (requires publishing a release first)
  • Crash loop detection (requires simulating a crash)

Implements automatic update checking and installation for end users:

- Adds src/update.rs module with GitHub Releases API integration
- Release builds (built by CI) auto-check for updates on startup
- Developer builds (local cargo build) never auto-update
- Includes crash loop detection with automatic rollback
- Supports both developer mode (git pull) and release mode (GitHub download)
- Adds GitHub Actions workflow for building release binaries

Key features:
- Only binaries with JCODE_RELEASE_BUILD=1 get auto-updated
- Atomic install via temp file + symlink swap
- SHA256 checksum verification for downloads
- 24-hour cooldown between update checks
- --no-update flag to skip update check
- --auto-update flag to install updates automatically
- `jcode update` command for manual updates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants