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

752 个评论

  1. Hello! This is kind of off topic but I need some advice from an established blog.
    Is it very 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? Thanks

  2. Its like you read my thoughts! You seem to grasp
    so much about this, like you wrote the e-book in it or something.

    I think that you simply can do with some p.c. to force the message home a little bit, however instead of that, that is wonderful blog.

    A fantastic read. I’ll definitely be back.

  3. hey there and thank you for your info – I have definitely picked up something new from right
    here. I did however expertise several technical issues using
    this web site, since I experienced to reload the web
    site lots of times previous to I could get it to load correctly.

    I had been wondering if your hosting is OK? Not that I’m
    complaining, but slow loading instances times will often affect your placement in google
    and can damage your quality score if advertising and marketing with
    Adwords. Well I’m adding this RSS to my e-mail and could look out for much more of your respective
    interesting content. Make sure you update this again soon.

  4. Hi there! I realize this is kind of off-topic
    but I needed to ask. Does building a well-established website like yours take a massive amount work?

    I am brand new to writing a blog but I do write in my journal every day.

    I’d like to start a blog so I can easily share my own experience
    and feelings online. Please let me know if you have any kind of ideas or tips for new aspiring
    bloggers. Thankyou!

  5. Please let me know if you’re looking for a
    article author 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 absolutely love to write some content for your blog in exchange for a
    link back to mine. Please shoot me an e-mail if interested.
    Cheers!

  6. Hmm it looks like your site ate my first
    comment (it was extremely long) so I guess I’ll just sum it up what I had
    written and say, I’m thoroughly enjoying your blog.

    I as well am an aspiring blog writer but I’m still new to the whole thing.
    Do you have any points for beginner blog writers?
    I’d definitely appreciate it.

  7. Thanks for some other informative website. Where else may I am
    getting that type of info written in such a perfect means?
    I have a venture that I’m just now working on, and I’ve been on the look out
    for such information.

  8. kızlık bozma onlıne izle school giril amator sex videos rus pornosu sex videosu izle son yılların en sexi götleri
    gerdek gecesi kızlık zarı patlatma videoları azeri sekis ru , rus
    sekisi viyosu , rusya porno vidosu , rusya sex com

发表评论

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