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

时间:2019-04-10 17:50:24

标签: electron electron-builder

  • 电子生成器版本:20.38.5
  • 目标:Windows ia32和x64

我正在尝试将项目推送到私有存储库中的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

我尝试将选项始终更改为onTag或onTagOrDraft,并将releaseType更改为release。

我尝试先在GitHub上手动创建草稿,但不起作用。

我试图将存储库公开以进行测试,但也无法正常工作。

我尝试两次重新生成令牌,并在envs,console和package.json上对其进行了更新,

我错过了一些配置吗?将电子发布到GitHub我需要做什么?

出现错误时,它说找不到https://github.com/repos/AndreD23/electron-todo-tasks/releases。在网络浏览器上打开它,返回404。我发现链接很奇怪,因为它在github.com之后添加了“ repos”一词,并在浏览器中将其删除就可以了。这个词是自动设置的吗?

2 个答案:

答案 0 :(得分:0)

感谢@edelCustodio https://github.com/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,这就是我的发布在package.json上的方式。“ publish”:“ build --win -p always”不要忘记关闭并打开一个新的PowerShell终端

答案 1 :(得分:0)

  1. 从管理员运行 Windows PowerShell
  2. 执行 [Environment]::SetEnvironmentVariable("GH_TOKEN","","User")
  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"
  }
}