参照相关文档,在package.json中配置electron-builder的基础打包设置:

  "build": {
    "productName": "Fishing Funds",
    "appId": "com.electron.1zilc.fishing-funds",
    "copyright": "Copyright © 2021 1zilc",
    "files": [
      "dist/",
      "node_modules/",
      "index.html",
      "main.prod.js",
      "main.prod.js.map",
      "package.json"
    ],
    "afterSign": ".erb/scripts/Notarize.js",
    "mac": {
      "target": [
        "dmg"
      ],
      "type": "distribution",
      "hardenedRuntime": true,
      "entitlements": "assets/entitlements.mac.plist",
      "entitlementsInherit": "assets/entitlements.mac.plist",
      "gatekeeperAssess": false
    },
    "dmg": {
      "contents": [
        {
          "x": 130,
          "y": 220
        },
        {
          "x": 410,
          "y": 220,
          "type": "link",
          "path": "/Applications"
        }
      ]
    },
    "win": {
      "target": [
        "nsis"
      ]
    },
    "linux": {
      "target": [
        "AppImage"
      ],
      "category": "Development"
    },
    "directories": {
      "app": "src",
      "buildResources": "assets",
      "output": "release"
    },
    "extraResources": [
      "./assets/**"
    ]
  },

在该配置的基础上添加 publish key,如下:

   "publish": {
      "provider": "github",
      "owner": "1zilc",
      "repo": "fishing-funds"
    }

以我自己的 Fishing Funds 为例

添加github token,网址如下: https://github.com/settings/tokens/new

勾选repo仓库相关权限

生成token后,临时添加环境变量中

export GH_TOKEN="<YOUR_TOKEN_HERE>"

在package.json中编写scripts,根据实际情况做调整

 "scripts": {
    "build": "concurrently \"yarn build:main\" \"yarn build:renderer\"",
    "build:main": "cross-env NODE_ENV=production webpack --config ./.erb/configs/webpack.config.main.prod.babel.js",
    "build:renderer": "cross-env NODE_ENV=production webpack --config ./.erb/configs/webpack.config.renderer.prod.babel.js",
    "package": "rm -rf src/dist && yarn build && electron-builder build --publish never",
    "package-mac": "rm -rf src/dist && yarn build && electron-builder build --mac -p always",
    "package-linux": "rm -rf src/dist && yarn build && electron-builder build --linux",
    "package-win": "rm -rf src/dist && yarn build && electron-builder build --win --x64",
    "package-all": "rm -rf src/dist && yarn build && electron-builder build -mwl",
    "release-all": "rm -rf src/dist && yarn build && electron-builder build -mwl --publish always"
  },
# 添加发布参数即release-all中所写
electron-builder build --publish always

执行

yarn release-all

构建完成后会自动通过刚才设置的token去调github的发布接口,此时仓库中会自动生成一个草稿状态的release,在填写相关日志后即可进行版本发布

electron-builder 自动发布 github release 到此完成! 🙂

发布结果:https://github.com/1zilc/fishing-funds

761 个评论

  1. After looking at a number of the articles on your website, I seriously
    like your way of writing a blog. I saved as a favorite it to my bookmark webpage list and will be checking back soon. Please check
    out my website as well and let me know how you feel.

  2. My partner and I absolutely love your blog and find most of your post’s to
    be exactly I’m looking for. Do you offer guest writers to write content available for you?
    I wouldn’t mind producing a post or elaborating on a few
    of the subjects you write about here. Again, awesome web site!

  3. What i do not understood is in truth how you’re not really a
    lot more well-favored than you might be right now.

    You’re very intelligent. You understand therefore considerably on the subject of this topic, made
    me for my part imagine it from so many various angles.
    Its like women and men aren’t involved except it is something to
    accomplish with Woman gaga! Your personal stuffs nice.

    All the time take care of it up!

  4. Howdy! I understand this is sort of off-topic but I
    needed to ask. Does running a well-established website such as yours take a large amount
    of work? I’m completely new to writing a blog but I do write in my journal every day.
    I’d like to start a blog so I will be able to share my experience and feelings online.
    Please let me know if you have any kind of recommendations or
    tips for brand new aspiring blog owners.
    Thankyou!

  5. What i do not realize is actually how you are now not really a
    lot more smartly-favored than you might be right now.

    You are very intelligent. You already know thus significantly on the subject of this
    subject, made me individually believe it from numerous various angles.

    Its like men and women are not involved except it is something to do with Woman gaga!
    Your personal stuffs outstanding. At all times handle it up!

  6. I do not know whether it’s just me or if everybody else experiencing
    issues with your site. It seems like some of the written text in your posts are running off the screen.
    Can somebody else please comment and let me know if this is happening to them too?
    This might be a problem with my web browser because I’ve had
    this happen before. Many thanks

  7. I love your blog.. very nice colors & theme. Did
    you design this website yourself or did you hire someone to do it
    for you? Plz answer back as I’m looking to create my own blog and would like to find out
    where u got this from. thanks

  8. Thanks for ones marvelous posting! I actually enjoyed reading it, you can be a great author.I will remember to bookmark your blog
    and will eventually come back at some point.
    I want to encourage you to ultimately continue
    your great job, have a nice day!

  9. I’m impressed, I have to admit. Seldom do I encounter a blog that’s both
    equally educative and interesting, and let me tell you,
    you have hit the nail on the head. The problem is something that not enough folks are speaking
    intelligently about. Now i’m very happy I came across this in my
    hunt for something concerning this.

回复 Halina 取消回复

您的邮箱地址不会被公开。 必填项已用 * 标注