Switching higher voltage current source

I know how to switch a current sink with a higher source voltage (i.e., 12V source switched with 5V GPIO pin) using an NPN transistor. I also know how to switch a current source with the same source voltage using a PNP transistor (5V source switched with 5V GPIO pin). But what is the best-practice way to source current from a 12V source and have it switched by a 5V GPIO pin?

Gate driver.

The circuit is called a high sided switch.
The simplest has two transistors the first is an NPN which generates a 0 to 12V signal from a 0 to 5V one. The second stage puts that to a PNP transistor high side switch. You can also do the same thing with FETs

MicrocontrollerGuy wrote (in part):

But what is the best-practice way to source current from a 12V source and have it switched by a 5V GPIO pin?

It depends upon what you want to achieve: least number of parts, highest reliability, simplicity, lowest cost, use existing parts, use existing circuit, use only bipolar transistors, use only MOSFETs, use a combination of MOSFETs and bipolar transistors, use a relay, use a phototransistor, achieve electrical isolation, etc.

But what is the best-practice way to source current from a 12V source and have it switched by a 5V GPIO pin?

Since you did not provide any quantitative design criteria I am just going to through this out there and if it is not rated for enough current, then don't use it:

TC4431

The NPN/PNP and the TC4431 both look like they would be good solutions for this. I didn't post detailed design requirements because this isn't for a specific design. It's just something I realized I don't know how to do and I should know how to do.

It's just something I realized I don't know how to do and I should know how to do.

If only other newbies had your ambition and high goals...

FYI,

"Knowing how to do things works better when you know how to do things..."

(meaning all your designs will work the first time if you follow the right steps in the process:
ie: 1-start with design criteria
2- make schematic and parts list
3- prototype circuit highlighting each connection on the schematic as you make it and doing a continuity check of each connection.
4- Measure power supply voltages BEFORE connecting them to the power bus on the breadboard.
5 - Measure all important circuit voltages after power up.
etc
etc
etc