Fermi Detection of \gamma-Ray Emission from the M2 Soft X-Ray Flare on 2010 June 12