Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fair-gifts-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"electron-updater": patch
---

fix(electron-updater): fix backward compatibility for GitHub provider without channels
56 changes: 31 additions & 25 deletions packages/electron-updater/src/providers/GitHubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,38 @@ export class GitHubProvider extends BaseGitHubProvider<GithubUpdateInfo> {
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 {
Expand Down