Skip to content

feat: add self-update system with graceful restart#547

Merged
wizzomafizzo merged 8 commits intomainfrom
feat/auto-update
Mar 3, 2026
Merged

feat: add self-update system with graceful restart#547
wizzomafizzo merged 8 commits intomainfrom
feat/auto-update

Conversation

@wizzomafizzo
Copy link
Member

Summary

  • Add self-update infrastructure using go-selfupdate with platform-specific asset filtering against https://updates.zaparoo.org/ (GitHub releases)
  • Add update.check and update.apply API methods with startup auto-check (configurable via updater.auto_update config)
  • Add pkg/service/restart package for graceful binary re-execution after updates (syscall.Exec on Unix, os.StartProcess on Windows)
  • Add ResponseWithCallback pattern to flush API response before triggering restart
  • Add RestartService() / RestartRequested() state management for clean shutdown-and-restart flow
  • Default auto-update off for package-managed installs (Batocera pacman, MiSTer Downloader)
  • Add restart.ExecIfRequested() helper to deduplicate restart logic across 5 platform entry points
  • Add update manifest generator script for CI
  • Add CI workflow for building update assets

- Add update.check and update.apply API methods using go-selfupdate
  with injectable functions for testability
- Add CheckAndNotify startup routine that posts inbox notification
  when an update is available, with injectable CheckFn and context
- Add auto_update config option (defaults to true) with
  IsDevelopmentVersion guard to skip dev builds
- Add publish-update-manifest CI job that generates checksums and
  manifest YAML, uploads to Bunny CDN
- Add media indexing guard to reject update.apply during active
  database writes
- Add injectable exitFn to HandleUpdateApply to prevent os.Exit
  from killing test processes
- Add comprehensive tests for updater, API handlers, and config
- Add ManagedByPackageManager() to Platform interface with detection
  for MiSTer Downloader and Batocera pacman
- Rename AutoUpdate param from managedInstall to defaultEnabled for
  consistency with VirtualGamepadEnabled pattern
- Add integration test for managed install disabling auto-update
- Add inline comment documenting MiSTer Downloader database IDs
Replace os.Exit-based shutdown with graceful RestartService() state
flag and restart.Exec() for binary re-execution after updates.
Extract restart.ExecIfRequested() helper to deduplicate the
restart-check pattern across 5 platform entry points. Add
ResponseWithCallback to ensure API responses are flushed before
triggering restart. Add tests for restart and state changes.
@sentry
Copy link

sentry bot commented Mar 2, 2026

Add nolint:gosec to os.StartProcess in restart_windows.go matching
the pattern in restart_unix.go. Extract manifest generator logic into
testable functions with 10 tests. Add ResponseWithCallback POST
handler test covering the AfterWrite unwrap path. Add cancelled
context tests for updater Check/Apply covering makeUpdater and error
branches.
Detect pre-release versions (alpha, beta, rc, nightly) by checking
for a hyphen in the version tag. Mark them as pre-release in GitHub
and skip publishing the update manifest to CDN.
Move publish-update-manifest from build.yml into a separate workflow
triggered on release published events. This allows editing release
notes before the manifest is pushed to CDN. Add --release-notes flag
to the manifest generator to include release body in the manifest.
@wizzomafizzo wizzomafizzo merged commit 4c02bc1 into main Mar 3, 2026
10 checks passed
@wizzomafizzo wizzomafizzo deleted the feat/auto-update branch March 3, 2026 02:56
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.

1 participant