From 15740722bda332e7b73052b6496304d9e4b7bcb2 Mon Sep 17 00:00:00 2001 From: Matej Kriz Date: Tue, 12 Jul 2022 16:38:47 +0200 Subject: [PATCH 1/2] fix(electron-updater): fix backward compatibility for GitHub provider without channels Adding support for channels on GitHub was breaking change for those using only pre-release status without channel tags. --- .../src/providers/GitHubProvider.ts | 56 ++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/packages/electron-updater/src/providers/GitHubProvider.ts b/packages/electron-updater/src/providers/GitHubProvider.ts index c50427317d..120e5a0a49 100644 --- a/packages/electron-updater/src/providers/GitHubProvider.ts +++ b/packages/electron-updater/src/providers/GitHubProvider.ts @@ -58,32 +58,38 @@ export class GitHubProvider extends BaseGitHubProvider { try { if (this.updater.allowPrerelease) { const currentChannel = this.updater?.channel || (semver.prerelease(this.updater.currentVersion)?.[0] as string) || null - for (const element of feed.getElements("entry")) { + + if (currentChannel === null) { // noinspection TypeScriptValidateJSTypes - const hrefElement = hrefRegExp.exec(element.element("link").attribute("href"))! - - // If this is null then something is wrong and skip this release - if (hrefElement === null) continue - - // This Release's Tag - const hrefTag = hrefElement[1] - //Get Channel from this release's tag - const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || null - - const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel) - const isCustomChannel = !["alpha", "beta"].includes(String(hrefChannel)) - // Allow moving from alpha to beta but not down - const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha" - - if (shouldFetchVersion && !isCustomChannel && !channelMismatch) { - tag = hrefTag - break - } - - const isNextPreRelease = hrefChannel && hrefChannel === currentChannel - if (isNextPreRelease) { - tag = hrefTag - break + tag = hrefRegExp.exec(latestRelease.element("link").attribute("href"))![1] + } else { + for (const element of feed.getElements("entry")) { + // noinspection TypeScriptValidateJSTypes + const hrefElement = hrefRegExp.exec(element.element("link").attribute("href"))! + + // If this is null then something is wrong and skip this release + if (hrefElement === null) continue + + // This Release's Tag + const hrefTag = hrefElement[1] + //Get Channel from this release's tag + const hrefChannel = (semver.prerelease(hrefTag)?.[0] as string) || null + + const shouldFetchVersion = !currentChannel || ["alpha", "beta"].includes(currentChannel) + const isCustomChannel = !["alpha", "beta"].includes(String(hrefChannel)) + // Allow moving from alpha to beta but not down + const channelMismatch = currentChannel === "beta" && hrefChannel === "alpha" + + if (shouldFetchVersion && !isCustomChannel && !channelMismatch) { + tag = hrefTag + break + } + + const isNextPreRelease = hrefChannel && hrefChannel === currentChannel + if (isNextPreRelease) { + tag = hrefTag + break + } } } } else { From 2666c98295733d729341b039c7f3427309d8f0b9 Mon Sep 17 00:00:00 2001 From: Mike Maietta Date: Tue, 12 Jul 2022 08:05:54 -0700 Subject: [PATCH 2/2] Create fair-gifts-explain.md --- .changeset/fair-gifts-explain.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fair-gifts-explain.md diff --git a/.changeset/fair-gifts-explain.md b/.changeset/fair-gifts-explain.md new file mode 100644 index 0000000000..840271b41b --- /dev/null +++ b/.changeset/fair-gifts-explain.md @@ -0,0 +1,5 @@ +--- +"electron-updater": patch +--- + +fix(electron-updater): fix backward compatibility for GitHub provider without channels