Best approach to deal with automatic build process and hex files?

Meanwhile I read a lot of documentation of arduino and arduino-cli and searched around for a while. But I still wonder, what the best way is to automatically build a sketch and then treat the generated hex file with my own program. My requirement is to build a given .ino file and then place the generated .hex on a remote server for OTA. I found existing solutions e.g. using a homebrew tool from the tools menu, but always with manual interaction in ui. Can anybody please point me in the right direction?

Do you want to initiate this process from the Arduino IDE GUI, or not use the GUI at all?

No gui at all, please. At the moment I use anrduino-cli inside docker to automatically install esp-core, needed libraries, clone a project from github and build it. But the handling of the compiled hex is odd as it is not hooked up to the arduino process.

I'd like to call something like "arduino-cli upload" using a homebrew script taking the hex and upload it somewhere. It does not need to be arduino-cli, it also can be arduino. Thank you.

Great! For that application, my recommendation is to run the compilation via arduino-cli, but set a custom build path via the --build-path option. Then you know that after the compilation the .hex file will be at {build-path}/{sketch name}.ino.hex. Then just do the upload to the server in your script however you like. No need to make the effort to get arduino-cli to do that for you (though it is possible).

The arduino-cli is relatively new, so if you’re looking at older tutorials, they may not have had it available...