When we were there last year without a car, we actually took the Greyhound to Merced, and then the Yosemite shuttle from there. Be sure to check the times, because you may end up having to spend the night in Merced (like we did) and then catching the morning shuttle.
On the way back, however, we did take Amtrak. They have their own shuttle that takes you across the bay into SF.
It's a bit more of a hassle than driving, but it ended up being lots of fun...makes the whole trip much more eventful. I'd do it again if I had to.