samuelmeuli / action-electron-builder

:electron: GitHub Action for building and releasing Electron apps
MIT License
658 stars 201 forks source link

electron-builder configuration CLI overrides #10

Closed GabeMedrash closed 4 years ago

GabeMedrash commented 4 years ago

Hi there,

I just started using this Github action--extremely useful, thank you for it. One piece that I found missing for my use case is the ability to pass a configuration override (e.g., -c.extraMetadata.foo=bar) directly to the electron-builder build command.

This PR accomplish that in a generic way. From a consumer's workflow yml file, a user can now pass a config_overrides object as a JSON string to this action, which will transform it into a properly formed -c.x.y.z=value config CLI arg. For example, passing:

config_overrides: >
  {
    "extraMetadata": {
      "version": "4.3.2-snapshot",
      "foo": "bar
    },
    "linux": {
      "target": "deb"
    }
  }

will be passed through to the electron-builder build command as -c.extraMetadata.version=4.3.2-snapshot -c.extraMetadata.foo=bar -c.linux.target=deb.

Let me know what you think! Thanks for the consideration, Gabe

samuelmeuli commented 4 years ago

Hi Gabe, thanks a lot for the PR!

electron-builder seems to support external config files already:

❯ yarn run electron-builder --help

...

Building:
...
  --config, -c             The path to an electron-builder config. Defaults to
                           `electron-builder.yml` (or `json`, or `json5`), see
                           https://goo.gl/YFRJOM

Instead of reimplementing that logic in this action, I would prefer an option where such a config path could be specified. That path could then simply be passed along to electron-builder.

What do you think? :)

GabeMedrash commented 4 years ago

Oh, huh. It was difficult to tell from the documentation (so I didn't experiment), but I thought the --config option was specifically for specifying electron-builder config in a place other than package.json or electron-builder.yml, not a mechanism for deep merging external config with automatically discovered config (like in package.json). Have you experimented with that?

Essentially the use-case I'm trying to cover here is overriding the version so that I can accomplish pre-release builds from feature branches. I'm triggering my release workflow through a repository_dispatch event, and sending in the git ref to build from and the version as a parameter.

samuelmeuli commented 4 years ago

Hmm. The CLI and docs really are confusing. I tested this quickly, and it's apparently possible to provide either a file path or a config string. So the CLI help information seems to be outdated.

I would suggest going with a config option for this action, which just passes its value along to the electron-builder command (with the --config flag). That way, all the parsing logic is delegated to electron-builder.

GabeMedrash commented 4 years ago

Makes sense! I'll take a look and update my PR.

mayeths commented 4 years ago

So is this PR still move on? it's really a lifesaver.

nicosampler commented 4 years ago

Any news on this? I need to overwrite the electron-builder config as well.

samuelmeuli commented 4 years ago

This can now be achieved with the args option introduced in v1.5.0.