参照相关文档,在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. Oh my goodness! Awesome article dude! Thanks, However I am experiencing problems with your RSS.
    I don’t know the reason why I can’t join it.
    Is there anyone else having identical RSS issues?

    Anyone who knows the solution can you kindly respond?

    Thanx!!

  2. I loved as much as you will receive carried out right here.
    The sketch is tasteful, your authored subject matter stylish.
    nonetheless, you command get bought an shakiness
    over that you wish be delivering the following. unwell unquestionably come more
    formerly again as exactly the same nearly a lot often inside case you shield this
    increase.

  3. Hello there, just became alert to your blog through Google, and found that it’s truly informative.

    I’m going to watch out for brussels. I’ll appreciate if you continue
    this in future. A lot of people will be benefited from your writing.
    Cheers!

  4. Hey! This is kind of off topic but I need some advice from an established blog.

    Is it difficult to set up your own blog? I’m not very techincal but I can figure things out pretty quick.
    I’m thinking about making my own but I’m not sure where to
    start. Do you have any tips or suggestions? Appreciate it

  5. Hello there I am so grateful I found your site, I really found you by accident,
    while I was looking on Askjeeve for something else, Anyways
    I am here now and would just like to say thanks a lot for a fantastic post and a all
    round interesting blog (I also love the theme/design),
    I don’t have time to browse it all at the minute but I have saved
    it and also added your RSS feeds, so when I have time I will be
    back to read much more, Please do keep up the superb work.

  6. I absolutely love your website.. Great colors & theme.
    Did you create this site yourself? Please reply back as I’m attempting
    to create my own personal blog and would like to know where you got
    this from or just what the theme is named.
    Kudos!

  7. I’m really inspired along with your writing talents and also with the structure
    in your blog. Is that this a paid topic or did you
    modify it your self? Either way keep up the excellent quality writing, it
    is uncommon to see a nice blog like this one today..

  8. Hello, I do think your site could be having browser compatibility issues.
    When I take a look at your blog in Safari, it looks fine however when opening in Internet Explorer, it’s got some overlapping issues.
    I simply wanted to give you a quick heads up!
    Other than that, fantastic blog!

  9. You really make it appear so easy together with your presentation however I find this topic to be really one thing that I feel I would by no
    means understand. It kind of feels too complicated and extremely
    large for me. I’m looking ahead in your subsequent post, I’ll attempt to get the
    dangle of it!

  10. I loved as much as you will receive carried out right
    here. The sketch is attractive, your authored subject matter stylish.

    nonetheless, you command get bought an nervousness over that
    you wish be delivering the following. unwell unquestionably come more formerly
    again since exactly the same nearly very often inside case
    you shield this increase.

  11. I have been exploring for a little for any high-quality articles or weblog posts on this kind
    of area . Exploring in Yahoo I ultimately stumbled upon this website.
    Reading this info So i am satisfied to show that
    I’ve a very good uncanny feeling I found out exactly what I needed.

    I so much surely will make sure to do not disregard this site and provides
    it a glance regularly.

  12. Hello there, I found your website by the use
    of Google whilst looking for a related matter, your website got here up, it seems good.
    I have bookmarked it in my google bookmarks.
    Hi there, simply turned into aware of your blog through Google, and located that it is really informative.
    I am going to be careful for brussels. I’ll appreciate if you proceed this
    in future. Lots of other people will be benefited out of your writing.
    Cheers!

  13. Hello! I know this is kinda off topic but I’d figured I’d ask.
    Would you be interested in trading links or maybe guest writing a blog article
    or vice-versa? My blog goes over a lot of the same subjects as yours and I think we could greatly benefit from each other.
    If you are interested feel free to shoot me an e-mail.
    I look forward to hearing from you! Fantastic blog by the way!

  14. Hey I know this is off topic but I was wondering if you knew of any widgets I could add to
    my blog that automatically tweet my newest twitter updates.
    I’ve been looking for a plug-in like this for quite some
    time and was hoping maybe you would have some experience with something like this.
    Please let me know if you run into anything. I truly enjoy reading your blog and I look forward to your new updates.

回复 bitcoin adaption 取消回复

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