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.
Although friendship is used instead of affection to evolve Pokemon like Eevee, it does not carry over most of the other affection bonuses from the original X/Y nor the friendship bonuses from the preceding Gen 9 games. The only bonus effect is that Pokemon with maxed out friendship have their critical hit rate doubled from 1/24 to 1/12.
Credit to @Sibuna_Switch on Twitter for this chart