The amount of friendship gained or lost depends on the action taken and the amount of friendship that the Pokemon already has.
As a result, it is more readable to just show this table:


Notable actions that do not affect friendship:
- Steps
- Gaining EXP (set to always add a value of 0)
- Breaking obstacles, such as Mega Crystals
- Winning battles, including Z-A Royale battles and Rogue Mega Evolution battles
Visiting cafes is the most efficient method for quickly raising the friendship of a single Pokemon, but repeatedly choosing the "Hang out with your Pokémon" option at benches is also a good option if you want to raise friendship with your whole team or don't want to spend money.
Credit to @Sibuna_Switch on Twitter for this chart