Follow BoS questline.Complete Tactical Thinking.DO not proceed with the quest ad Victoriam.Complete all previous quests if you like.
Complete form ranks after you have become an enemy of the Institute (Shoot people inside or kill Courser during Battle of Bunker Hill and then verbally attack Father,or complete Spoils of war)
Complete defend the castle.
Proceed from here with The Nuclear Option (Minutemen)
You can do all Institute quest you like untill Mass Fusion.
You can do all RR quest you like.Completing Spoils of war will also fail RR Questline.
The best advice I can give you to avoid BoS ending is to not plug the Beryllium agitator in the back of liberty prime.Doing this will trigger the assault on the institute (BoS)
ALSO:If you are gonna destroy the RR anyway,why not stick with the BoS?The minutemen will still be happy about the ending.
If you go through with the MM ending,the BoS members might sound kinda pissed about it,nothing big really,but still.The will say stuff like "Ugh ,it should have been us dealing the final blow to the Institute"