How to correctly calculate academic gpa

Do you calculate it per class (adding up each class separately, finding the average per class, then finding the average of all your classes total) or per school year (adding all classes together per year, finding the average of those classes together per year)?

the first method.

thanks thanks