Is my attempt to prove that Berry's phase is quantized in inversion symmetric systems true? Do I violate gauge invariance? The Berry's or Zak's phase is given as
\begin{align*}
\gamma & =\oint_\mathrm{BZ}d\mathbf{k}\mathcal{\mathcal{\mathcal{A}}}(\mathbf{k})\ \ \mbox{mod }2\pi\\
 & =i\oint_\mathrm{BZ}d\mathbf{k}\langle u_{n}(\mathbf{k})|\nabla_{\mathbf{k}}u_{n}(\mathbf{k})\rangle\ \ \mbox{mod }2\pi\\
\end{align*}
which can take any value between  $[0,2\pi]$.
Now we want to learn the implications of the symmetries on this Berry's
 phase first assume that our system has only inversion symmetry such that
 the hamiltonian obeys
$$U_{p}H(\mathbf{k})=H(-\mathbf{k})U_{p}$$
then we have 
\begin{align*}
U_{p}H(\mathbf{k})U(\mathbf{k}) & =E(\mathbf{k})U_{p}U(\mathbf{k})\\
H(-\mathbf{k})U_{p}U(\mathbf{k}) & =E(\mathbf{k})U_{p}U(\mathbf{k})\\
H(\mathbf{k})U_{p}U(-\mathbf{k}) & =E(-\mathbf{k})U_{p}U(-\mathbf{k})
\end{align*}
such that $E(k)=E(-k)$ and  $U_{p}U(-\mathbf{k})=e^{i\phi(\mathbf{k})}U(\mathbf{k})$ where $U_{k}$ is the vector representation of  $|u(k)\rangle$.
 Now the Berry connection is
\begin{align*}
\mathcal{A}(\mathbf{k}) & =i(U_{p}U(-\mathbf{k})e^{-i\phi(\mathbf{k})})^{\dagger}\nabla_{\mathbf{k}}e^{-i\phi(\mathbf{k})}U_{P}U(-\mathbf{k})\\
 & =i(U(-\mathbf{k}))^{\dagger}e^{i\phi(\mathbf{k})}\nabla_{\mathbf{k}}e^{-i\phi(\mathbf{k})}U(-\mathbf{k})\\
 & =-\mathcal{A}(-\mathbf{k})+\nabla_{\mathbf{k}}\phi(\mathbf{k})
\end{align*}
and the Berry's phase is for a 1d  $\mathrm{BZ}$ for simplicity
\begin{align}
\gamma & =\intop_{-\pi}^{\pi}dk\,\mathcal{A}(k)\\
 & =-\intop_{-\pi}^{\pi}dk\,[\mathcal{A}(-k)+\nabla_{k}\phi(k)]\\
 & =\left.\phi(k)\right|_{-\pi}^{\pi}-\underbrace{\intop_{-\pi}^{\pi}dk\,\mathcal{A}(k)}_{\gamma}\label{eq:-18}\\
 & =2\pi n-\gamma\label{eq:-17}
\end{align}
thus we have 
\begin{align*}
\gamma=\pi n
\end{align*}
since $\gamma$ is well defined only up to $\mbox{mod }2\pi$ it can be $0$ or $\pi$ while obeying the last condition.
My suspicion arises from the last step. The Berry phase should be gauge independent, but here it looks like gauge term determines its value.
 A: Your derivation is perfectly correct. Please see Hatsugai (page 16) who performs essentially the same calculation as you did.
I'll explain here why nevertheless the Zak phase is gauge invariant, therefore a legitimate observable.
The phase $\phi(\mathbf{k})$ is not a gauge transformation. It is the additional phase added to the state vectors as a consequence of the application of the physical operator of time reversal operator (which I'll denote by $\mathcal{T}$ for clarity). In a time reversal symmetric system as you wrote:
$$\mathcal{T} | u(\mathbf{k}) \rangle = e^{i\phi(\mathbf{k})} | u(\mathbf{-k}) \rangle $$
The function $ e^{i\phi(\mathbf{k})} $ can be any true function on the brillouin zone which has the topology of $S^1$. Thus we must have :
$$ e^{i\phi(\pi)} = e^{i\phi(-\pi)} $$ 
Thus
$$ \phi(\mathbf{-\pi}) = \phi(\mathbf{\pi}) + 2 \pi n$$
This transformation has a winding number $n$
$$\frac{1}{2 \pi}\int e^{-i\phi(\mathbf{k})} d  e^{i\phi(\mathbf{k})} = n$$
In contrast as a gauge transformation, $ e^{i\phi(\mathbf{k})}$ is a large gauge transformation. In quantum mechanics large gauge transformations correspond to physically different states. This issue was discussed in physics stack exchange in the past, please see the following questions and answers: (1),  and  (2). 
The resons for that is that quantum theories in which states related by a large gauge transformation are distinct are completely consistent. There is no need in quatum mechanics to identify between these states, in contrast to the small gauge transformations which lead to constraints that we should get rid of in order to quantize. In reality, large gauge transformation describe superselection sectors, which explain a wide variety of phenomena. For example in the Aharonov-Bohm effect, the superselection sectors correspond to different (nonquantized) values of the flux; and for a particle moving on a torus with magnetic flux the superselection sectors correspond to different quantized fluxes. In both cases the wave functions are the same except for a phase factor, nevertheless they represent different systems.
Therefore, for a gauge transformation we should select only functions , $ e^{i\phi(\mathbf{k})}$ having a zero winding number, which makes the Zak phase gauge invariant.
