【问题标题】:How to Publish to a Private GitHub with Electron-builder NSIS and AppImage?如何使用 Electron-builder NSIS 和 AppImage 发布到私有 GitHub?
【发布时间】:2019-09-01 06:27:02
【问题描述】:
  • 电子制造商版本: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

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

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

我尝试将存储库公开以进行测试,但也没有用。

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

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

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

【问题讨论】:

    标签: electron electron-builder


    【解决方案1】:

    谢谢@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 终端。

    【讨论】:

      【解决方案2】:
      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"
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2020-05-28
        • 2019-12-14
        • 2018-03-16
        • 2019-07-26
        • 2021-09-23
        • 2021-12-18
        • 2018-12-06
        • 2019-02-25
        • 2020-05-26
        相关资源
        最近更新 更多