Analog of Gauss-Bonnet formula for principal bundles over manifolds with boundary The Gauss-Bonnet formula gives a topological invariant as an integral over a local density on the given manifold. In particular, when there is a boundary, GB formula has to be supplemented by a boundary term, for example the extrinsic curvature in two dimensional case.
I am wondering if there is an analogous topological invariant for a gauge theory (or principal bundle) on manifolds with boundary, and if so, what is the local density to be integrated over, including the boundary term. I am particularly interested in the case of the two dimensional base manifold with U(1) gauge group. 
Since I am from a physics background and pretty new to this kind of subject, it would be especially great if one can also point to physics-oriented reference on this.

What you are looking for is the theory of characteristic classes of principal bundles. You can take any connection on the principal bundle, plug it in the appropriate $G$-invariant polynomial and what you get is an element of cohomology that descends to the base manifold. For a certain choice you would get the Chern class of the principal bundle which is integral in the sense that it corresponds to an element of integral singular cohomology via the de-Rham isomorphism.
If you want to learn the theory of connections, curvature and characteristic classes for principal bundles, I recommend the books 'Foundations of differential geometry' by Kobayashi and Nomizu. 
