如何使用 Electron-builder NSIS 和 AppImage 发布到私人 GitHub?

How to Publish to a Private GitHub with Electron-builder NSIS and AppImage?

我正在尝试将项目推送到私有存储库中的 GitHub 版本。 主要目标是 Win ia32 和 x64。

我通过以下方式在控制台中设置令牌:

set GH_TOKEN=<blabla>

并且在 package.json 文件中:

"publish": {
      "provider": "github",
      "repo": "electron-todo-tasks",
      "owner": "AndreD23",
      "host": "github.com",
      "protocol": "https",
      "releaseType": "draft",
      "token": "<blablabla>",
      "private": true
    }

我是唯一有权访问该项目的人,因此更新文件中的令牌显然不是问题。

但是,当我 运行:

electron-builder --x64 --ia32 --publish always

它告诉我错误:

Error: Cannot cleanup:

Error #1 --------------------------------------------------------------------------------
HttpError: 404 Not Found
"method: undefined url: https://github.com/repos/AndreD23/electron-todo-tasks/releases\n\nPlease double check that your authentication token is correct. Due to security reasons actual status maybe not reported, but 404.\n"

我会附上整个错误。

2019-03-22T13_04_27_992Z-debug.log

electron publish error.txt

我尝试将选项始终更改为 onTagonTagOrDraft,并将 releaseType 更改为 release

我先尝试在 GitHub 上手动创建草稿,但没有用。

我试图创建存储库 public 用于测试,但没有用。

我尝试重新生成令牌两次并更新了环境、控制台和 package.json,但没有用。

有没有我遗漏的配置?我需要做什么才能让 Electron 发布到 GitHub?

报错时说找不到https://github.com/repos/AndreD23/electron-todo-tasks/releases。在网络浏览器上打开它,它 returns 404。我发现 link 有点奇怪,因为它在 github.com 之后添加了单词 repos,并在浏览器中将其删除它加载正常。这个词是自动设置的吗?

谢谢@edelCustodio

参考:https://github.com/electron-userland/electron-builder/issues/3776#issuecomment-486888574

这对我有用,在 PowerShell 上输入这个

[Environment]::SetEnvironmentVariable("GH_TOKEN","my-personal-token","User") 

并确保您 package.json 会像这样:

"build": {
    "appId": "com.friasoftit.electron-auto-update",
    "productName": "Electron Auto Update",
    "publish": [
      {
        "provider": "github",
        "owner": "edelCustodio",
        "repo": "electron-auto-update"
      }
    ],
    "win": {
      "publish": [
        "github"
      ],
      "target": [
        {
          "target": "nsis",
          "arch": [
            "x64",
            "ia32"
          ]
        }
      ]
    }
  },

然后我 运行 这个命令 yarn run publish 这就是我的 publish 在我的 package.json

上的样子
"publish": "build --win -p always" 

不要忘记关闭并打开一个新的 PowerShell 终端。

  1. 运行 windows 来自管理员的 powerShell
  2. 执行[环境]::SetEnvironmentVariable("GH_TOKEN","","用户")
  3. 启动或完全重启您的 IDE
  4. 运行 bozon 包 windows --publish

配置:

{
  "name": "",
  "version": "",
  "description": "",
  "author": "",
  "repository": "<repo_url>",
  "dependencies": {
    "cross-fetch": "^3.0.6",
    "electron-builder": "^22.10.5",
    "file-loader": "^6.2.0",
    "luxon": "^1.26.0",
    "node-fetch": "^2.6.1"
  },
  "license": "ISC",
  "devDependencies": {
    "bozon": "1.1.3",
    "eslint-config-airbnb-base": "^14.2.1",
    "eslint-plugin-import": "^2.22.1",
    "jest": "26.6.3",
    "spectron": "13.0.0"
  },
  "build": {
    "appId": "",
    "publish": [
      {
        "provider": "github"
      }
    ],
    "win": {}
  },
  "main": ".eslintrc.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  }
}