The automated computation of tree-level and next-to-leading order differential cross sections, and their matching to parton shower simulations