You are close.
The correct derivation is
$\displaystyle g'(\theta) = \frac{d}{dx}\left(\sec\frac{\theta}{2}\tan\frac{\t heta}{2}\right)$
$\displaystyle = \sec\frac{\theta}{2}\left(\frac{1}{2}\sec^2\frac{\ theta}{2}\right)+\left(\frac{1}{2}\sec\frac{\theta }{2}\tan\frac{\theta}{2}\right)\tan\frac{\theta}{2 }$
$\displaystyle =\frac{1}{2}\sec^3\frac{\theta}{2}+\frac{1}{2}\sec \frac{\theta}{2}\tan^2\frac{\theta}{2}$
$\displaystyle =\frac{1}{2}\sec^3\frac{\theta}{2}+\frac{1}{2}\sec \frac{\theta}{2}\left(\sec^2\frac{\theta}{2}-1\right)$
$\displaystyle =\frac{1}{2}\sec^3\frac{\theta}{2}+\frac{1}{2}\sec ^3\frac{\theta}{2}-\frac{1}{2}\sec\frac{\theta}{2}$
$\displaystyle =\sec^3\frac{\theta}{2}-\frac{1}{2}\sec\frac{\theta}{2}.$