具有私有 GitHub 存储库的 Electron Autoupdater?

Electron Autoupdater with Private GitHub Repository?

我已经使用 PRIVATE GitHub 存储库实现了 Electron AutoUpdater 作为发布电子应用程序的提供者。现在,我可以使用 GitHub 存储库发布它,但是每当 AutoUpdater 尝试从 GitHub 存储库下载更新时,每次它都会提示响应代码 404 Not found..我已经尝试在 setFeedURL 方法中传递令牌,并且将其设置为 GH_TOKEN 但似乎也不起作用。

autoUpdater.setFeedURL({ provider: 'github'
, owner: 'owner'
, repo: 'repo-name'
, token: 'token'
, private: true });

那么,有没有办法让它与 PRIVATE GitHub 存储库一起工作?

你在用electron吗auto-updater module? from the API documentation,我看他们不支持

另一方面,如果您使用 electron-updater module, make sure that you are following the recommended release workflow, and you should not use setFeedURL check the note here

更新:

如果您正在使用 electron-updater 并且要发布到私有存储库,则需要确保您的令牌在 app-update.yml 文件中可用,这就是为什么很多人说它不是建议,如果您的 app-update.yml 文件中未设置令牌,您将收到 404.

为了 electron-updater 自动将您的令牌添加到 app-update.yml 文件,应该在发布部分中设置令牌,如下所示:

  "publish": [
    {
      "provider": "github",
      "private": true,
      "owner": "<github_owner>",
      "repo": "<repo_name>",
      "token": "<your github token>"
    }
  ],

这将生成如下所示的 app-update.yml 文件:

owner: <github_owner>
repo: <repo_name>
provider: github
private: true
token: <your github token>
updaterCacheDirName: electron-updater-private-updater

检查这个 small video

这是我的代码 https://github.com/linuxjuggler/electron-auto-update-example 检查 electron-builder.json 文件。

更新 2

根据 Quick Setup Guide 部分中提到的注意事项,您永远不应调用 setFeedURL.

Auto-Update - 你可以看到私有 github 存储库只适用于非常特殊的情况,他们建议有一个单独的 release-only 存储库来分发版本,因此源被锁定下来,你可以分发到受控机器。这是一个有用的功能,因为不需要服务器,但有特殊用例。此外,您可以使用 s3 存储桶或其他一些升级服务器使其工作。

我发现这个 AutoUpdater Git Repo 非常有用,我的代码现在可以正常工作了。我需要做的唯一改变是在 github yml 设置中,从 github.

添加一个 token=<PersonalAccessToken>

您可以从Github > Settings > Developer Settings > Personal access tokens > Generate New Token

获得Github个人令牌

如果有人仍然遇到这个问题(我被困了几个星期),我创建了一个包来帮助解决这个问题。 electron-github-autoupdater

它几乎是 Electron autoUpdate API 的精确克隆,它接受 private/enterprise github 存储库配置和访问令牌的配置对象。它应该正常工作