Multiwavelength observations of GRB 110731A: GeV emission from onset to afterglow