Making a bone rig for piston
When working with 3D models, we often work the opposite way to reality, that is we would animate the aerofoil rotating and have the attached parts move to follow its movement. For what you are after you may not need any more than rotating the aerofoil, the interconnecting pieces of a cars rear spoiler may not even be visible.

There are a collection of constraints available that can simplify automated interactions of multiple components.

A piston is composed of two parts, one fitting inside the other and both pieces pointing toward the fixture point of the other. The TrackTo constraint is the easiest way to keep the two piston pieces in place as both ends are moved. You can find a simple example in this answer.

It is possible to build more complex rigs, in this answer a front-end loader rig is setup to move one bone that rotates the scoop as well as the attached parts that would control the movement on a real tractor.