参照相关文档,在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

756 个评论

  1. Excellent post. Keep posting such kind of info on your site.
    Im really impressed by your blog.
    Hello there, You’ve performed a fantastic job. I’ll definitely digg it and individually suggest to my friends.
    I am sure they will be benefited from this site.

  2. Please let me know if you’re looking for a article
    writer for your site. You have some really great articles
    and I think I would be a good asset. If you ever want to take some of the load off,
    I’d love to write some content for your blog in exchange for a link
    back to mine. Please shoot me an e-mail if interested.
    Regards!

  3. Hey there! I know this is kinda off topic nevertheless I’d figured
    I’d ask. Would you be interested in trading links
    or maybe guest authoring a blog post or vice-versa?

    My website addresses a lot of the same topics
    as yours and I believe we could greatly benefit from each other.

    If you happen to be interested feel free to shoot me an e-mail.
    I look forward to hearing from you! Awesome blog by the way!

  4. Wonderful goods from you, man. I’ve understand your stuff previous to and you are just too great.
    I actually like what you have acquired here, really like what you’re stating and the way in which
    you say it. You make it enjoyable and you still take
    care of to keep it sensible. I cant wait to read much more from you.
    This is actually a great web site.

  5. With havin so much content and articles do you ever
    run into any issues of plagorism or copyright infringement?
    My website has a lot of exclusive content I’ve either
    written myself or outsourced but it appears a lot of
    it is popping it up all over the internet without my authorization. Do you know any solutions
    to help protect against content from being ripped
    off? I’d really appreciate it.

  6. Do you have a spam issue on this site; I also am a blogger, and I was wondering
    your situation; we have created some nice procedures and we are
    looking to trade strategies with others, be sure
    to shoot me an email if interested.

  7. I’m really enjoying the design and layout of your blog. It’s a very easy on the eyes which makes it much more pleasant for me to come here and
    visit more often. Did you hire out a developer to create
    your theme? Great work!

  8. I was wondering if you ever considered changing the
    structure of your website? Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so
    people could connect with it better. Youve got an awful
    lot of text for only having one or 2 images. Maybe you could space it out better?

  9. Definitely consider that which you stated. Your favorite justification seemed to
    be at the net the easiest factor to take note of.

    I say to you, I certainly get irked while folks consider concerns that they plainly don’t understand about.
    You controlled to hit the nail upon the highest and outlined out the
    whole thing without having side-effects , other people can take
    a signal. Will probably be back to get more. Thanks

  10. I’m really inspired together with your writing
    abilities and also with the layout in your weblog. Is this
    a paid subject matter or did you customize it your self?
    Either way keep up the nice quality writing, it is uncommon to look a great
    weblog like this one nowadays..

  11. But as writer Peggy Orenstein discovered while
    carrying out research on her new manual, “Boys & Sex: Young Men on Hookups, Love, Porn, Consent, as well as Navigating the New Masculinity” (Harper),
    out right now, the fact can be actually really various.
    Before Porn, sex was actually plain. You a lot better
    be prepared to view such premium HD sexual activity video clips
    as they include thoughts going scenes, great information and the greatest top
    quality functions online. Get well-balanced. Moderate physical exercise, extending, or even yoga exercise is actually extremely favorable while naked,
    specifically before an uncut looking glass, as one may see
    which muscle mass and ligaments enter into action. These women are actually therefore
    uninhibited that a person can rarely believe. Assuming this holds true, the very best task is to join our web-based dating internet site when you can. My
    BF and also I have been actually dating for 4 months now.
    The branch of the internet sites in to the groups stated above,
    make the consumers look easy and also quickly, so they’ll have a terrific consumer encounter.
    There is actually still much more things I haven’t fully tested, like Dex (Desktop
    Experience).

  12. Hello there! I know this is kind of off topic but I was
    wondering which blog platform are you using for this website?
    I’m getting tired of WordPress because I’ve had problems with hackers and
    I’m looking at options for another platform.
    I would be awesome if you could point me in the direction of a good platform.

  13. Hello There. I discovered your weblog the usage of msn. That is an extremely neatly written article.
    I’ll be sure to bookmark it and come back to learn more of your helpful information.
    Thanks for the post. I will definitely return.

发表回复

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