我想使用电子生成器的autoUpdater来更新我的应用程序。我没有使用Github Releases,因为我有一个私有的repo,出于安全目的,我不想包含GH_TOKEN。相反,我希望将二进制文件和latest.yml/latest-mac.yml文件放入Google Storage Bucket中。
我知道可以使用通用提供程序来检查更新。但目前,我甚至不能让电子生成器读取latest.yml。我已经在文档和其他github/堆栈溢出问题上倾注了几个小时,但没有找到任何解决这个问题的方法。
下面是我的电子/自动更新器main.js
中的代码,用于设置一个新的提要URL -
const data = {
provider: 'generic',
url: 'https://storage.cloud.google.com/my-project', //'my-project' is the name of the bucket
channel: 'latest',
};
autoUpdater.setFeedURL(data);
autoUpdater.autoDownload = false;
autoUpdater.checkForUpdates();
构建的应用程序和yml文件都在该存储桶中。当我尝试运行我的应用程序时,我得到一个巨大的错误,基本上只是复制Google Cloud Storage HTML/CSS,而不是读取和处理latest.yml文件……
Error: Error: Cannot parse update info from latest-mac.yml in the latest release artifacts (https://storage.cloud.google.com/my-project/latest-mac.yml?noCache=1dh4pdr5e): YAMLException: end of the stream or a document separator is expected at line 11, column 14:
font-family: 'Open Sans';
^
at generateError (/Users/somelocation/documents/some-project/node_modules/js-yaml/lib/js-yaml/loader.js:167:10)
at throwError (/Users/somelocation/documents/some-project/node_modules/js-yaml/lib/js-yaml/loader.js:173:9)
at readDocument (/Users/somelocation/documents/some-project/node_modules/js-yaml/lib/js-yaml/loader.js:1539:5)
at loadDocuments (/Users/somelocation/documents/some-project/node_modules/js-yaml/lib/js-yaml/loader.js:1575:5)
at load (/Users/somelocation/documents/some-project/node_modules/js-yaml/lib/js-yaml/loader.js:1596:19)
at safeLoad (/Users/somelocation/documents/some-project/node_modules/js-yaml/lib/js-yaml/loader.js:1618:10)
at parseUpdateInfo (/Users/somelocation/documents/some-project/node_modules/electron-updater/out/providers/Provider.js:131:37)
at GenericProvider.getLatestVersion (/Users/somelocation/documents/some-project/node_modules/electron-updater/out/providers/GenericProvider.js:57:48)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
at async MacUpdater.getUpdateInfoAndProvider (/Users/somelocation/documents/some-project/node_modules/electron-updater/out/AppUpdater.js:488:13), rawData:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=300, initial-scale=1" name="viewport">
<meta name="google-site-verification" content="LrdTUW9psUAMbh4Ia074-BPEVmcpBxF6Gwf0MSgQXZs">
<title>Sign in - Google Accounts</title>
有没有可能从Google Cloud Storage存储桶中读取文件,而不是从S3或Github?另外,我已经尝试从yml文件中删除多余的行或制表符。
发布于 2020-06-22 20:45:59
您应该使用GCP API,而不是浏览器URL。
这段代码对我来说很有效:
"publish": {
"provider": "generic",
"url": "https://storage.googleapis.com/YOUR_BUCKET/"
}
也可以使用https://cloud.google.com/storage/docs/json_api/v1,但它需要OAuth
发布于 2019-10-08 10:51:12
尝试在app 'ready‘事件之后执行此代码。
app.on('ready', () => {
const feedURL = 'https://storage.cloud.google.com/my-project';
autoUpdater.setFeedURL(feedURL);
autoUpdater.checkForUpdates();
});
https://stackoverflow.com/questions/57299490
复制相似问题