There are many different methods. I've had the best lasting results with cold brewed coffee added to secondary/keg.
What ever you chose to do, don't just hot brew coffee, let it cool, and add it to the beer. Generally it will be much too bitter and turn vegetal quicker.