mirror of
https://github.com/pvrzz/atmosphere.git
synced 2026-11-29 05:22:26 +00:00
Signed automatic updates from GitHub Releases
- Atmosphere checks the repo's latest release and offers new versions with their notes - Updates are signed; installed copies refuse anything not signed with the project key - Installer, macOS and AppImage builds update themselves; portable and deb/rpm link to the download - Release workflow builds, signs and publishes every platform with latest.json on a version tag - Check-for-updates row and automatic check setting in Settings - Release guide in docs/releasing.md
This commit is contained in:
@@ -157,6 +157,7 @@ async function init() {
|
||||
bindBackup();
|
||||
bindMini();
|
||||
bindConnect();
|
||||
bindUpdates();
|
||||
bindStats();
|
||||
await listen("atmosphere://job", (e) => onJob(e.payload));
|
||||
await listen("atmosphere://probe", (e) => onProbe(e.payload));
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
|
||||
<div class="sidebar-foot">
|
||||
<button class="nav-item" data-nav="settings"><span class="i" data-icon="settings"></span><span>Settings</span></button>
|
||||
<button class="update-chip" id="updateChip" hidden></button>
|
||||
<button class="engine-state" id="engineState" data-nav="settings" data-anchor="engine"></button>
|
||||
</div>
|
||||
</aside>
|
||||
@@ -258,6 +259,8 @@
|
||||
|
||||
<h2 id="set-app">App</h2>
|
||||
<div class="group">
|
||||
<div class="setting"><div><strong>Updates</strong><span id="updateInfo">Atmosphere</span></div><button class="btn" id="updateBtn" type="button"><span class="label">Check for updates</span><span class="spin" aria-hidden="true"></span></button></div>
|
||||
<label class="setting"><div><strong>Check for updates automatically</strong><span>When Atmosphere opens, it asks its GitHub releases page whether there's a newer version. Every update is signed and checked before it installs.</span></div><input type="checkbox" class="switch" data-key="checkUpdates" /></label>
|
||||
<div class="setting">
|
||||
<div><strong>Appearance</strong><span>Follows Windows unless you choose.</span></div>
|
||||
<div class="seg" data-seg="theme"><button type="button" data-value="system">System</button><button type="button" data-value="light">Light</button><button type="button" data-value="dark">Dark</button></div>
|
||||
@@ -375,5 +378,6 @@
|
||||
<script src="stats.js"></script>
|
||||
<script src="miniplayer.js"></script>
|
||||
<script src="connect.js"></script>
|
||||
<script src="updates.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -969,3 +969,11 @@ body.mini-mode > *:not(#mini):not(.toasts):not(.modal-wrap):not(script) { displa
|
||||
.api-scope.dim { opacity: 0.55; }
|
||||
#apiDocs { color: var(--accent); font: inherit; padding: 0; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
|
||||
#apiDocs:hover { text-decoration-color: currentColor; }
|
||||
|
||||
/* updates */
|
||||
.update-chip { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 10px; margin-bottom: 6px; border-radius: var(--r-ctl); background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); font-weight: 600; font-size: 12.5px; text-align: left; transition: background-color 120ms var(--ease); }
|
||||
.update-chip:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
|
||||
.update-chip .i svg { width: 16px; height: 16px; }
|
||||
.update-notes { max-height: 220px; overflow: auto; white-space: pre-wrap; font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 10px; background: var(--surface-2, var(--surface)); border: 1px solid var(--hairline); color: var(--text-2); }
|
||||
.update-bar { height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; margin: var(--s3) 0 var(--s2); }
|
||||
.update-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 160ms linear; }
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
// atmosphere · updates.js · Update chip, what's-new dialog and install progress for signed GitHub releases
|
||||
const Upd = { info: null, app: null, busy: false };
|
||||
|
||||
async function checkUpdates(manual = false) {
|
||||
const btn = $("#updateBtn");
|
||||
if (manual && btn) {
|
||||
btn.classList.add("loading");
|
||||
btn.disabled = true;
|
||||
}
|
||||
try {
|
||||
Upd.info = await invoke("update_check");
|
||||
renderUpdate();
|
||||
if (manual) {
|
||||
if (Upd.info) openUpdate();
|
||||
else toast("You're on the latest version.", "ok");
|
||||
}
|
||||
} catch (e) {
|
||||
if (manual) toast(errText(e), "err");
|
||||
} finally {
|
||||
if (manual && btn) {
|
||||
btn.disabled = false;
|
||||
btn.classList.remove("loading");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function renderUpdate() {
|
||||
const chip = $("#updateChip");
|
||||
const info = $("#updateInfo");
|
||||
if (chip) {
|
||||
chip.hidden = !Upd.info;
|
||||
if (Upd.info) chip.replaceChildren(icon("sparkles"), h("span", {}, `Update to ${Upd.info.version}`));
|
||||
}
|
||||
if (info && Upd.app) {
|
||||
info.textContent = Upd.info
|
||||
? `Atmosphere ${Upd.app.version}. Version ${Upd.info.version} is available.`
|
||||
: `Atmosphere ${Upd.app.version}${Upd.app.canSelfUpdate ? "" : ". This copy updates by downloading the new version."}`;
|
||||
}
|
||||
}
|
||||
|
||||
async function openUpdate() {
|
||||
const u = Upd.info;
|
||||
if (!u || Upd.busy) return;
|
||||
const notes = (u.notes || "").trim();
|
||||
const body = h("div", { class: "stack" },
|
||||
h("p", { class: "muted" }, `You have ${u.current}.${u.date ? ` Released ${new Intl.DateTimeFormat(undefined, { dateStyle: "long" }).format(new Date(u.date.replace(" ", "T").replace(/ .*$/, "")))}.` : ""}`),
|
||||
notes ? h("div", { class: "update-notes" }, notes) : null,
|
||||
u.canInstall ? h("p", { class: "muted small" }, "Atmosphere restarts to finish. Downloads in progress stop, and your library, settings and stats stay as they are.") : h("p", { class: "muted small" }, "This copy can't replace itself, so the new version opens on GitHub for you to download."));
|
||||
const go = await modal(`Atmosphere ${u.version} is here`, body, [{ label: "Later", value: false }, { label: u.canInstall ? "Update and restart" : "Download", value: true, primary: true }]);
|
||||
if (!go) return;
|
||||
if (!u.canInstall) return invoke("open_link", { url: u.page }).catch((e) => toast(errText(e), "err"));
|
||||
installUpdate();
|
||||
}
|
||||
|
||||
async function installUpdate() {
|
||||
Upd.busy = true;
|
||||
Player.flushListen?.();
|
||||
const bar = h("div", { class: "update-bar" }, h("span", { class: "update-fill" }));
|
||||
const label = h("p", { class: "muted small" }, "Downloading…");
|
||||
const wrap = h("div", { class: "modal-wrap" }, h("div", { class: "modal", role: "dialog", "aria-modal": "true", "aria-label": "Updating Atmosphere" }, h("h2", {}, `Updating to ${Upd.info.version}`), bar, label));
|
||||
document.body.append(wrap);
|
||||
const off = await listen("atmosphere://update", (e) => {
|
||||
const { received, total } = e.payload || {};
|
||||
if (total) {
|
||||
bar.firstChild.style.width = `${Math.min(100, (received / total) * 100).toFixed(1)}%`;
|
||||
label.textContent = `${(received / 1048576).toFixed(1)} of ${(total / 1048576).toFixed(1)} MB`;
|
||||
if (received >= total) label.textContent = "Installing… Atmosphere will restart.";
|
||||
} else label.textContent = `${(received / 1048576).toFixed(1)} MB`;
|
||||
});
|
||||
try {
|
||||
await invoke("update_install");
|
||||
} catch (e) {
|
||||
off();
|
||||
wrap.remove();
|
||||
Upd.busy = false;
|
||||
toast(errText(e), "err");
|
||||
}
|
||||
}
|
||||
|
||||
async function bindUpdates() {
|
||||
Upd.app = await invoke("app_version").catch(() => null);
|
||||
renderUpdate();
|
||||
$("#updateBtn")?.addEventListener("click", () => (Upd.info ? openUpdate() : checkUpdates(true)));
|
||||
$("#updateChip")?.addEventListener("click", openUpdate);
|
||||
if (state.settings?.checkUpdates !== false) setTimeout(() => checkUpdates(false), 5000);
|
||||
}
|
||||
Reference in New Issue
Block a user