Use Minkowski spacetime signature and write . The reparametrization-invariant relativistic charged-particle action is
The first term is because
An electromagnetic gauge transformation is
It leaves the electromagnetic field tensor unchanged because antisymmetrized second derivatives commute. The action changes only by
This endpoint term has zero variation for fixed endpoints, which is the gauge invariance of the charged-particle worldline action.