Anharmonic Properties of Semiconductors from Density-Functional Perturbation Theory