I'm angry with myself, I think I betrayed my friend's trust.
Why do you think you betrayed your friend's trust?
He's been rude to me lately so I told one of his secrets to his girlfriend.
I am sorry your friend was rude but this does not allow you to breach your friend's trust. It is wrong to breach trust of a friend as relationships are based on trust.
I know it was wrong, but I don't know how to fix it.
You should apologize to him and try to work this out. Tell him how you feel and tell him how much his friendship means to you. I think you can save your relationship.