The first law of general quantum resource theories