package main import ( "context" _ "embed" "log" "os" "github.com/wailsapp/wails/v3/pkg/application" "github.com/wailsapp/wails/v3/pkg/updater" giteaprovider "AniTrack/updater/gitea" ) //go:embed updater.pub var updaterPublicKey []byte // maybeEnableUpdater wires self-updates: desktop production builds only. // Mobile stays on Obtainium; dev builds never phone home. The startup check // is headless — the builtin window opens only when an update is found, via a // second CheckAndInstall (one redundant index round-trip, negligible). func maybeEnableUpdater(app *application.App) { if !updaterAutoCheck { return } if !application.System.IsDesktop() { return } gh, err := giteaprovider.New(giteaprovider.Config{ BaseURL: "https://git.linuxhg.com", Owner: "john-okeefe", Repo: "Anitrack", AssetName: "AniTrack-linux-amd64", // Beta channel (rc tags) for testing: ANITRACK_UPDATER_CHANNEL=beta. AllowPrerelease: os.Getenv("ANITRACK_UPDATER_CHANNEL") == "beta", }) if err != nil { log.Printf("updater: %s", err) return } if err := app.Updater.Init(updater.Config{ CurrentVersion: appVersion(), Providers: []updater.Provider{gh}, PublicKey: updaterPublicKey, Window: &updater.BuiltinWindow{ CSS: ":root { --accent: #4d9fff; }", }, }); err != nil { log.Printf("updater: init: %s", err) return } go func() { rel, err := app.Updater.Check(context.Background()) if err != nil { log.Printf("updater: check: %s", err) return } if rel == nil { return } log.Printf("updater: %s available, opening installer", rel.Version) if err := app.Updater.CheckAndInstall(context.Background()); err != nil { log.Printf("updater: install: %s", err) } }() }