diff --git a/packages/electron-builder/src/publish/PublishManager.ts b/packages/electron-builder/src/publish/PublishManager.ts index d0fe70a4aad..22860563790 100644 --- a/packages/electron-builder/src/publish/PublishManager.ts +++ b/packages/electron-builder/src/publish/PublishManager.ts @@ -341,7 +341,7 @@ export function computeDownloadUrl(publishConfig: PublishConfiguration, fileName } else { const gh = publishConfig - baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/v${packager.appInfo.version}` + baseUrl = `${githubUrl(gh)}/${gh.owner}/${gh.repo}/releases/download/${gh.vPrefixedTagName === false ? "" : "v"}${packager.appInfo.version}` } if (fileName == null) { diff --git a/packages/electron-updater/src/GitHubProvider.ts b/packages/electron-updater/src/GitHubProvider.ts index 113a94a0d17..df48cb0217a 100644 --- a/packages/electron-updater/src/GitHubProvider.ts +++ b/packages/electron-updater/src/GitHubProvider.ts @@ -34,7 +34,7 @@ export class GitHubProvider extends BaseGitHubProvider { const version = await this.getLatestVersionString(basePath, cancellationToken) let result: any const channelFile = getChannelFilename(getDefaultChannelName()) - const requestOptions = Object.assign({path: `${basePath}/download/v${version}/${channelFile}`, headers: this.requestHeaders || undefined}, this.baseUrl) + const requestOptions = Object.assign({path: this.getBaseDownloadPath(version, channelFile), headers: this.requestHeaders || undefined}, this.baseUrl) try { result = await request(requestOptions, cancellationToken) } @@ -67,7 +67,7 @@ export class GitHubProvider extends BaseGitHubProvider { } } - protected get basePath() { + private get basePath() { return `/${this.options.owner}/${this.options.repo}/releases` } @@ -80,10 +80,14 @@ export class GitHubProvider extends BaseGitHubProvider { const name = versionInfo.githubArtifactName || path.posix.basename(versionInfo.path).replace(/ /g, "-") return { name: name, - url: formatUrl(Object.assign({path: `${this.basePath}/download/v${versionInfo.version}/${name}`}, this.baseUrl)), + url: formatUrl(Object.assign({path: this.getBaseDownloadPath(versionInfo.version, name)}, this.baseUrl)), sha2: versionInfo.sha2, } } + + private getBaseDownloadPath(version: string, fileName: string) { + return `${this.basePath}/download/${this.options.vPrefixedTagName === false ? "" : "v"}${version}/${fileName}` + } } interface GithubReleaseInfo {