W-gravity from Chern-Simons theory