BBEG correct leveling?

Hello everyone! I'm dming a campaign of about 4 players all at level 12, and they're about to fight the bbeg. I don't want to give them an easy fight, or a too difficult one, so what level should I do? I'm planning on throwing a sorcerer their way with a couple legendary actions. I need some help since this is my first full length campaign, and my one shot had a BBEG that bored the players and they killed within three turns. This was with 3 players at level 8! Any suggestions? I kinda really need it.