The ideal solution is two power supplies; 5V one for the uC, 12V for the stepper, with opto-isolation for the logic drive.
Second best is two power supplies, common ground connection, without opto-isolation.
Third best is one 12V power supply, with a linear regulator to create the 5V, common ground.
Preventing inductive spikes from the stepper getting into and interfering with the uC operation has generated hundreds of posts on these forums. If you start with option 3, you will learn more than you ever wanted to know about common grounds, single-point grounds, ground-loops, bypassing, common-mode noise, shielding, bypassing, etc...