参照相关文档,在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. Hi there! I understand this is sort of off-topic but I had
    to ask. Does managing a well-established website such as yours
    require a massive amount work? I’m completely new to running
    a blog but I do write in my diary daily. I’d like to start a blog so I can easily share my experience and thoughts online.
    Please let me know if you have any ideas or tips for new aspiring bloggers.
    Appreciate it!

  2. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a
    comment is added I get several e-mails with the same comment.
    Is there any way you can remove people from that service?
    Thank you!

  3. Hiya! Quick question that’s totally off topic. Do you know
    how to make your site mobile friendly? My web site looks weird when browsing from my iphone4.
    I’m trying to find a theme or plugin that might be able to resolve this issue.
    If you have any recommendations, please share. Thanks!

  4. It’s appropriate time to make a few plans for the long run and it is time to be happy.
    I’ve learn this submit and if I may I wish to suggest you some interesting things or suggestions.
    Perhaps you can write next articles referring
    to this article. I want to learn more issues about it!

  5. It’s the best time to make some plans for the future and it’s time
    to be happy. I’ve read this post and if I could I wish to suggest you some interesting things
    or advice. Maybe you can write next articles referring to this article.
    I desire to read even more things about it!

  6. Thanks alot : ) for your post. I’d really like to write my opinion that the price of car insurance will vary from one scheme to another, given that there are so many different facets which give rise to the overall cost. One example is, the make and model of the automobile will have a tremendous bearing on the charge. A reliable older family vehicle will have a more economical premium than just a flashy fancy car.

  7. Please let me know if you’re looking for a writer for your blog.

    You have some really good posts and I feel I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some material for your blog in exchange for a link back to mine.
    Please shoot me an email if interested. Cheers!

  8. You are so interesting! I don’t think I’ve truly read anything like this before.
    So wonderful to discover another person with original thoughts on this
    subject matter. Seriously.. many thanks for starting this up.
    This website is one thing that is required on the web, someone with a little originality!

  9. First of all I would like to say superb blog! I had a quick question that I’d like to ask if you don’t mind.
    I was curious to know how you center yourself and clear your mind
    before writing. I have had difficulty clearing my thoughts in getting my thoughts out.
    I do take pleasure in writing however it just seems like the first 10 to 15
    minutes are lost simply just trying to figure out how to begin. Any suggestions or tips?
    Thank you!

  10. Greetings I am so happy I found your blog page, I really found
    you by accident, while I was searching on Bing for something else,
    Anyhow I am here now and would just like to say many thanks for a tremendous post
    and a all round thrilling blog (I also love the theme/design), I don’t have
    time to browse it all at the minute but I have book-marked it and also added in your
    RSS feeds, so when I have time I will be back to
    read much more, Please do keep up the excellent work.

  11. Great goods from you, man. I’ve understand your stuff previous to and you’re just too
    magnificent. I actually like what you have acquired
    here, certainly like what you’re stating and the way in which you say it.
    You make it entertaining and you still take care of to keep it smart.
    I can’t wait to read far more from you. This is actually a great web site.

回复 Takipci Satin AL 取消回复

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