Answer
$$y= \frac{1}{\sec x +\tan x}\left( x-\cos x +C\right).$$
Work Step by Step
This is a linear equation and has the integrating factor as follows $$\alpha(x)= e^{\int P(x)dx}=e^{ \int \sec x dx}=e^{\ln(\sec x +\tan x)}=\sec x +\tan x$$ where we used the fact that $ \int \sec xdx=\ln(\sec x+\tan x)$.
Now the general solution is
\begin{align}
y&=\alpha^{-1}(x)\left( \int\alpha(x) Q(x)dx +C\right)\\ &=\frac{1}{\sec x +\tan x}\left( \int (\sec x +\tan x)\cos xdx +C\right)\\ &= \frac{1}{\sec x +\tan x}\left( \int (1 +\sin x) dx +C\right)\\
&= \frac{1}{\sec x +\tan x}\left( x-\cos x +C\right)\\ \end{align}
where we used integration by parts.
Thus, the general solution is:
$$y= \frac{1}{\sec x +\tan x}\left( x-\cos x +C\right).$$