参照相关文档,在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. The next time I read a blog, I hope that it does not disappoint
    me as much as this particular one. I mean, Yes, it was my choice to read through, nonetheless I
    genuinely believed you would have something useful to
    say. All I hear is a bunch of moaning about something that you can fix
    if you weren’t too busy looking for attention.

  2. It’s the best time to make some plans for the future and it’s time to be happy.
    I have read this post and if I could I want to suggest you few interesting
    things or suggestions. Perhaps you can write next articles referring to this article.
    I want to read even more things about it!

  3. Hi there would you mind letting me know which web host you’re
    utilizing? I’ve loaded your blog in 3 different web browsers and I must say this blog loads a lot quicker then most.
    Can you suggest a good internet hosting provider at a honest price?
    Thanks a lot, I appreciate it!

  4. I truly love your site.. Very nice colors & theme. Did you build this web site yourself?
    Please reply back as I’m looking to create my own personal website and would
    love to find out where you got this from or exactly
    what the theme is named. Thank you!

  5. This is the perfect site for anybody who would like to understand this topic.
    You understand a whole lot its almost tough to argue
    with you (not that I really will need to…HaHa).

    You definitely put a new spin on a topic that has been discussed for decades.
    Great stuff, just great!

  6. Whats up this is kind of of off topic but I was wanting to know
    if blogs use WYSIWYG editors or if you have to manually code with
    HTML. I’m starting a blog soon but have no coding know-how so I wanted to get advice from someone with experience.
    Any help would be enormously appreciated!

  7. hey there and thank you for your information – I’ve certainly picked up anything new from right
    here. I did however expertise some technical issues using this web
    site, as I experienced to reload the site many times previous
    to I could get it to load correctly. I had been wondering if your hosting is OK?
    Not that I am complaining, but slow loading instances times will
    often affect your placement in google and could damage your quality
    score if advertising and marketing with Adwords. Anyway I’m adding this RSS
    to my e-mail and could look out for a lot more of your respective fascinating content.
    Ensure that you update this again very soon.

  8. Wonderful beat ! I wish to apprentice while you amend your site, how could i subscribe
    for a blog web site? The account aided me a acceptable deal.
    I had been tiny bit acquainted of this your broadcast
    offered bright clear idea

  9. Unquestionably believe that that you said. Your favorite justification appeared
    to be at the web the simplest thing to take into accout of.
    I say to you, I certainly get annoyed while folks think about worries that they just don’t recognize
    about. You managed to hit the nail upon the top as neatly as outlined
    out the whole thing with no need side effect , other folks can take a signal.

    Will likely be back to get more. Thanks

  10. It’s perfect 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 desire to suggest you some interesting
    things or advice. Maybe you can write next articles referring to this
    article. I want to read more things about it!

  11. It is appropriate time to make some plans for the future and it is time to be happy.
    I have read this post and if I could I want to suggest you few interesting things or suggestions.

    Perhaps you could write next articles referring to this article.
    I want to read even more things about it!

  12. Thanks for the useful information on credit repair on this site. Things i would offer as advice to people is always to give up a mentality that they’ll buy now and shell out later. Like a society we all tend to try this for many issues. This includes holidays, furniture, plus items we wish. However, you have to separate a person’s wants from the needs. When you’re working to fix your credit score actually you need some trade-offs. For example you possibly can shop online to economize or you can click on second hand shops instead of high priced department stores for clothing.

  13. I have been surfing online more than 3 hours today, yet I never found any
    interesting article like yours. It is pretty worth enough
    for me. Personally, if all site owners and bloggers made good content as you did, the internet will be
    a lot more useful than ever before.

  14. Hey would you mind sharing which blog platform you’re working with?
    I’m planning to start my own blog soon but I’m having a hard time choosing between BlogEngine/Wordpress/B2evolution and
    Drupal. The reason I ask is because your design seems different then most
    blogs and I’m looking for something unique. P.S
    Apologies for getting off-topic but I had to ask!

  15. It’s appropriate time to make a few plans for the long run and it
    is time to be happy. I’ve read this publish and if I may just I
    desire to counsel you few interesting things or advice.
    Perhaps you can write next articles relating to this article.
    I wish to learn even more issues approximately it!

发表回复

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