Topological photonic systems have recently emerged as an exciting new paradigm to guide light without back-reflections. The Chern topological numbers of a photonic platform are usually written in terms of the Berry curvature, which depends on the normal modes of the system. Here, we use a gauge invariant Green’s function method to determine from first principles the topological invariants of photonic crystals. The proposed formalism does not require the calculation of the photonic band-structure, and can be easily implemented using the operators obtained with a standard plane-wave expansion. Furthermore, it is shown that the theory can be readily applied to the classification of topological phases of non-Hermitian photonic crystals with lossy or gainy materials, e.g., parity-time symmetric photonic crystals.