参照相关文档,在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. I’ve been surfing online more than 3 hours today, yet I never found any interesting article like yours.
    It’s pretty worth enough for me. In my view, if all website owners and bloggers made good content
    as you did, the net will be a lot more useful than ever before.

  2. I have been browsing online greater than three hours as of late, yet I
    never found any fascinating article like yours.
    It’s lovely price enough for me. In my opinion, if all
    webmasters and bloggers made excellent content material as you
    probably did, the internet might be much more useful than ever before.

  3. It is 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 tips. Maybe you could write next articles referring to this article.
    I desire to read more things about it!

  4. I have been browsing online more than three hours today,
    yet I never found any interesting article like yours. It’s pretty worth enough for me.
    In my view, if all webmasters and bloggers made good content as
    you did, the net will be a lot more useful than ever before.

  5. Woah! I’m really enjoying the template/theme
    of this blog. It’s simple, yet effective. A lot of times
    it’s very difficult to get that “perfect balance” between user friendliness and visual appearance.
    I must say that you’ve done a excellent job with this.
    Also, the blog loads extremely quick for me on Safari.
    Outstanding Blog!

  6. I have taken note that of all forms of insurance, medical health insurance is the most marked by controversy because of the conflict between the insurance policy company’s necessity to remain making money and the consumer’s need to have insurance cover. Insurance companies’ revenue on wellbeing plans are incredibly low, as a result some firms struggle to gain profits. Thanks for the thoughts you discuss through this site.

  7. It is 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 desire to suggest you some interesting things or advice.

    Maybe you can write next articles referring
    to this article. I desire to read more things about it!

  8. It’s appropriate time to make a few plans for the future and it’s
    time to be happy. I have read this post and if I may just I wish to counsel you few interesting issues or suggestions.

    Maybe you could write next articles regarding this article.
    I want to read more issues about it!

  9. Write more, thats all I have to say. Literally, it seems as though you relied on the video
    to make your point. You clearly know what youre talking about,
    why throw away your intelligence on just posting videos to your site when you could be giving us something enlightening to read?

  10. Takipçi satın almak sadece gelir elde etmek isteyen kişilerin değil
    hesaplarındaki takipçi sayısını
    yükselterek popüler bir profil oluşturmak isteyen kullanıcılarında tercih ettikleri bir yöntemdir
    . Instagram fenomeni olmak için İnstagram takipçi sayınızı megatakip adresi ile güvenilir sekilde takipci alabilirsiniz

  11. You really make it appear really easy with your presentation but I to find this topic to be really something that I feel I would by no means understand. It seems too complicated and very wide for me. I am having a look forward for your next submit, I will try to get the dangle of it! Clara Dew Rossuck

  12. Mahalo, Aleta! Your blog is truthful, accurate, well-delivered, and timly! It is with this type of honest communication, written following biblical principles, that we can move forward and repair our country. Thank you. I am looking forward to more of your writing. Willie Agosto Yalonda

  13. Definitely believe that which you said. Your favorite reason seemed to be on the web the simplest thing to
    be aware of. I say to you, I definitely get irked while
    people think about worries that they plainly don’t know about.
    You managed to hit the nail upon the top and also defined out the whole thing without having side effect , people
    can take a signal. Will likely be back to get more.
    Thanks

发表回复

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