Build RPM in CI

Does anyone know how to automatically build RPM from your compiled binary in CI running Linux.

Using command rpmdev-setuptree seems to create the build tree in the home directory. It is possible to change that location, but how is that securely done?

Is there annother method to build RPMs?