Run script before build

My optimization script works similarly to occlusion culling but designed for my task.Overally It changes hierarchy and adds parent nodes to groups of objects so that these groups can be enabled/disabled relatively to distance from camera to particular group. I dont want to run this script every time I run the scene and I dont want to run it in editor but it would be great to run it before build. I searched in unity docs and found nothing that can help me to specify the list of scripts to be run before build :frowning:

I suspect you have already thought of what I’m about to say, but I can’t think of any other of doing it.

Make a GameObject and attach it an Editor Script with just one button. When clicking it, make all he calls.
And make sure you only click this button right before building the project.